* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #07080c;
  color: #f6efe2;
  font-family: "Palatino Linotype", Palatino, "Songti SC", "Microsoft YaHei", serif;
  overflow: hidden;
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
body.clean .panel,
body.clean .speedo,
body.clean .touch,
body.clean .minimap,
body.clean .panel-toggle,
body.clean .help { display: none !important; }

.letterbox {
  position: fixed;
  left: 0; right: 0;
  height: 7vh;
  background: #05060a;
  z-index: 3;
  pointer-events: none;
}
.letterbox.top { top: 0; }
.letterbox.bottom { bottom: 0; }

.grain, .vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.grain { opacity: 0.16; mix-blend-mode: overlay; }
.vignette {
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
}

.titlecard {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  animation: card 7s ease forwards;
}
.studio {
  letter-spacing: 0.55em;
  font-size: 13px;
  color: #e8c27a;
}
.titlecard h1 {
  margin: 10px 0 0;
  font-weight: 500;
  font-size: clamp(40px, 6vw, 84px);
  letter-spacing: 0.12em;
}
.titlecard p {
  margin: 8px 0 0;
  letter-spacing: 0.42em;
  font-size: 12px;
  color: #f0d7a8;
}
@keyframes card {
  0% { opacity: 0; }
  14% { opacity: 1; }
  68% { opacity: 1; }
  100% { opacity: 0; }
}

.panel-toggle, .panel, .speedo, .touch, .minimap, .subtitle, .selftest, .help {
  z-index: 5;
}
.panel-toggle {
  display: none;
  position: fixed;
  top: calc(7vh + 10px);
  left: 12px;
  background: rgba(8, 10, 14, 0.78);
  color: #f3e6c4;
  border: 1px solid rgba(232, 194, 122, 0.45);
  padding: 8px 12px;
}
.panel {
  position: fixed;
  top: calc(7vh + 12px);
  left: 14px;
  width: min(320px, calc(100vw - 28px));
  max-height: calc(100vh - 14vh - 24px);
  overflow: auto;
  padding: 14px 14px 12px;
  background: rgba(8, 10, 14, 0.62);
  border: 1px solid rgba(232, 194, 122, 0.38);
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
}
.panel h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.14em;
}
.kicker, .hint, .group-label {
  color: #e8c27a;
  letter-spacing: 0.22em;
  font-size: 11px;
}
.kicker { margin: 0 0 4px; }
#status {
  min-height: 1.4em;
  margin: 8px 0 10px;
  font-size: 14px;
}
.group-label { margin: 10px 0 6px; }
.row { display: flex; flex-wrap: wrap; gap: 6px; }
button {
  font: inherit;
  color: #f6efe2;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(243, 230, 196, 0.28);
  padding: 8px 10px;
  cursor: pointer;
  letter-spacing: 0.06em;
}
button:hover { border-color: #e8c27a; }
button.active {
  background: rgba(232, 194, 122, 0.18);
  border-color: #e8c27a;
  color: #fff8ea;
}
button:disabled { opacity: 0.45; cursor: default; }
.cta {
  width: 100%;
  margin-top: 4px;
  padding: 13px 10px;
  background: linear-gradient(180deg, #f0d7a2, #b8893e);
  color: #1a1208;
  border: none;
  font-weight: 700;
  letter-spacing: 0.22em;
}
.cta:hover { filter: brightness(1.05); }
.hint { margin: 12px 0 0; line-height: 1.55; letter-spacing: 0.04em; }

.speedo {
  position: fixed;
  right: 22px;
  bottom: calc(7vh + 18px);
  text-align: right;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
}
.speedo strong {
  display: block;
  font-size: 64px;
  line-height: 0.85;
  font-weight: 500;
}
.speedo span, .speedo em {
  letter-spacing: 0.28em;
  font-style: normal;
  color: #e8c27a;
  font-size: 12px;
}
.subtitle {
  position: fixed;
  left: 50%;
  bottom: calc(7vh + 22px);
  transform: translateX(-50%);
  width: min(680px, 72vw);
  text-align: center;
  font-size: clamp(16px, 2vw, 22px);
  letter-spacing: 0.08em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  opacity: 0;
}
.subtitle.show { animation: sub 4.8s ease forwards; }
@keyframes sub {
  0% { opacity: 0; }
  12% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0.82; }
}
.minimap {
  position: fixed;
  top: calc(7vh + 12px);
  right: 14px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(232, 194, 122, 0.4);
  background: rgba(8, 10, 14, 0.35);
}
.touch {
  position: fixed;
  right: 18px;
  bottom: calc(7vh + 110px);
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 6px;
}
.touch button { padding: 12px 0; background: rgba(8, 10, 14, 0.72); }
.selftest {
  position: fixed;
  top: calc(7vh + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #6d1020;
  color: white;
  padding: 8px 12px;
}
@media (max-width: 860px) {
  .panel-toggle { display: block; }
  .panel { display: none; top: auto; bottom: calc(7vh + 8px); max-height: 46vh; }
  .panel.open { display: block; }
  .minimap { width: 112px; height: 112px; }
  .speedo strong { font-size: 42px; }
  .touch { right: 8px; bottom: calc(7vh + 78px); }
}
