/*
 * Tsumiki — page chrome and the heads-up display.
 *
 * Two visual languages, on purpose, and they meet in the middle.
 *
 * The menus are Minecraft's: hard-edged panels wallpapered with the game's own
 * dirt texture, buttons with a three-pixel bevel that inverts when pressed, and
 * white text over a hard offset shadow. Nothing is rounded and nothing fades,
 * because that is the vocabulary she already reads as "this is my kind of game"
 * before she has read a single word on the screen.
 *
 * The in-world HUD is a phosphor monitor: the words themselves glow, so that
 * English on screen is always the brightest thing in the room. The bloom in the
 * shader is the other half of the same idea.
 *
 * The dirt and stone data URLs are injected as custom properties at boot from
 * the same canvas that paints the world's textures — see atlas.js.
 */

:root {
  --ink: #e6e6e6;
  --phos: #6cff9f;         /* the glow on live text in the world */
  --amber: #ffd83d;        /* Minecraft's yellow: splash text and rewards */
  --rose: #ff9fb4;         /* Japanese lines, so the eye separates them */

  --stone: #8b8b8b;        /* button face */
  --stone-lt: #c6c6c6;     /* top-left bevel */
  --stone-dk: #545454;     /* bottom-right bevel */
  --stone-on: #a3b58f;     /* hovered button, greened slightly */
  --slot: #1d1d22;         /* inventory-slot interior */

  --dirt: none;            /* set from js/atlas.js at boot */
  --rock: none;

  --shadow: 3px 3px 0 rgba(0, 0, 0, 0.6);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN",
               system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}

#stage {
  display: block;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  /* chunky is the point — never let the browser smooth the upscale */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hidden { display: none !important; }

/*
 * The Minecraft bevel, as one reusable rule. Three pixels of light on the top
 * and left, three of shade on the bottom and right, and a hard black keyline
 * around the whole thing so it reads at any scale against any background.
 */
.bevel {
  border: 0;
  border-radius: 0;
  box-shadow:
    inset 3px 3px 0 var(--stone-lt),
    inset -3px -3px 0 var(--stone-dk),
    0 0 0 3px #000;
}
.bevel-in {
  border: 0;
  border-radius: 0;
  box-shadow:
    inset 3px 3px 0 var(--stone-dk),
    inset -3px -3px 0 var(--stone-lt),
    0 0 0 3px #000;
}

/* ---------------------------------------------------------------- crosshair */

/*
 * Deliberately larger than Minecraft's. Eight-year-old eyes on a laptop lose a
 * four-pixel plus sign against grass, and a player who cannot see where she is
 * aiming reads that as the game being broken.
 */
#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  opacity: 0.85;
}
#crosshair span {
  position: absolute;
  background: #fff;
  mix-blend-mode: difference;
}
#crosshair span:nth-child(1) { left: 0; top: 11px; width: 26px; height: 4px; }
#crosshair span:nth-child(2) { left: 11px; top: 0; width: 4px; height: 26px; }
body.big-aim #crosshair { width: 40px; height: 40px; }
body.big-aim #crosshair span:nth-child(1) { top: 17px; width: 40px; height: 6px; }
body.big-aim #crosshair span:nth-child(2) { left: 17px; height: 40px; width: 6px; }

/* ------------------------------------------------------------- world HUD */

.panel {
  background: rgba(8, 10, 9, 0.78);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.14),
              inset -2px -2px 0 rgba(0, 0, 0, 0.5),
              0 0 0 2px #000;
  padding: 10px 18px;
}

#look {
  position: absolute;
  left: 50%;
  top: calc(50% + 44px);
  transform: translateX(-50%);
  text-align: center;
  min-width: 190px;
}
#look .en {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.10em;
  color: #fff;
  text-shadow: var(--shadow), 0 0 12px var(--phos), 0 0 30px rgba(108, 255, 159, 0.5);
}
/* The Japanese is only a little smaller than the English, not half its size.
 * It is the line she can already read, and it is what makes the English above
 * it mean anything. */
#look .ja {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-top: 4px;
  color: #ffd9e2;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.6), 0 0 16px rgba(255, 159, 180, 0.8);
}
#look .hint {
  font-size: 11px;
  margin-top: 5px;
  opacity: 0.45;
  letter-spacing: 0.1em;
}

/* --------------------------------------------------------------- hotbar */

/* One dark bar with nine slots cut into it, as close to the original as CSS
 * gets without an image. The selector is a white frame that overhangs. */
