:root {
  color-scheme: dark;
  --ink: #e8e9e4;
  --muted: #a4adb1;
  --faint: #63747b;
  --cyan: #8fe5dc;
  --amber: #ffc277;
  --danger: #ff806c;
  --panel: rgba(8, 17, 25, .94);
  --line: rgba(185, 214, 211, .18);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #081119;
  color: var(--ink);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #081119;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body { position: fixed; inset: 0; }

#game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse at 50% 48%, rgba(41, 67, 73, .22), transparent 48%),
    linear-gradient(155deg, #0b1720, #081119 72%);
}

#scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.brand-mark, .desktop-hint, .corner-note {
  position: absolute;
  z-index: 2;
  color: rgba(207, 221, 218, .57);
  font: 500 10px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .12em;
  pointer-events: none;
}

.brand-mark {
  top: max(22px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  display: flex;
  gap: 10px;
  align-items: center;
}

.brand-mark b { color: var(--cyan); font-weight: 600; }
.brand-symbol { color: var(--cyan); font-size: 21px; line-height: .6; transform: rotate(-17deg); }

.desktop-hint {
  top: max(24px, env(safe-area-inset-top));
  right: max(24px, env(safe-area-inset-right));
  display: flex;
  gap: 5px;
  align-items: center;
  letter-spacing: .04em;
}

kbd {
  min-width: 18px;
  padding: 3px 4px 2px;
  border: 1px solid rgba(174, 208, 203, .2);
  border-radius: 4px;
  color: #d6e1de;
  background: rgba(179, 215, 211, .07);
  text-align: center;
  font: inherit;
  font-size: 9px;
}

.desktop-hint span { margin-left: 2px; color: rgba(207, 221, 218, .46); }
.desktop-hint i { width: 1px; height: 14px; margin: 0 7px; background: rgba(174, 208, 203, .18); }

.corner-note {
  right: max(24px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  color: rgba(207, 221, 218, .35);
}

.corner-note span { color: var(--amber); padding: 0 4px; }

.screen-card {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  width: min(490px, calc(100vw - 36px));
  padding: clamp(23px, 5vw, 38px);
  transform: translate(-50%, -50%);
  border: 1px solid rgba(161, 212, 207, .22);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(17, 34, 42, .98), rgba(8, 18, 26, .98) 64%),
    var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .56), inset 0 1px 0 rgba(227, 250, 244, .07);
  backdrop-filter: blur(18px);
}

.screen-card::before, .screen-card::after {
  position: absolute;
  width: 16px;
  height: 16px;
  content: '';
  border-color: rgba(143, 229, 220, .6);
}

.screen-card::before { top: -1px; left: 18px; border-top: 2px solid; }
.screen-card::after { right: 18px; bottom: -1px; border-bottom: 2px solid; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #8faaa9;
  font: 500 10px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .15em;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(143, 229, 220, .75);
}

h1, h2 {
  margin: 21px 0 0;
  color: #f0f1eb;
  font-size: clamp(34px, 8vw, 53px);
  font-weight: 800;
  letter-spacing: .085em;
  line-height: .98;
}

