:root {
  --bg: #efe8da;
  --ink: #2a2d3a;
  --ink-soft: #5d6070;
  --panel: #f8f4ea;
  --edge: #2a2d3a;
  --accent: #d4574e;
  --accent-2: #e5b94e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Pixelify Sans', monospace;
}

#stage { position: fixed; inset: 0; display: grid; place-items: center; }
canvas.game { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }

#hud[hidden], #menu[hidden], #menu [hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: 1px; }
.sub { margin: 0; color: var(--ink-soft); }
label { display: flex; flex-direction: column; gap: 6px; }
input, button { font: inherit; font-size: 18px; border: 3px solid var(--edge); padding: 8px 10px; background: #fff; color: var(--ink); border-radius: 6px; }
input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent-2); }
button { background: var(--accent); color: #fff7ea; cursor: pointer; box-shadow: 0 4px 0 var(--edge); transition: transform 80ms, box-shadow 80ms, background 120ms; }
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 0 var(--edge); }
button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
button:disabled { cursor: not-allowed; background: #b9ad95; color: #f3ecdd; }
button:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
.join { display: flex; gap: 8px; }
.join input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 3px; }
#err { margin: 0; color: var(--accent); min-height: 1.2em; font-weight: 600; }
#roomcode { color: var(--accent); letter-spacing: 3px; }

/* ---------- main menu ----------
   Left column (brand, profile, modes) over a live CPU rally; the chosen
   mode opens a sheet in the second column. */
#menu {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 410px) 1fr;
  gap: 28px;
  align-items: center;
  padding: 32px 48px;
  overflow-y: auto;
}
#menu .scrim {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(239, 232, 218, 0.94) 0, rgba(239, 232, 218, 0.8) 26%, rgba(239, 232, 218, 0.3) 48%, transparent 64%),
    radial-gradient(ellipse at 70% 50%, transparent 55%, rgba(42, 45, 58, 0.16));
}
#menu .col { display: flex; flex-direction: column; gap: 18px; }

.logo {
  font-size: 30px;
  line-height: 1;
  color: var(--accent);
  letter-spacing: 8px;
  text-transform: uppercase;
  text-shadow: 0 3px 0 var(--edge);
}
.logo span {
  position: relative;
  display: block;
  margin-top: 6px;
  font-size: 84px;
  line-height: 0.95;
  letter-spacing: 2px;
  color: #fff7ea;
  text-shadow:
    3px 0 0 var(--edge), -3px 0 0 var(--edge), 0 3px 0 var(--edge), 0 -3px 0 var(--edge),
    3px 3px 0 var(--edge), -3px 3px 0 var(--edge), 3px -3px 0 var(--edge), -3px -3px 0 var(--edge),
    0 9px 0 var(--edge);
}
/* a pixel ball hopping on the logo */
.logo span::after {
  content: '';
  position: absolute;
  top: -4px;
  margin-left: 8px;
  width: 18px;
  height: 18px;
  background: #e8f06a;
  border: 3px solid var(--edge);
  box-shadow: inset -4px -4px 0 #b9c43a;
  animation: hop 1.1s cubic-bezier(0.3, 0, 0.7, 1) infinite;
}
@keyframes hop { 0%, 100% { transform: translateY(26px); } 50% { transform: translateY(-14px); } }