#hotbar {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  gap: 0;
  padding: 4px;
  background: rgba(20, 20, 24, 0.82);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.13),
              inset -2px -2px 0 rgba(0, 0, 0, 0.6),
              0 0 0 3px #000;
  pointer-events: auto;
}
.slot {
  position: relative;
  width: 62px;
  height: 62px;
  background: var(--slot);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.55),
              inset -2px -2px 0 rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  cursor: pointer;
}
.slot canvas {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}
.slot .lab {
  position: relative;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding-bottom: 3px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  white-space: nowrap;
  overflow: hidden;
  max-width: 60px;
}
.slot .key {
  position: absolute;
  left: 4px;
  top: 2px;
  font-size: 10px;
  color: #fff;
  opacity: 0.4;
  text-shadow: 1px 1px 0 #000;
}
.slot.on {
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.4),
              inset -2px -2px 0 rgba(255, 255, 255, 0.1),
              0 0 0 4px #fff, 0 0 16px rgba(255, 255, 255, 0.35);
  z-index: 2;
}

/* ----------------------------------------------------------- word flash */

/*
 * The big one. When a block is named, the word is thrown across the middle of
 * the screen — English enormous, Japanese enormous underneath it — held for
 * about a second and then let go.
 *
 * It is deliberately the largest thing in the game. Text that shares the screen
 * politely with the scenery gets read as scenery; text that takes the screen
 * gets read. Both lines are sized in vw so they fill a laptop and a big monitor
 * the same way, and both carry the phosphor glow, so the word is also the
 * brightest object in the frame for as long as it is up.
 */
#flash {
  position: fixed;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 96%;
  pointer-events: none;
  z-index: 40;              /* above the overlays — see the note in index.html */
}
.fl-tag {
  font-size: clamp(12px, 1.5vw, 20px);
  letter-spacing: 0.34em;
  font-weight: 800;
  color: var(--amber);
  margin-bottom: 6px;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.65), 0 0 22px rgba(255, 216, 61, 0.75);
}
.fl-en {
  font-size: clamp(54px, 10vw, 148px);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.02;
  color: #fff;
  text-shadow:
    5px 5px 0 rgba(0, 0, 0, 0.55),
    0 0 18px rgba(255, 255, 255, 0.55),
    0 0 44px var(--phos),
    0 0 90px rgba(108, 255, 159, 0.55);
}
.fl-ja {
  font-size: clamp(32px, 5.6vw, 82px);
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.25;
  margin-top: 6px;
  color: #ffd9e2;
  text-shadow:
    4px 4px 0 rgba(0, 0, 0, 0.5),
    0 0 16px rgba(255, 159, 180, 0.9),
    0 0 52px rgba(255, 110, 150, 0.7);
}
.fl-s {
  font-size: clamp(14px, 1.8vw, 24px);
  margin-top: 12px;
  color: #eafff2;
  opacity: 0.9;
  letter-spacing: 0.04em;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.6), 0 0 20px rgba(108, 255, 159, 0.5);
}

/* Gold treatment for a word she has never met before. */
.flash.gold .fl-en {
  text-shadow: 5px 5px 0 rgba(0, 0, 0, 0.55),
               0 0 20px rgba(255, 255, 255, 0.6),
               0 0 50px var(--amber),
               0 0 110px rgba(255, 216, 61, 0.6);
}

/*
 * Overshoot, settle, hold, lift away. The hold is done by the element's own
 * lifetime rather than by the keyframes, so the same animation serves a
 * one-second glance at DIRT and a two-and-a-half second fanfare for a new word.
 */
.flash {
  animation: flashIn 0.34s cubic-bezier(0.16, 1.4, 0.4, 1) both;
}
.flash.out { animation: flashOut 0.42s ease-in both; }

@keyframes flashIn {
  from { opacity: 0; transform: scale(0.62) translateY(26px); filter: blur(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}
@keyframes flashOut {
  to { opacity: 0; transform: scale(1.10) translateY(-26px); filter: blur(3px); }
}

/* --------------------------------------------------------------- toasts */

#toasts {
  position: fixed;
  left: 50%;
  top: 13%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 41;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
}
.toast {
  padding: 12px 24px;
  background: rgba(8, 10, 9, 0.85);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.14),
              inset -2px -2px 0 rgba(0, 0, 0, 0.55),
              0 0 0 3px #000;
  text-align: center;
  animation: pop 0.24s steps(4, end);
}
.toast .t-en {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: var(--shadow), 0 0 14px var(--phos);
}
.toast .t-ja { font-size: 15px; color: var(--rose); margin-top: 2px;
               text-shadow: 2px 2px 0 rgba(0,0,0,0.7); }
