:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  background: #080e34;
  color: #f6f7ec;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; }
button, select, input { font: inherit; }
button, select, summary { min-height: 48px; cursor: pointer; }
button, select { border: 1px solid #ffffff45; border-radius: 8px; color: inherit; background: #182c87; }
button:active { transform: translateY(2px); filter: brightness(.88); }
button:disabled { opacity: .55; }
:focus-visible { outline: 3px solid #fbce76; outline-offset: 4px; }
#scene:focus { outline: none; }
[hidden] { display: none !important; }
#game { position: relative; width: 100%; height: 100svh; overflow: hidden; background: #111d6b; }
#scene { position: absolute; width: 100%; height: 100%; touch-action: none; }
header { position: absolute; top: calc(20px + var(--safe-top)); left: calc(24px + var(--safe-left)); right: calc(24px + var(--safe-right)); display: flex; justify-content: space-between; align-items: start; pointer-events: none; }
.wordmark { font-size: 14px; letter-spacing: 3px; font-weight: 900; line-height: 1.2; }
.wordmark span { display: block; letter-spacing: 5.5px; color: #aebcf8; }
#pause { width: 48px; font-size: 20px; background: #0b164de8; pointer-events: auto; }
#hud { position: absolute; left: calc(24px + var(--safe-left)); top: calc(75px + var(--safe-top)); display: flex; align-items: baseline; gap: 10px; pointer-events: none; padding: 5px 8px; border-radius: 5px; background: #0c1646ed; }
#hud > span { font-size: 8px; letter-spacing: 1.4px; }
#score { font-size: 28px; line-height: 1; letter-spacing: -1px; }
#best { font-size: 9px; color: #afbef0; }
#hint { position: absolute; top: calc(108px + var(--safe-top)); margin: 0; width: 100%; text-align: center; font-size: 12px; pointer-events: none; color: #fff3d6; }
#panel { position: absolute; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); width: min(340px, calc(100% - 48px)); padding: 21px 24px 8px; background: linear-gradient(145deg, #101b65ef, #0b123bf2); border: 1px solid #819cff45; border-radius: 15px; box-shadow: 0 20px 60px #03062360; max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 30px); overflow-y: auto; }
h1 { font-size: clamp(38px, 9vw, 48px); line-height: .95; letter-spacing: -2px; margin: 0 0 15px; }
h1 em { font-style: normal; color: #ff9b86; }
#description { font-size: 13px; color: #c6cdec; line-height: 1.5; margin: 0 0 18px; }
.primary { background: #ff9984; color: #172052; width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; font-weight: bold; border: 0; min-height: 54px; }
.primary span { font-size: 22px; }
summary { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: #b5c4fa; list-style: none; }
summary::after { content: '+'; font-size: 20px; }
details[open] summary::after { content: '−'; }
.settings-body { display: grid; gap: 8px; padding-bottom: 12px; }
label { font-size: 12px; color: #c6cdec; }
select { display: block; appearance: none; -webkit-appearance: none; width: 100%; height: 48px; padding: 0 12px; font-size: 12px; background: #17225c; }
.check { display: flex; align-items: center; gap: 9px; min-height: 48px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: #ff9984; }
.keys { font-size: 11px; color: #9aaadd; line-height: 1.5; margin: 0; }
#thumb { position: absolute; left: 24px; right: 24px; bottom: calc(60px + var(--safe-bottom)); height: 14%; display: flex; justify-content: center; align-items: center; gap: 25px; font-size: 10px; letter-spacing: 2.5px; color: #afc0ff66; border-top: 1px solid #9ab4ff14; pointer-events: none; }
#thumb span { font-size: 22px; }
#countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 80px; font-weight: bold; background: #070d2833; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
body[data-mode="title"] .wordmark, body[data-mode="title"] #thumb { visibility: hidden; }
body[data-mode="lost"] h1, body[data-mode="paused"] h1 { font-size: 31px; letter-spacing: -1px; }
body[data-mode="play"] #panel, body[data-mode="countdown"] #panel { display: none; }
@media (min-aspect-ratio: 23/20) {
  #panel { left: max(24px, calc((100% - 1000px)/2)); bottom: 50%; transform: translateY(50%); width: min(34%, 340px); }
  #hud { left: 55%; top: calc(20px + var(--safe-top)); }
  #hint { left: 45%; width: 55%; top: calc(54px + var(--safe-top)); }
  #thumb { left: 45%; }
}
@media (max-height: 640px) and (max-aspect-ratio: 23/20) {
  #panel { padding: 14px 20px 4px; bottom: calc(12px + var(--safe-bottom)); }
  h1 { font-size: 32px; }
  #description { margin-bottom: 10px; font-size: 12px; }
}
body[data-mode="play"] .wordmark, body[data-mode="countdown"] .wordmark { visibility: hidden; }
#hud { top: calc(21px + var(--safe-top)); }
#hint { top: calc(78px + var(--safe-top)); }
.metrics-download { display: block; width: 100%; font-size: 12px; margin: 0 0 12px; }
select { font-size: 16px; }
@media (max-height: 640px) and (max-aspect-ratio: 23/20) {
  body[data-mode="title"] h1 { font-size: 28px; letter-spacing: -1px; }
  body[data-mode="title"] h1 br { display: none; }
  body[data-mode="title"] h1 em { margin-left: .2em; }
}
body[data-mode="lost"] .wordmark, body[data-mode="paused"] .wordmark { visibility: hidden; }
#hint { top: auto; bottom: calc(105px + var(--safe-bottom)); left: 24px; right: 24px; width: auto; line-height: 1.5; padding: 12px; }
.arrow { font-family: Arial, Helvetica, sans-serif; font-variant-emoji: text; }
@media (min-aspect-ratio: 23/20) { #hint { left: 45%; } }
/* Compact controls retain a clear separation at the smallest trial viewport. */
#settings { margin-top: 8px; }
#hud { gap: 8px; padding: 8px; }
#hud > span { font-size: 10px; letter-spacing: 1px; }
#best { font-size: 10px; }
#thumb {
  left: 50%; right: auto; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 48px); height: auto;
  padding: 10px 12px; gap: 16px; border: 1px solid #43558d;
  border-radius: 8px; color: #e3ebff; background: #0b123a;
}
#hint {
  left: 50%; right: auto; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 48px);
  padding: 10px 12px; color: #fff5dd; background: #0b123a;
  border: 1px solid #43558d; border-radius: 8px;
}
@media (max-height: 640px) and (max-aspect-ratio: 23/20) {
  body[data-mode="lost"] #panel { padding: 14px 20px 4px; }
  body[data-mode="lost"] h1 { font-size: 28px; line-height: 1; margin: 0 0 8px; }
  body[data-mode="lost"] #description { font-size: 12px; line-height: 1.4; margin: 0 0 8px; }
}
@media (min-aspect-ratio: 23/20) {
  #hint, #thumb { left: 69%; }
}
/* Experiment: static full-height architecture plus a bounded transparent play raster. */
#architecture { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#scene { pointer-events: auto; }
#render { position: absolute; pointer-events: none; }
/* Text enlargement: keep the card scrollable and allow each intrinsic grid item to shrink. */
#panel { min-width: 0; overflow-x: hidden; overscroll-behavior: contain; }
#panel h1, #panel p, #panel label, #panel summary, #panel button {
  overflow-wrap: anywhere; max-width: 100%;
}
.settings-body { grid-template-columns: minmax(0, 1fr); }
.settings-body > *, #panel button, #panel select { min-width: 0; max-width: 100%; }
#panel select { height: auto; min-height: 48px; padding-block: 12px; line-height: 1.4; }
#panel .check { min-width: 0; }
#panel .check input { flex: 0 0 20px; }
#panel .primary, #panel summary { gap: 8px; flex-wrap: wrap; }
#panel .primary .arrow { flex: 0 0 auto; }
@media (max-width: 240px) {
  #panel { width: calc(100% - 16px); padding-inline: 12px; }
  #hud { max-width: calc(100% - 80px); flex-wrap: wrap; }
}
@media (min-aspect-ratio: 23/20) and (max-width: 640px) {
  #panel { left: 8px; width: calc(100% - 16px); max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 16px); }
}
