/* ---------------------------------------------------------------------------
   Soft Throw, a portrait page.

   The tokens are Motion Lab's, copied rather than linked so the game runs on
   its own: the paper, the three inks, the six fills from the double-diamond
   diagram and the motion curves. The canvas reads the same properties, so a
   colour changes in one place.

   No webfonts: the system stack carries Chinese and Latin on every phone and
   nothing has to come from a server that may not answer.
--------------------------------------------------------------------------- */

:root{
  color-scheme:light;
  --bg:#fefdf9;
  --surface:#f5f4f0;
  --surface-2:#ecebe4;
  --surface-3:#dcdbd2;
  --tint:#f1f0ea;
  --line:#dedad7;
  --line-soft:#eeebe9;
  --ink:#1e1b19;
  --ink-2:#39332f;
  --ink-3:#8e8781;
  --c1:#01b6ff;   /* azure  */
  --c2:#cc9fd2;   /* orchid */
  --c3:#fe7236;   /* orange */
  --c4:#24cc71;   /* green  */
  --c5:#fafd5d;   /* yellow */
  --c6:#94b8ac;   /* sage   */
  --ok:#1f9d58;
  --shadow-2:0 2px 10px rgba(0,0,0,.07), 0 30px 70px rgba(0,0,0,.14);
  --r-m:18px;
  --r-l:24px;
  --e-standard:cubic-bezier(.2,0,0,1);
  --e-spring:cubic-bezier(.34,1.56,.64,1);
  --font:-apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
         "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* mono faces carry no Chinese, and left alone Windows falls back to a
     thin serif for it; the sans fallbacks keep digits monospaced and the
     Chinese in the same face as the rest of the interface */
  --mono:ui-monospace, SFMono-Regular, "SF Mono", "Cascadia Mono", Menlo, Consolas,
         "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  /* one size for every word in the interface; only the title and the
     result card's headline are larger */
  --fs:15px;
  /* the one hand-drawn pen, from the site's heading rules */
  --wiggle:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 58 7' preserveAspectRatio='none'%3E%3Cpath d='M2 4.8C11 2.7 21 5.2 30 3.4 39 1.6 48 4.4 56 2.6' fill='none' stroke='%23000' stroke-width='2.8' stroke-linecap='round'/%3E%3C/svg%3E");
}

*,*::before,*::after{box-sizing:border-box}
html,body{margin:0;height:100%;background:var(--bg);color:var(--ink);font-family:var(--font);
  -webkit-text-size-adjust:100%;overscroll-behavior:none}
body{
  /* the site's dot field, outside the column on wide screens */
  background-image:radial-gradient(var(--line) 1.1px, transparent 1.3px);
  background-size:22px 22px;
  -webkit-user-select:none;user-select:none;-webkit-touch-callout:none;
  -webkit-tap-highlight-color:transparent;
}
button{font:inherit;color:inherit}

.app{
  height:100vh;height:100dvh;
  width:min(100vw, 560px);margin:0 auto;
  display:grid;grid-template-rows:auto 1fr auto;gap:8px;
  padding:calc(env(safe-area-inset-top,0px) + 8px) calc(env(safe-area-inset-right,0px) + 12px)
          calc(env(safe-area-inset-bottom,0px) + 10px) calc(env(safe-area-inset-left,0px) + 12px);
  background:var(--bg);
}
@media (min-width:600px){ .app{box-shadow:0 0 0 1px var(--line-soft)} }

/* --- header ------------------------------------------------------------- */
.hud{display:flex;align-items:center;gap:6px;min-height:40px}
.hud__title{margin:0 auto 0 2px;font-size:19px;font-weight:800;letter-spacing:-.01em;line-height:1;
  position:relative;padding-bottom:13px}
.hud__title::after{content:"";position:absolute;left:0;bottom:0;width:46px;height:7px;background:var(--ink);
  -webkit-mask:var(--wiggle) center/100% 100% no-repeat;mask:var(--wiggle) center/100% 100% no-repeat}