.card {
  background: var(--panel);
  border: 3px solid #2c2825;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #fffaf0, 0 5px 0 #2c2825, 0 14px 22px rgba(40, 32, 26, 0.2);
}
.profile { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border: 3px solid var(--edge);
  border-radius: 6px;
  background:
    linear-gradient(#2a2d3a 0 0) 10px 17px / 4px 4px no-repeat,
    linear-gradient(#2a2d3a 0 0) 24px 17px / 4px 4px no-repeat,
    linear-gradient(#f2e6d8 0 0) 0 0 / 100% 10px no-repeat,
    linear-gradient(#d4574e 0 0) 0 29px / 100% 100% no-repeat,
    #e9b48f;
}
.who { flex: 1; gap: 2px; min-width: 0; }
.who small { font-size: 12px; color: var(--ink-soft); letter-spacing: 1px; text-transform: uppercase; }
.who input { border: 0; border-bottom: 2px dashed #c9bda6; border-radius: 0; padding: 0; background: transparent; font-size: 22px; font-weight: 600; }
.who input:focus { box-shadow: none; border-bottom-color: var(--accent-2); }
.rank-chip { flex: none; display: grid; place-items: center; }

.modes { display: flex; flex-direction: column; gap: 12px; }
.mode {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 10px 10px;
  text-align: left;
  color: var(--ink);
  background: var(--panel);
  border: 3px solid #2c2825;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #fffaf0, 0 5px 0 #2c2825;
}
.mode:hover:not(:disabled) { transform: translateX(4px); box-shadow: inset 0 0 0 2px #fffaf0, 0 5px 0 #2c2825; }
.mode.on, .mode.on:hover { background: #fff1c2; transform: translateX(10px); }
.mode .ico {
  display: grid;
  place-items: center;
  flex: none;
  width: 52px;
  height: 52px;
  border: 3px solid #2c2825;
  border-radius: 7px;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.18), inset 0 3px 0 rgba(255, 255, 255, 0.3);
}
.mode .ico svg { width: 32px; height: 32px; shape-rendering: crispEdges; fill: #fff7ea; }
.mode .ico .hole { fill: rgba(42, 45, 58, 0.45); }
.mode.play .ico { background: var(--accent); }
.mode.practice .ico { background: #6fa35a; }
.mode.ranked .ico { background: var(--accent-2); }
.mode .txt { flex: 1; display: flex; flex-direction: column; }
.mode b { font-size: 30px; line-height: 1; letter-spacing: 1px; }
.mode small { margin-top: 3px; font-size: 14px; color: var(--ink-soft); }
.mode .go { font-size: 22px; color: #b9ad95; transition: color 120ms, transform 120ms; }
.mode:hover .go, .mode.on .go { color: var(--ink); transform: translateX(3px); }

/* sound: a mute toggle and four volume bars */
.sound { display: flex; align-items: center; gap: 10px; }
.sound small { font-size: 12px; color: var(--ink-soft); letter-spacing: 1px; text-transform: uppercase; }
.sound .spk { padding: 4px 6px; background: var(--panel); color: var(--ink); box-shadow: 0 3px 0 var(--edge); }
.sound svg { display: block; width: 20px; height: 20px; fill: currentColor; }
.sound .off, .sound.muted .on { display: none; }
.sound.muted .off { display: inline; }
.sound .bars { display: flex; align-items: flex-end; gap: 5px; height: 24px; }
.sound .bars button { width: 12px; padding: 0; border-width: 2px; border-radius: 2px; background: var(--panel); box-shadow: 0 2px 0 var(--edge); }
.sound .bars button:nth-child(1) { height: 9px; }
.sound .bars button:nth-child(2) { height: 14px; }
.sound .bars button:nth-child(3) { height: 19px; }
.sound .bars button:nth-child(4) { height: 24px; }
.sound .bars button.lit { background: var(--accent-2); }

/* sheet for the chosen mode */
#sheet, #waiting { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px 20px; animation: sheet-in 180ms ease-out; }
@keyframes sheet-in { from { opacity: 0; transform: translateX(-14px); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 26px; letter-spacing: 3px; text-transform: uppercase; }
.x { padding: 2px 9px; font-size: 16px; background: var(--panel); color: var(--ink); box-shadow: 0 3px 0 var(--edge); }
.pane { display: flex; flex-direction: column; gap: 12px; }
.big { display: flex; flex-direction: column; align-items: center; padding: 12px; font-size: 24px; font-weight: 600; line-height: 1; }
.big small { margin-top: 4px; font-size: 13px; font-weight: 400; opacity: 0.8; }
.alt { background: var(--panel); color: var(--ink); }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 14px; }
.or::before, .or::after { content: ''; flex: 1; border-top: 2px dashed #c9bda6; }

.pick { border: 0; margin: 0; padding: 0; display: flex; gap: 8px; min-width: 0; }
.pick legend { margin-bottom: 6px; padding: 0; font-size: 13px; color: var(--ink-soft); letter-spacing: 1px; text-transform: uppercase; }
.pick label { flex: 1; min-width: 0; cursor: pointer; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border: 3px solid var(--edge);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 4px 0 var(--edge);
  font-size: 17px;
  transition: transform 80ms, box-shadow 80ms, background 120ms;
}
.pick span:hover { background: #fffaf0; }
.pick input:checked + span { background: #fff1c2; transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.pick input:focus-visible + span { outline: 3px solid var(--accent-2); outline-offset: 2px; }
/* courts: three swatch tiles */
.pick.maps { display: grid; grid-template-columns: repeat(6, 1fr); }
.pick.maps legend { grid-column: 1 / -1; }
.pick.maps label { grid-column: span 2; }
.pick.maps label:nth-of-type(n + 4) { grid-column: span 3; }
.pick.maps span { flex-direction: column; gap: 2px; padding: 6px 6px 8px; text-align: center; }
.pick.maps b { font-size: 15px; white-space: nowrap; }
.pick.maps small { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.pick.skies { display: grid; grid-template-columns: repeat(3, 1fr); }
.pick.skies legend { grid-column: 1 / -1; }
.pick.skies span { justify-content: center; padding: 6px 4px; font-size: 14px; }
.sw { display: block; width: 100%; height: 34px; margin-bottom: 4px; border: 2px solid var(--edge); border-radius: 4px; }
.sw.park { background: linear-gradient(90deg, transparent 48%, #fff 48% 52%, transparent 52%), #5a8aa8; box-shadow: inset 0 0 0 5px #5e8d6f; }
.sw.clay { background: linear-gradient(90deg, transparent 48%, #fff 48% 52%, transparent 52%), #c8683f; box-shadow: inset 0 0 0 5px #a9512f; }
.sw.grass { background: linear-gradient(90deg, transparent 48%, #fff 48% 52%, transparent 52%), repeating-linear-gradient(90deg, #78a85a 0 8px, #6c9c50 8px 16px); box-shadow: inset 0 0 0 5px #5f8c48; }
.sw.city {
  background:
    linear-gradient(90deg, transparent 48%, #fff 48% 52%, transparent 52%),
    radial-gradient(circle at 18% 30%, #ffe9a8 0 2px, transparent 3px), radial-gradient(circle at 82% 30%, #ffe9a8 0 2px, transparent 3px),
    #3f5f8f;
  box-shadow: inset 0 0 0 5px #4a4652;
}
.sw.roof {
  background:
    linear-gradient(90deg, transparent 48%, #fff 48% 52%, transparent 52%),
    linear-gradient(transparent 70%, rgba(255, 255, 255, 0.25) 70% 74%, transparent 74%),
    #2f7d84;
  box-shadow: inset 0 0 0 5px #8a95a3;
}
/* difficulty pips */
.pips { width: 4px; height: 10px; margin-right: 12px; background: var(--accent); box-shadow: 6px 0 0 #d8ccb4, 12px 0 0 #d8ccb4; }
.pips[data-n="2"] { box-shadow: 6px 0 0 var(--accent), 12px 0 0 #d8ccb4; }
.pips[data-n="3"] { box-shadow: 6px 0 0 var(--accent), 12px 0 0 var(--accent); }

/* ranked */
.me-rank { display: flex; align-items: center; gap: 12px; padding: 10px; background: #efe6d4; border: 2px solid #d8ccb4; border-radius: 8px; }
.me-rank .rank-ico { flex: none; display: grid; place-items: center; }
.me-rank div { display: flex; flex-direction: column; gap: 3px; }
.me-rank b { font-size: 20px; }
.me-rank small { font-size: 13px; color: var(--ink-soft); }
.pbar { display: flex; gap: 4px; margin-top: 3px; }
.pbar i { width: 22px; height: 8px; background: #d8ccb4; border: 2px solid #b9ad95; border-radius: 2px; }
.season { margin: 2px 0 -4px; font-size: 13px; color: var(--ink-soft); letter-spacing: 1px; text-transform: uppercase; }
.ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 4px; }
.ladder li { flex: 0 0 calc(25% - 3px); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 8px; transition: transform 120ms, background 120ms; }
.ladder li:hover { background: #fff1c2; transform: translateY(-3px); }
.ladder .rank-ico { display: grid; place-items: center; height: 64px; }
.ladder b { font-size: 14px; white-space: nowrap; }
.ladder small { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.rank-ico canvas, .rank-chip canvas { display: block; image-rendering: pixelated; }

/* waiting / matchmaking */
.searching { display: flex; align-items: center; gap: 12px; }
.bob { width: 16px; height: 16px; background: #e8f06a; border: 3px solid var(--edge); box-shadow: inset -3px -3px 0 #b9c43a; animation: hop 0.8s cubic-bezier(0.3, 0, 0.7, 1) infinite; }
#waiting h2 { font-size: 26px; }
#waiting p { margin: 0; }
#waiting.quick .room-only { display: none; }

@media (max-width: 860px) {
  #menu { grid-template-columns: minmax(0, 420px); justify-content: center; align-items: start; padding: 24px 16px; }
  #menu .scrim { background: rgba(239, 232, 218, 0.78); }
  #sheet, #waiting { grid-area: 1 / 1; }
  #menu.open .col { visibility: hidden; }
  .logo span { font-size: 64px; }
}

/* ---------- scoreboard ----------
   A framed board drawn on faint graph paper; the guide lines run past
   the frame like a technical drawing. */
.blueprint::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(42, 45, 58, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 45, 58, 0.07) 1px, transparent 1px);
  background-size: 10px 10px;
  -webkit-mask-image: radial-gradient(closest-side, #000 72%, transparent);
          mask-image: radial-gradient(closest-side, #000 72%, transparent);
}
#score {
  position: fixed;
  top: 6px;
  left: 6px;
  padding: 18px;
  isolation: isolate;
}
.hudbox .board {
  position: relative;
  min-width: 250px;
  padding: 6px;
  background: #4b4540;
  border: 3px solid #2c2825;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #6a625a, 0 5px 0 #2c2825, 0 10px 14px rgba(40, 32, 26, 0.22);
}
.hudbox .board::before,
.hudbox .board::after {
  content: '';
  position: absolute;
  pointer-events: none;
  border: 0 solid rgba(42, 45, 58, 0.22);
}
.hudbox .board::before { left: -16px; right: -16px; top: 8px; bottom: 8px; border-width: 1px 0; }
.hudbox .board::after { top: -16px; bottom: -16px; left: 8px; right: 8px; border-width: 0 1px; }
.hudbox .sb-head { display: grid; grid-template-columns: 1fr 34px 34px; gap: 4px; margin-bottom: 6px; }
.hudbox .sb-head > span {
  display: grid;
  place-items: center;
  height: 30px;
  background: #5c544c;
  border: 2px solid #2c2825;
  border-radius: 5px;
  box-shadow: inset 0 2px 0 #776d63;
}
.hudbox .title {
  justify-content: start !important;
  padding-left: 12px;
  color: #efe6d4;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 2px 0 #2c2825;
}
.hudbox .star svg { width: 19px; height: 19px; fill: #2f2b28; stroke: #2c2825; stroke-width: 1.2; }
.hudbox .star.on svg { fill: #f1c54a; }
.hudbox .sb-body {
  background: #f8f2e4;
  border: 2px solid #2c2825;
  border-radius: 5px;
  box-shadow: inset 0 2px 0 #fffaf0;
}
#score .row {
  display: grid;
  grid-template-columns: 16px 1fr 34px 38px;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 21px;
}
#score .row + .row { border-top: 2px solid #ddd3bf; }
#score .dot { width: 12px; height: 12px; border: 2px solid #2c2825; background: transparent; }
#score .row.serving .dot { background: #c9a43c; }
#score .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#score .name small { font-size: 13px; color: var(--ink-soft); }
#score .games { text-align: center; color: var(--ink-soft); }
#score .pts { text-align: right; font-weight: 600; }

#msg {
  position: fixed;
  top: 28%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 44px;
  font-weight: 600;
  color: #fff7ea;
  text-shadow: 3px 3px 0 var(--edge), -3px 3px 0 var(--edge), 3px -3px 0 var(--edge), -3px -3px 0 var(--edge);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
#msg.show { opacity: 1; }

/* shot feedback: floats up from the strings and fades */
#pop {
  position: fixed;
  font-size: 17px;
  font-weight: 600;
  color: #fff7ea;
  text-shadow: 2px 2px 0 var(--edge), -2px 2px 0 var(--edge), 2px -2px 0 var(--edge), -2px -2px 0 var(--edge);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -100%);
}
#pop.show { animation: pop 0.95s ease-out forwards; }
#pop.perfect { color: #ffe27a; }
#pop.late, #pop.early, #pop.jammed, #pop.stretched, #pop.low, #pop.high { color: #ffb7a6; }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, -70%) scale(0.7); }
  14% { opacity: 1; transform: translate(-50%, -100%) scale(1.1); }
  70% { opacity: 1; transform: translate(-50%, -150%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}

/* ---------- power meter ---------- */
/* network readout: a ping chip under the score, and the details under it (F3) */
#net { display: grid; justify-items: start; gap: 4px; margin-top: 8px; }
#net .chip {
  --q: #8fd16f;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px 0 6px;
  font-size: 13px;
  line-height: 1;
  color: #efe6d4;
  background: #4b4540;
  border: 2px solid #2c2825;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 #6a625a, 0 2px 0 #2c2825;
  cursor: pointer;
}
#net .chip[data-q="3"] { --q: #d3d36a; }
#net .chip[data-q="2"] { --q: #e5b94e; }
#net .chip[data-q="1"] { --q: #e0675c; }
#net .chip:focus-visible { box-shadow: inset 0 1px 0 #6a625a, 0 0 0 2px var(--accent-2); }
#net .bars { display: inline-flex; align-items: flex-end; gap: 1px; height: 9px; }
#net .bars b { width: 2px; background: #6a625a; }
#net .bars b:nth-child(1) { height: 3px; }
#net .bars b:nth-child(2) { height: 5px; }
#net .bars b:nth-child(3) { height: 7px; }
#net .bars b:nth-child(4) { height: 9px; }
#net .chip[data-q="1"] b:nth-child(-n + 1),
#net .chip[data-q="2"] b:nth-child(-n + 2),
#net .chip[data-q="3"] b:nth-child(-n + 3),
#net .chip[data-q="4"] b { background: var(--q); }
#net .ms { min-width: 3.4em; font-variant-numeric: tabular-nums; }
#net .dbg {
  display: grid;
  grid-template-columns: auto auto;
  gap: 1px 12px;
  margin: 0;
  padding: 5px 8px 6px;
  font: 11px/1.3 ui-monospace, Consolas, monospace;
  color: #efe6d4;
  background: rgba(43, 39, 36, 0.84);
  border: 2px solid #2c2825;
  border-radius: 6px;
  pointer-events: none;
}
#net.closed .dbg { display: none; }
#net .dbg dt { color: #a99d8e; }
#net .dbg dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#net .dbg .sec { grid-column: 1 / -1; margin-top: 4px; color: #e5b94e; letter-spacing: 1px; }
#net .dbg .sec:first-child { margin-top: 0; }

#power {
  position: fixed;
  left: 6px;
  bottom: 6px;
  padding: 18px;
  isolation: isolate;
  opacity: 0.6;
  transition: opacity 120ms;
}
#power.live { opacity: 1; }
#power .board { min-width: 0; width: 250px; }
#power .sb-head { grid-template-columns: 1fr auto; }
#power .pk {
  padding: 0 10px;
  color: #efe6d4;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}
#power .sb-body { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
#power .gauge {
  position: relative;
  flex: 1;
  height: 20px;
  background: #e6dcc8;
  border: 2px solid #2c2825;
  border-radius: 3px;
  overflow: hidden;
}
#power .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--fill, 0) * 100%);
  background: linear-gradient(90deg, #7fbf5f 0, #b9cf55 45%, #f1c54a 70%, #e07a4f 85%, #d4574e 100%);
  background-size: 186px 100%;
}
/* pixel segments over the fill */
#power .gauge::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 12px, #e6dcc8 12px 14px);
}
/* risk zone: the last 20% sprays more when mistimed */
#power .risk {
  position: absolute;
  inset: 0 0 0 80%;
  border-left: 2px dashed #2c2825;
  background: repeating-linear-gradient(-45deg, rgba(212, 87, 78, 0.18) 0 3px, transparent 3px 6px);
  z-index: 1;
}
#power .pv { width: 44px; text-align: right; font-size: 18px; font-weight: 600; }
#power.risky .pv { color: var(--accent); }

/* ---------- prompt: what the next click does ----------
   A small dark board under the court: the step that's live glows, the one after it waits. */
#hint {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  animation: hint-in 220ms cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 10px); } }
#hint[hidden] { display: none; }
#hint .flag {
  padding: 2px 10px 3px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff7ea;
  background: var(--accent);
  border: 2px solid #2c2825;
  border-radius: 4px;
  box-shadow: 0 3px 0 #2c2825;
}
#hint .flag:empty { display: none; }
#hint .flag.win { background: #6fa35a; }
#hint .board {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  background: #4b4540;
  border: 3px solid #2c2825;
  border-radius: 9px;
  box-shadow: inset 0 0 0 2px #6a625a, 0 5px 0 #2c2825, 0 10px 16px rgba(40, 32, 26, 0.25);
}
#hint .step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 6px 9px;
  font-size: 17px;
  color: #b3a898;
  background: #5c544c;
  border: 2px solid #2c2825;
  border-radius: 5px;
  box-shadow: inset 0 2px 0 #776d63;
  white-space: nowrap;
  transition: background 120ms, color 120ms;
}
#hint .step[hidden] { display: none; }
#hint .step.on { color: #2c2825; background: #f1c54a; box-shadow: inset 0 2px 0 #fbe39a, inset 0 -3px 0 #c9a43c; }
#hint .link { width: 14px; height: 4px; background: repeating-linear-gradient(90deg, #8a8076 0 2px, transparent 2px 4px); }
#hint .link[hidden] { display: none; }
#hint .ms { width: 13px; height: 18px; shape-rendering: crispEdges; }
#hint .ms .body { fill: #efe6d4; }
#hint .ms .lb { fill: #8a8076; }
#hint .step.on .ms .body { fill: #fff7ea; }
#hint .step.on .ms .lb { fill: var(--accent); animation: click 0.9s steps(1) infinite; }
@keyframes click { 50% { fill: #2c2825; } }

/* ---------- controls diagram ---------- */
#controls {
  position: fixed;
  right: 8px;
  bottom: 8px;
  width: 360px;
  height: auto;
  overflow: visible;
  pointer-events: none;
  user-select: none;
  font-family: 'Pixelify Sans', monospace;
}
#controls .gridline { fill: none; stroke: #2a2d3a; stroke-opacity: 0.08; }
#controls .guide { fill: none; stroke: #2a2d3a; stroke-opacity: 0.16; stroke-dasharray: 2 3; }
#controls text { fill: var(--ink); font-size: 11px; }
#controls text.h { font-size: 10px; letter-spacing: 1.5px; text-anchor: middle; fill: var(--ink-soft); }
#controls text.lbl { font-size: 13px; font-weight: 600; }
#controls text.sub { font-size: 10px; fill: var(--ink-soft); }
#controls text.end { text-anchor: end; }
#controls .mouse { fill: #f8f2e4; stroke: var(--ink); stroke-width: 2; }
#controls .btn { stroke: var(--ink); stroke-width: 1.4; transition: fill 60ms; }
#controls .btn.l { fill: #e3897c; }
#controls .btn.r { fill: #f8f2e4; }
#controls .btn.down { fill: var(--accent-2); }
#controls .seam { fill: none; stroke: var(--ink); stroke-width: 1.4; }
#controls .wheel { fill: var(--ink); }
#controls .wheel.down { fill: var(--accent); }
#controls .lead { fill: none; stroke: var(--ink); stroke-width: 1; }
#controls .pin { fill: var(--ink); }
#controls .key text { text-anchor: middle; font-size: 11px; font-weight: 600; }
#controls .key .cap { fill: #fffaf0; stroke: var(--ink); stroke-width: 1.5; transition: transform 60ms; }
#controls .key .side { fill: #b9ad95; stroke: var(--ink); stroke-width: 1.5; }
#controls .key text { transition: transform 60ms; }
#controls .key.gold .cap { fill: #f1c54a; }
#controls .key.down .cap, #controls .key.down text { transform: translateY(2px); }
#controls .key.down .cap { fill: #fff1c2; }

@media (max-width: 760px) {
  #controls { width: 250px; }
  #score { transform: scale(0.8); transform-origin: top left; }
  #power { transform: scale(0.8); transform-origin: bottom left; }
}




@media (max-width: 600px) {
  #msg { font-size: 30px; }
}