.toast .t-tag {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--amber);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7), 0 0 12px rgba(255, 216, 61, 0.6);
  margin-bottom: 4px;
}
.toast.fade { animation: fadeout 0.4s steps(5, end) forwards; }
.toast.gold .t-en { text-shadow: var(--shadow), 0 0 16px var(--amber); }

/* Stepped, not eased. Minecraft has no easing curves and neither does this. */
@keyframes pop {
  from { transform: scale(0.72) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes fadeout { to { transform: translateY(-14px); opacity: 0; } }

/* -------------------------------------------------------- corners, quest */

#topright {
  position: absolute;
  right: 16px;
  top: 14px;
  text-align: right;
  letter-spacing: 0.06em;
}
#stars {
  color: var(--amber);
  font-weight: 800;
  font-size: 22px;
  text-shadow: var(--shadow), 0 0 14px rgba(255, 216, 61, 0.6);
}
#mute {
  font-size: 12px;
  margin-top: 4px;
  color: #ff9fb4;
  letter-spacing: 0.08em;
  text-shadow: 2px 2px 0 #000;
}

#wordCount {
  font-size: 12px;
  color: #fff;
  opacity: 0.6;
  margin-top: 2px;
  text-shadow: 2px 2px 0 #000;
}

#quest {
  position: absolute;
  left: 16px;
  top: 14px;
  max-width: 320px;
}
.qtitle {
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--amber);
  margin-bottom: 5px;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7);
}
.qbody { font-size: 15px; line-height: 1.55; text-shadow: 2px 2px 0 rgba(0,0,0,0.7); }
.qbody b {
  color: #fff;
  text-shadow: var(--shadow), 0 0 10px var(--phos);
  letter-spacing: 0.04em;
}
.qbody .sub { display: block; font-size: 12px; color: var(--rose); margin-top: 3px; }

/* ------------------------------------------------------------- overlays */

/*
 * The dirt background. Minecraft's menus are a tiled dirt texture with a black
 * wash over it, and since we already paint that texture for the world it costs
 * one data URL to have the same thing here.
 */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #241a12;
  background-image: linear-gradient(rgba(8, 10, 8, 0.52), rgba(8, 10, 8, 0.60)), var(--dirt);
  background-size: auto, 72px 72px;
  background-repeat: repeat;
  image-rendering: pixelated;
}

.sheet {
  position: relative;
  width: min(900px, 94vw);
  max-height: 88vh;
  overflow: auto;
  padding: 28px 32px 32px;
  background-color: #2e2c29;
  background-image: linear-gradient(rgba(14, 16, 13, 0.76), rgba(14, 16, 13, 0.82)), var(--rock);
  background-size: auto, 56px 56px;
  image-rendering: pixelated;
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.16),
    inset -3px -3px 0 rgba(0, 0, 0, 0.6),
    0 0 0 3px #000,
    0 0 44px rgba(108, 255, 159, 0.10);
}

.sheet h1 {
  margin: 0 0 6px;
  font-size: 44px;
  letter-spacing: 0.14em;
  color: #fff;
  text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.65), 0 0 22px rgba(108, 255, 159, 0.35);
}
.sheet h2 {
  margin: 0 0 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--rose);
  letter-spacing: 0.04em;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7);
}
.sheet p {
  font-size: 14px;
  line-height: 1.75;
  color: #e0ddd6;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
}
.sheet a { color: var(--amber); text-decoration: none; border-bottom: 2px solid rgba(255,216,61,0.4); }
.sheet a:hover { border-bottom-color: var(--amber); }

/* The yellow line that hangs off the corner of the Minecraft logo, rotated and
 * bouncing. It is the most-loved two lines of code in that game. */
/* Pulled out of the flow and pinned to the corner of the sheet. Left inline it
 * rotates down across the subtitle, which is the one line that must stay
 * readable. */
.splash {
  position: absolute;
  right: 44px;
  top: 46px;
  white-space: nowrap;
  color: var(--amber);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.65);
  transform: rotate(-14deg);
  animation: splash 0.9s ease-in-out infinite alternate;
  vertical-align: middle;
}
@keyframes splash { from { transform: rotate(-14deg) scale(1); }
                    to   { transform: rotate(-14deg) scale(1.12); } }