.hud__title span{font:500 var(--fs)/1 var(--mono);color:var(--ink-3);margin-left:9px;letter-spacing:.02em}

.pill{appearance:none;border:0;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;
  min-height:38px;padding:0 13px;border-radius:999px;background:var(--surface);color:var(--ink);
  font-size:var(--fs);font-weight:600;white-space:nowrap;
  transition:background .12s var(--e-standard),transform .2s var(--e-spring)}
.pill:active{transform:scale(.96)}
.pill[aria-pressed="false"]{color:var(--ink-3)}
.pill--ink{background:var(--ink);color:var(--bg)}
.pill.is-nudge{box-shadow:inset 0 0 0 2px var(--c3);animation:nudge 1.6s ease-in-out infinite}
.pill:disabled{opacity:.4;cursor:default}
@keyframes nudge{50%{box-shadow:inset 0 0 0 2px var(--c3),0 0 0 4px rgba(254,114,54,.18)}}

/* --- level sheet -------------------------------------------------------- */
/* Levels live behind one button, in a sheet over the tile, so the world
   keeps the whole height. Twelve small tiles in three columns. */
.sheet{position:absolute;inset:0;z-index:3;display:flex;flex-direction:column;gap:12px;padding:16px;
  background:rgba(254,253,249,.96);animation:sheet-in .32s var(--e-spring) both}
.sheet[hidden]{display:none}
.sheet__head{display:flex;align-items:baseline;justify-content:space-between}
.sheet__head b{font-size:var(--fs)}
.sheet__head span{font:400 var(--fs)/1 var(--mono);color:var(--ink-3)}
.sheet__grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;align-content:start;overflow:auto;min-height:0}
.sheet__ch{grid-column:1/-1;margin-top:6px;font-size:var(--fs);font-weight:600;line-height:1.4;color:var(--ink-3)}
.sheet__ch:first-child{margin-top:0}
/* number and name on one line, the tick at the far end */
.lv{appearance:none;border:0;cursor:pointer;position:relative;min-width:0;min-height:52px;padding:0 28px 0 12px;border-radius:var(--r-m);
  background:var(--surface);color:var(--ink);text-align:left;
  display:flex;flex-direction:row;align-items:center;gap:8px}
.lv span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.lv i{font:400 var(--fs)/1 var(--mono);font-style:normal;color:var(--ink-3)}
.lv span{font-size:var(--fs);font-weight:700;line-height:1.25}
.lv[aria-current="true"]{background:var(--ink);color:var(--bg)}
.lv[aria-current="true"] i{color:inherit;opacity:.65}
.lv.is-done::after{content:"✓";position:absolute;right:10px;top:50%;transform:translateY(-50%);color:var(--ok);font-weight:800}
.lv[aria-current="true"].is-done::after{color:var(--c4)}
.sheet__opts{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap}
@keyframes sheet-in{from{opacity:0;transform:translateY(10px)}}

/* --- the tile ----------------------------------------------------------- */
.stage{position:relative;min-height:0;display:flex;align-items:center;justify-content:center;
  border-radius:var(--r-l);background:var(--surface);overflow:hidden}
/* the frame is exactly the canvas, so every label sits inside the world's
   walls whatever shape the tile is */
.frame{position:relative;flex:none}
.frame canvas{display:block;touch-action:none;cursor:grab}
.frame canvas.is-aiming{cursor:grabbing}
.side{flex:1;align-self:stretch;display:none;flex-direction:column;align-items:center;justify-content:flex-end;
  gap:12px;padding:16px 0}
.app.is-wide .side{display:flex}
.app.is-wide .dock{display:none}
.app.is-wide .inv{flex-direction:column;margin:0;gap:12px}
.tile-label{position:absolute;left:16px;top:13px;right:110px;display:flex;flex-direction:column;gap:3px;pointer-events:none}
.tile-label b{font-size:var(--fs);font-weight:700;color:var(--ink)}
.tile-label span{font-size:var(--fs);color:var(--ink-2)}
.tile-meta{position:absolute;right:14px;top:14px;font:400 var(--fs)/1.35 var(--mono);color:var(--ink-3);
  text-align:right;pointer-events:none;white-space:pre}