h2 { font-size: clamp(25px, 6vw, 38px); line-height: 1.08; }
.subtitle { margin: 10px 0 0; color: #a9c4c0; font-size: 14px; letter-spacing: .08em; }
.rule { height: 1px; margin: 23px 0 19px; background: linear-gradient(90deg, rgba(143, 229, 220, .55), rgba(143, 229, 220, .02)); }
.pitch { margin: 0; color: #d3dbd7; font-size: clamp(14px, 3.5vw, 16px); line-height: 1.7; }
.objective-line { display: flex; align-items: center; gap: 8px; margin: 17px 0 0; color: #a9b8b6; font-size: 12px; line-height: 1.5; }
.objective-line b { color: #e2d9c5; font-weight: 700; }
.objective-icon { color: var(--amber); font-size: 18px; }

.primary-button {
  display: flex;
  width: 100%;
  min-height: 52px;
  margin-top: 25px;
  padding: 0 18px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(143, 229, 220, .62);
  border-radius: 9px;
  color: #071417;
  background: linear-gradient(110deg, #9debe0, #73c9c0);
  box-shadow: 0 9px 24px rgba(74, 193, 179, .12), inset 0 1px 0 rgba(255,255,255,.5);
  cursor: pointer;
  font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .12em;
  transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
  touch-action: manipulation;
}

.primary-button:hover { transform: translateY(-1px); filter: brightness(1.07); box-shadow: 0 12px 30px rgba(74, 193, 179, .2); }
.primary-button:active { transform: translateY(1px) scale(.995); }
.primary-button span { font-size: 18px; font-weight: 500; }
.microcopy { margin: 14px 0 0; color: #75878b; font: 400 9px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; text-align: center; }

.result-card { text-align: left; }
.result-card p:not(.microcopy) { margin: 15px 0 0; color: #c0cbc7; font-size: 14px; line-height: 1.6; }
.result-card[data-result="fail"] .eyebrow-dot { background: var(--danger); box-shadow: 0 0 12px rgba(255,128,108,.7); }
.result-card[data-result="fail"] h2 { color: #ffd0c7; }

.touch-controls { display: none; }
.touch-controls.active { display: block; }

.move-zone {
  position: absolute;
  z-index: 3;
  left: max(17px, env(safe-area-inset-left));
  bottom: max(21px, env(safe-area-inset-bottom));
  width: clamp(116px, 31vw, 150px);
  height: clamp(116px, 31vw, 150px);
  display: grid;
  place-items: center;
  touch-action: none;
}

.move-ring {
  position: absolute;
  width: 76%;
  height: 76%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(162, 218, 211, .34);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(101, 157, 153, .17), rgba(14, 30, 36, .45));
  box-shadow: inset 0 0 24px rgba(101, 157, 153, .09), 0 8px 28px rgba(0,0,0,.24);
}

.move-ring::before, .move-ring::after { position: absolute; content: ''; background: rgba(173, 219, 212, .18); }
.move-ring::before { width: 1px; height: 100%; }
.move-ring::after { width: 100%; height: 1px; }

.move-knob {
  position: absolute;
  z-index: 1;
  width: 38%;
  height: 38%;
  border: 1px solid rgba(195, 240, 231, .65);
  border-radius: 50%;
  background: radial-gradient(circle at 36% 32%, rgba(180, 241, 229, .82), rgba(84, 155, 151, .72) 70%);
  box-shadow: 0 0 24px rgba(110, 224, 209, .23), inset 0 1px 0 rgba(255,255,255,.4);
  transform: translate(0, 0);
  pointer-events: none;
}

.move-zone > span {
  position: absolute;
  bottom: 0;
  color: rgba(207, 221, 218, .55);
  font: 500 8px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .13em;
}

.echo-button {
  position: absolute;
  z-index: 3;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(31px, env(safe-area-inset-bottom));
  width: clamp(100px, 27vw, 128px);
  height: clamp(100px, 27vw, 128px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid rgba(255, 194, 119, .66);
  border-radius: 50%;
  color: #fff0d9;
  background: radial-gradient(circle at 50% 35%, rgba(114, 79, 49, .75), rgba(35, 30, 29, .91) 70%);
  box-shadow: 0 0 0 7px rgba(255, 194, 119, .045), 0 9px 30px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.14);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}

.echo-button:active { transform: scale(.96); }
.echo-button[disabled] { opacity: .47; filter: saturate(.35); }
.echo-button .echo-icon { color: var(--amber); font-size: 25px; line-height: 1; transform: rotate(-14deg); }
.echo-button > span:nth-child(2) { font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .16em; }
.echo-button small { color: #c3a57e; font: 500 7px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .12em; }

.status-toast {
  position: absolute;
  z-index: 4;
  top: max(76px, calc(env(safe-area-inset-top) + 58px));
  left: 50%;
  max-width: min(90vw, 440px);
  padding: 9px 13px;
  border: 1px solid rgba(255, 194, 119, .32);
  border-radius: 6px;
  color: #f4d7af;
  background: rgba(24, 21, 19, .88);
  box-shadow: 0 6px 24px rgba(0,0,0,.24);
  opacity: 0;
  transform: translate(-50%, -7px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
  font: 600 9px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .08em;
  text-align: center;
}

.status-toast.visible { opacity: 1; transform: translate(-50%, 0); }
[hidden] { display: none !important; }

@media (pointer: coarse), (max-width: 760px) {
  .touch-controls.active { display: block; }
  .desktop-hint { display: none; }
  .brand-mark { top: max(17px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left)); }
  .corner-note { right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); font-size: 8px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .move-zone { width: 104px; height: 104px; bottom: 12px; left: 12px; }
  .echo-button { width: 94px; height: 94px; bottom: 16px; right: 16px; }
  .corner-note { display: none; }
  .brand-mark { top: 12px; left: 16px; }
  .status-toast { top: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