/* -------------------------------------------------------------- buttons */

.btn {
  pointer-events: auto;
  display: inline-block;
  padding: 13px 26px;
  margin: 8px 10px 0 0;
  background: var(--stone);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.07em;
  cursor: pointer;
  border: 0;
  border-radius: 0;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
  box-shadow:
    inset 3px 3px 0 var(--stone-lt),
    inset -3px -3px 0 var(--stone-dk),
    0 0 0 3px #000;
}
.btn:hover { background: var(--stone-on); box-shadow:
    inset 3px 3px 0 #d6e0c8, inset -3px -3px 0 #61704f, 0 0 0 3px #000,
    0 0 0 5px rgba(255, 255, 255, 0.85); }
.btn:active {
  transform: translateY(3px);
  box-shadow: inset 3px 3px 0 var(--stone-dk), inset -3px -3px 0 var(--stone-lt), 0 0 0 3px #000;
}
.btn.amber { background: #c9a227; }
.btn.amber:hover { background: #e0b62c; box-shadow:
    inset 3px 3px 0 #ffe89a, inset -3px -3px 0 #7d6414, 0 0 0 3px #000,
    0 0 0 5px rgba(255, 255, 255, 0.85); }
.btn small { display: block; font-size: 11px; font-weight: 600; color: #fff8dc;
             opacity: 0.85; letter-spacing: 0; margin-top: 2px; }

.keys { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; margin: 18px 0 22px; }
.keys div { font-size: 13px; color: #ded9d0; text-shadow: 2px 2px 0 rgba(0,0,0,0.6); }
.keys kbd {
  display: inline-block;
  min-width: 24px;
  text-align: center;
  padding: 3px 8px;
  margin-right: 10px;
  background: var(--stone);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  box-shadow: inset 2px 2px 0 var(--stone-lt), inset -2px -2px 0 var(--stone-dk), 0 0 0 2px #000;
}

/* ----------------------------------------------------- book / quiz cards */

.wgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.wcard {
  pointer-events: auto;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  background: var(--slot);
  box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.6),
              inset -3px -3px 0 rgba(255, 255, 255, 0.13),
              0 0 0 2px #000;
}
.wcard:hover { background: #2f3a2c; box-shadow: inset 3px 3px 0 rgba(0,0,0,0.5),
              inset -3px -3px 0 rgba(255,255,255,0.18), 0 0 0 2px #000,
              0 0 0 4px rgba(255, 255, 255, 0.8); }
.wcard .ic { font-size: 30px; line-height: 1.15; }
.wcard .ic canvas { image-rendering: pixelated; }
.wcard .en { font-size: 15px; font-weight: 800; letter-spacing: 0.05em; color: #fff;
             text-shadow: 2px 2px 0 rgba(0,0,0,0.6); }
.wcard .ja { font-size: 11px; color: var(--rose); }
.wcard.locked { opacity: 0.28; cursor: default; }
.wcard.locked .en, .wcard.locked .ja { color: #999; }

.cat {
  margin-top: 22px;
  font-size: 11px;
  letter-spacing: 0.26em;
  color: var(--amber);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
}

/* ------------------------------------------------------- spelling tray */

.bigicon { font-size: 92px; text-align: center; line-height: 1; margin: 8px 0 12px; }
.bigicon canvas { image-rendering: pixelated; }

.spell { display: flex; gap: 8px; justify-content: center; margin: 14px 0 20px; flex-wrap: wrap; }
.cell {
  width: 54px;
  height: 64px;
  background: var(--slot);
  box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.65), inset -3px -3px 0 rgba(255, 255, 255, 0.1),
              0 0 0 2px #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 800;
  color: #fff;
}
.cell.full { background: #35502f; text-shadow: 2px 2px 0 rgba(0,0,0,0.5), 0 0 12px var(--phos); }
.cell.space { box-shadow: none; background: none; width: 22px; }

.tiles { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.tile {
  pointer-events: auto;
  width: 54px;
  height: 58px;
  background: var(--stone);
  font: inherit;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  border: 0;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
  box-shadow: inset 3px 3px 0 var(--stone-lt), inset -3px -3px 0 var(--stone-dk), 0 0 0 3px #000;
}
.tile:hover { background: var(--stone-on); }
.tile:active { transform: translateY(3px); }
.tile:disabled { opacity: 0.22; cursor: default; transform: none; }
.tile.wrong { animation: shake 0.28s steps(3, end); background: #a33f3a; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.center { text-align: center; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.say {
  pointer-events: auto;
  background: var(--stone);
  color: #fff;
  border: 0;
  width: 48px;
  height: 48px;
  font-size: 20px;
  cursor: pointer;
  box-shadow: inset 3px 3px 0 var(--stone-lt), inset -3px -3px 0 var(--stone-dk), 0 0 0 3px #000;
}
.say:hover { background: var(--stone-on); }

/* ------------------------------------------------------------- credits */

.credit { text-align: center; padding: 6px 0 4px; }
.credit .for {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--amber);
  margin: 26px 0 6px;
  text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6), 0 0 26px rgba(255, 216, 61, 0.55);
}
.credit .forja { font-size: 14px; color: var(--rose); margin-bottom: 24px;
                 text-shadow: 2px 2px 0 rgba(0,0,0,0.6); }
.credit .by { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: 0.08em;
              text-shadow: var(--shadow); }
.credit .role { font-size: 12px; letter-spacing: 0.22em; color: var(--amber); margin-bottom: 6px; }
.credit .small { font-size: 12px; opacity: 0.6; line-height: 1.9; margin-top: 20px; }

/* A soft darkening at the edge, so the DOM sits in the same room as the CRT. */
#hud::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.5);
}