.hint{position:absolute;left:12px;right:12px;top:58px;margin:0;padding:10px 14px;border-radius:var(--r-m);
  background:rgba(254,253,249,.94);box-shadow:0 0 0 1px var(--line);font-size:var(--fs);line-height:1.5;color:var(--ink-2);
  cursor:pointer;animation:pop-hint .3s var(--e-spring) both}
@keyframes pop-hint{from{opacity:0;transform:translateY(-6px)}}
.hint b{color:var(--ink)}
.hint i{font:500 var(--fs)/1 var(--mono);font-style:normal;color:var(--ink-3);margin-right:8px}

.toast{position:absolute;left:50%;top:62px;transform:translateX(-50%);width:min(88%,330px);
  display:flex;flex-direction:column;align-items:center;gap:6px;padding:18px 18px 16px;border-radius:var(--r-l);
  background:var(--ink);color:var(--bg);box-shadow:var(--shadow-2);text-align:center;
  animation:pop .48s var(--e-spring) both}
.toast[hidden]{display:none}
.toast b{font-size:20px;font-weight:800;letter-spacing:.02em}
.toast span{font-size:var(--fs);font-weight:500;opacity:.85}
.toast__act{display:flex;gap:8px;margin-top:8px}
.toast button{appearance:none;border:0;cursor:pointer;min-height:40px;border-radius:999px;padding:0 16px;
  font-size:var(--fs);font-weight:700;background:rgba(255,255,255,.14);color:inherit}
.toast button.is-main{background:var(--c5);color:#1e1b19}
@keyframes pop{from{opacity:0;transform:translate(-50%,-10px) scale(.94)}}
.toast.is-center{top:50%;transform:translate(-50%,-50%);animation-name:pop-c}
@keyframes pop-c{from{opacity:0;transform:translate(-50%,-46%) scale(.94)}}

/* --- dock --------------------------------------------------------------- */
/* blobs in the middle, retry at the right; the empty first column keeps the
   blobs centred however wide the retry button is */
.dock{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(max-content,1fr);align-items:center;gap:6px;
  padding-bottom:6px}
/* five or more blobs on a phone: a size down so the row still fits */
.inv:has(.chip:nth-child(5)) .chip{width:46px;height:46px}
.inv:has(.chip:nth-child(5)){gap:6px}
.inv{display:flex;gap:8px;min-width:0;grid-column:2}
.dock #retry{grid-column:3;justify-self:end}
.chip{appearance:none;border:0;cursor:pointer;width:52px;height:52px;border-radius:50%;padding:0;
  display:grid;place-items:center;background:var(--surface);position:relative;
  transition:transform .2s var(--e-spring),opacity .2s,box-shadow .12s}
.chip svg{width:38px;height:38px}
.chip[aria-checked="true"]{box-shadow:inset 0 0 0 2.5px var(--ink);transform:translateY(-3px)}
.chip:disabled{opacity:.28;cursor:default;transform:none;box-shadow:none}
.chip:disabled svg{filter:grayscale(1)}
.chip small{position:absolute;bottom:-8px;left:50%;transform:translateX(-50%);padding:1px 6px;border-radius:8px;
  font:600 var(--fs)/1.25 var(--font);background:var(--bg);color:var(--ink-2);box-shadow:0 0 0 1px var(--line);white-space:nowrap}

#game-err{position:fixed;left:8px;right:8px;bottom:8px;z-index:9;padding:10px 12px;border-radius:12px;
  background:#2b1d16;color:#ffd9c7;font:var(--fs)/1.45 var(--mono);white-space:pre-wrap;user-select:text}

/* three columns of names like 斜坡上的压板 need about 520px; below that, two */
@media (max-width:520px){
  .sheet__grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:420px){
  .hud__title span{display:none}
  .hud .pill{padding:0 11px}
}
@media (prefers-reduced-motion:reduce){
  .toast,.pill.is-nudge,.sheet{animation:none}
}