/* ============================================================== touch =====
 *
 * The on-screen controls, which only exist on a device that reports touch.
 *
 * Everything here is bigger than a desktop designer would draw it. The target
 * is an eight-year-old's finger on an iPad held in two hands, and a control she
 * misses is a control she stops using — so the buttons are 76px, the thumb
 * stick is floating rather than fixed, and the two clusters sit inside the
 * bottom corners where thumbs already rest.
 */

body.touch {
  /* No rubber-banding, no pull-to-refresh, no text selection on a long press. */
  overscroll-behavior: none;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* The sheets are the one thing that must still scroll under a finger. */
.sheet { touch-action: pan-y; }

.touchui {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;   /* only the controls themselves take touches */
}

/* ---- the floating stick ---- */

.tstick {
  position: absolute;
  width: 132px;
  height: 132px;
  margin: -66px 0 0 -66px;
  border-radius: 50%;
  background: rgba(10, 14, 12, 0.30);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.28);
  pointer-events: none;
}
.tknob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(230, 255, 240, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.45), 0 0 18px rgba(108, 255, 159, 0.5);
  transform: translate(-26px, -26px);
}

/* ---- the action cluster, bottom right ---- */

.tpad {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 10px;
  justify-items: center;
}

.tbtn {
  pointer-events: auto;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #fff;
  background: rgba(20, 24, 22, 0.55);
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.20),
              inset -3px -3px 0 rgba(0, 0, 0, 0.45),
              0 0 0 3px #000;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
  user-select: none;
}
.tbtn.on {
  background: rgba(108, 255, 159, 0.35);
  box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.4),
              inset -3px -3px 0 rgba(255, 255, 255, 0.2),
              0 0 0 3px #000;
}

/* Breaking is the verb this game is about, so it is the big one. */
.tbtn.dig {
  grid-column: 3;
  grid-row: 2 / span 2;
  height: 162px;   /* two rows plus the gap between them */
  font-size: 40px;
  background: rgba(90, 60, 30, 0.6);
}
.tbtn.put  { grid-column: 3; grid-row: 1; }
.tbtn.jump { grid-column: 2; grid-row: 3; font-size: 26px; }
.tbtn.down { grid-column: 1; grid-row: 3; font-size: 26px; }
.tbtn.use  { grid-column: 2; grid-row: 2; font-weight: 800; font-size: 26px; }
.tbtn.say  { grid-column: 1; grid-row: 2; font-size: 26px; }
.tbtn.fly  { grid-column: 1; grid-row: 1; font-size: 26px; }

/* ---- menu and book, top left, away from the thumbs ---- */

.tcorner {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
}
.tcorner .tbtn { width: 62px; height: 62px; font-size: 24px; }

/* ---- the rest of the HUD, rearranged for a tablet ---- */

body.touch #hotbar {
  bottom: auto;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
}
body.touch .slot { width: 54px; height: 54px; }
body.touch .slot canvas { width: 34px; height: 34px; }

/* The quest line would sit under the hotbar; move it down. */
body.touch #quest { top: 92px; }
body.touch #topright { top: 92px; }

/* The word flash sits higher, clear of both thumbs. */
body.touch #flash { top: 40%; }

/* The look label must not land under the action pad. */
body.touch #look { top: calc(50% + 30px); }

/* No hover states on a touch screen — they stick after a tap. */
body.touch .btn:hover { background: var(--stone); box-shadow:
    inset 3px 3px 0 var(--stone-lt), inset -3px -3px 0 var(--stone-dk), 0 0 0 3px #000; }
body.touch .btn.amber:hover { background: #c9a227; }
body.touch .btn { padding: 16px 28px; font-size: 17px; }
body.touch .wcard { padding: 14px 8px; }

/* ------------------------------------------------- small screens, upright ==
 *
 * A phone held in portrait is the hardest case this HUD faces: the play area is
 * a tall slot, the thumbs cover the bottom corners, and there is no width to
 * spare. Everything below shrinks the furniture and moves it out of the two
 * places a thumb naturally rests.
 *
 * The game is much better in landscape and says so once, quietly — but it has
 * to be properly playable upright, because a child will pick the phone up
 * whichever way round it already is.
 */

@media (max-width: 820px) {
  body.touch .tbtn { width: 62px; height: 62px; font-size: 24px; }
  body.touch .tbtn.dig { height: 134px; font-size: 32px; }
  body.touch .tpad { gap: 8px; }
  body.touch .tcorner .tbtn { width: 52px; height: 52px; font-size: 20px; }
  body.touch .slot { width: 48px; height: 48px; }
  body.touch .slot canvas { width: 30px; height: 30px; }
  body.touch .slot .lab { font-size: 8px; max-width: 46px; }
}

@media (max-width: 560px), (orientation: portrait) and (max-width: 900px) {
  /* The stick lives in the lower-left, so the menu and book move to the top,
   * under the hotbar, where nothing else wants to be. */
  body.touch .tcorner {
    bottom: auto;
    top: max(76px, calc(env(safe-area-inset-top) + 74px));
    left: max(10px, env(safe-area-inset-left));
    flex-direction: column;
  }
  body.touch .tcorner .tbtn { width: 48px; height: 48px; font-size: 19px; }

  body.touch .tbtn { width: 56px; height: 56px; font-size: 22px; }
  body.touch .tbtn.dig { height: 120px; font-size: 30px; }
  body.touch .tpad { gap: 7px; right: max(10px, env(safe-area-inset-right)); }

  body.touch #hotbar { padding: 3px; }
  body.touch .slot { width: 42px; height: 42px; }
  body.touch .slot canvas { width: 26px; height: 26px; }
  body.touch .slot .lab { font-size: 7px; max-width: 40px; letter-spacing: 0; }
  body.touch .slot .key { font-size: 8px; }

  /* The word is the point of the game, so it keeps its size for as long as it
   * can — but it must not run off a 360-pixel screen. */
  .fl-en { font-size: clamp(34px, 13vw, 74px); }
  .fl-ja { font-size: clamp(20px, 7vw, 40px); }
  .fl-s  { font-size: clamp(12px, 3.6vw, 18px); }

  #look .en { font-size: 24px; }
  #look .ja { font-size: 18px; }
  #look .hint { display: none; }
  body.touch #look { top: calc(50% + 18px); }

  #quest { max-width: 58vw; font-size: 13px; padding: 7px 11px; }
  .qbody { font-size: 13px; }
  #topright { top: max(72px, calc(env(safe-area-inset-top) + 70px)); }
  #stars { font-size: 17px; }

  .sheet { padding: 18px 16px 22px; width: 96vw; }
  .sheet h1 { font-size: 27px; letter-spacing: 0.08em; }
  .sheet h2 { font-size: 13px; }
  .btn { padding: 13px 18px; font-size: 15px; }
  .wgrid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .cell { width: 42px; height: 52px; font-size: 24px; }
  .tile { width: 44px; height: 48px; font-size: 22px; }
}

/* The hint to turn the phone round. Shown once, briefly, never blocking. */
#rotate {
  position: fixed;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  z-index: 45;
  display: none;
  padding: 12px 20px;
  text-align: center;
  background: rgba(8, 10, 9, 0.9);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.14),
              inset -2px -2px 0 rgba(0, 0, 0, 0.55), 0 0 0 3px #000;
  pointer-events: none;
  animation: pop 0.3s ease;
}
#rotate .a { font-size: 30px; }
#rotate .b { font-size: 15px; font-weight: 800; color: #fff; letter-spacing: 0.06em; }
#rotate .c { font-size: 13px; color: var(--rose); }
body.show-rotate #rotate { display: block; }
