/* Maze Race. Full-screen game; every screen floats over the 3D canvas. One look: dusk hedge garden. */
:root {
  --hedge: #1f4a27;
  --hedge-deep: #12291a;
  --gravel: #e9dcbc;
  --ink: #102016;
  --gold: #ffc53d;
  --you: #e0533a;
  --go: #4fd27a;
  --paper: #fbf6e8;
  --scrim: rgba(10, 22, 14, 0.82);
  --card: rgba(10, 22, 14, 0.45);
  --font-display: "Lilita One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--hedge-deep); color: var(--paper); font-family: var(--font-body); }
body { user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
#three { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.screen {
  position: fixed; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  text-align: center;
}
.screen.scroll { overflow-y: auto; justify-content: flex-start; -webkit-overflow-scrolling: touch; }
.screen.scroll > * { flex: none; }
#menu, #lobby, #statsScreen { background: radial-gradient(120% 80% at 50% 0%, #2f6b37 0%, var(--hedge) 45%, var(--hedge-deep) 100%); }
#study { background: var(--hedge-deep); justify-content: flex-start; }
#win { background: var(--scrim); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(3rem, 15vw, 5.5rem); line-height: .9; margin: 0; letter-spacing: .01em; color: var(--gold); text-shadow: 0 4px 0 #7a5200, 0 10px 24px rgba(0,0,0,.45); text-wrap: balance; }
h2 { font-family: var(--font-display); font-weight: 400; font-size: 2.2rem; margin: 0; color: var(--gold); text-wrap: balance; }
h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; margin: 0; color: var(--paper); text-align: left; }
.tag { font-size: 1rem; max-width: 32ch; opacity: .9; line-height: 1.45; margin: 0; }
.label { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 800; opacity: .75; }
.fine { color: var(--paper); opacity: .55; font-size: .8rem; }

button {
  font: inherit; font-family: var(--font-display); font-size: 1.35rem; letter-spacing: .02em;
  border: 0; border-radius: 999px; padding: 14px 34px; cursor: pointer;
  background: var(--gold); color: var(--ink);
  box-shadow: 0 5px 0 #a87400, 0 10px 20px rgba(0,0,0,.35);
  transition: transform .08s ease, box-shadow .08s ease;
}
button:active { transform: translateY(4px); box-shadow: 0 1px 0 #a87400, 0 4px 10px rgba(0,0,0,.35); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--paper); outline-offset: 3px; }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; color: var(--paper); box-shadow: inset 0 0 0 2px rgba(251,246,232,.5); }
button.small { font-size: 1rem; padding: 8px 16px; }
button.chip { font-family: var(--font-body); font-weight: 800; font-size: .95rem; padding: 8px 16px; background: var(--scrim); color: var(--paper); box-shadow: inset 0 0 0 1px rgba(251,246,232,.25); }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.topbar { width: min(100%, 560px); display: flex; justify-content: space-between; gap: 10px; }

input {
  font: inherit; font-size: 16px; font-weight: 800; width: 100%;
  padding: 12px 16px; border-radius: 14px; border: 0;
  background: rgba(251,246,232,.95); color: var(--ink);
  user-select: text; -webkit-user-select: text;
}

/* Loading page: the whole cover, centered, its top and bottom fading into the cover's own blues. */
.loading-screen { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(#00103f, #001657 30%, #001c61 70%, #001a5a); }
.cover-stage { position: relative; aspect-ratio: 1086 / 1448; width: min(100vw, 75vh); width: min(100vw, 75dvh); max-width: 100%; }
.cover-art { display: block; width: 100%; height: 100%;
  -webkit-mask-image: linear-gradient(transparent, #000 7%, #000 93%, transparent);
  mask-image: linear-gradient(transparent, #000 7%, #000 93%, transparent); }
/* Measured from the cover: the painted bar's gold rim spans x 222-862 and y 1115-1195 of 1086 x 1448. */
.cover-bar { position: absolute; left: 20.1%; top: 76.8%; width: 59.8%; height: 5.8%; border-radius: 999px; padding: 1%;
  background: linear-gradient(#fff2a8, #ffc53d 45%, #d98a00); box-shadow: 0 0 0 2px #7a3e00 inset, 0 4px 14px rgba(0, 0, 0, .45); }
.cover-track { width: 100%; height: 100%; border-radius: 999px; background: #0b1230; overflow: hidden; box-shadow: inset 0 2px 6px rgba(0, 0, 0, .6); }
.loading-fill { height: 100%; width: 0; border-radius: 999px;
  background: repeating-linear-gradient(-45deg, rgba(255,255,255,.22) 0 7px, transparent 7px 14px), linear-gradient(#8fe4ff, #2aa3ff 55%, #1063d6);
  background-size: 20px 100%, 100% 100%; animation: stripes .6s linear infinite;
  box-shadow: 0 0 10px rgba(120, 210, 255, .9); }
@keyframes stripes { to { background-position: 20px 0, 0 0; } }

/* Fletch Built */
.splash-screen { background: #f9f9f9; z-index: 8; transition: opacity .6s ease; }
.splash-screen img { width: min(80vw, 80vh, 520px); height: auto; }
.splash-screen.is-hidden { opacity: 0; }

/* Menu */
.modes { display: grid; gap: 14px; width: min(100%, 380px); }
.mode { display: grid; gap: 10px; padding: 16px; border-radius: 18px; background: var(--card); box-shadow: inset 0 0 0 1px rgba(251,246,232,.12); }
.mode p { margin: 0; font-size: .92rem; opacity: .85; line-height: 1.4; }
.mode > button { width: 100%; }
.seg { display: flex; gap: 8px; justify-content: center; align-items: center; }
.seg span { font-weight: 800; font-size: .9rem; margin-right: 4px; }
.seg button { padding: 6px 0; width: 48px; font-size: 1.2rem; background: transparent; color: var(--paper); box-shadow: inset 0 0 0 2px rgba(251,246,232,.35); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.join { display: flex; gap: 10px; }
.join input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; min-width: 0; }
.join button { flex: none; padding: 10px 22px; font-size: 1.15rem; }
.how { display: grid; gap: 4px; font-size: .88rem; opacity: .8; max-width: 34ch; text-align: left; margin: 0; padding-left: 1.2em; }

/* Online room */
.roomcode { font-family: var(--font-display); font-size: 4.5rem; letter-spacing: .18em; color: var(--gold); line-height: 1; padding-left: .18em; user-select: text; -webkit-user-select: text; }
.members { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; width: min(100%, 360px); }
.members li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; background: rgba(251,246,232,.08); font-weight: 800; text-align: left; }
.members li.me { box-shadow: inset 0 0 0 2px var(--you); }
.members .st { font-size: .8rem; opacity: .7; font-weight: 600; white-space: nowrap; }

/* Study */
.studybar { width: min(100%, 560px); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.count { font-family: var(--font-display); font-size: 3rem; line-height: 1; color: var(--gold); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.count.hot { color: #ff7a59; }
.meter { width: min(100%, 560px); height: 8px; border-radius: 99px; background: rgba(251,246,232,.15); overflow: hidden; flex: none; }
.meter > i { display: block; height: 100%; width: 100%; background: var(--gold); transform-origin: left; }
#map { border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5); max-width: 100%; flex: none; }
.legend { display: flex; gap: 8px 16px; font-size: .9rem; font-weight: 800; flex-wrap: wrap; justify-content: center; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; flex: none; }

/* HUD */
#hud { position: fixed; z-index: 4; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none;
  padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px)); }
.pill { pointer-events: auto; background: var(--scrim); border-radius: 999px; padding: 8px 14px; font-weight: 800; font-variant-numeric: tabular-nums; box-shadow: 0 4px 14px rgba(0,0,0,.3); white-space: nowrap; }
#timer { font-family: var(--font-display); font-size: 1.7rem; color: var(--gold); padding: 4px 18px; }
#hud button { pointer-events: auto; font-size: 1rem; padding: 8px 14px; background: var(--scrim); color: var(--paper); box-shadow: 0 4px 14px rgba(0,0,0,.3); }
#toast { position: fixed; z-index: 7; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 66px); transform: translateX(-50%); pointer-events: none; transition: opacity .4s; }
#hint { position: fixed; z-index: 4; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); font-weight: 800; font-size: .9rem; opacity: .85; pointer-events: none; transition: opacity .6s; white-space: nowrap; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
#touch { position: fixed; inset: 0; z-index: 3; touch-action: none; }
#joy { position: fixed; z-index: 4; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%; background: rgba(251,246,232,.12); box-shadow: inset 0 0 0 2px rgba(251,246,232,.35); pointer-events: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(251,246,232,.75); box-shadow: 0 4px 12px rgba(0,0,0,.35); }
#go { position: fixed; z-index: 6; inset: 0; display: grid; place-items: center; pointer-events: none; font-family: var(--font-display); font-size: 24vw; color: var(--go); text-shadow: 0 6px 0 #1b6b38, 0 14px 30px rgba(0,0,0,.5); }
#go.pop { animation: pop .9s ease-out forwards; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 25% { transform: scale(1.1); opacity: 1; } 70% { opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }

/* Results */
.stats { display: flex; gap: 26px; }
.stat b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 2.2rem; color: var(--paper); font-variant-numeric: tabular-nums; }
#standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; width: min(100%, 360px); }
#standings li { display: grid; grid-template-columns: 2.2em 1fr auto; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 12px; background: rgba(251,246,232,.08); text-align: left; font-variant-numeric: tabular-nums; }
#standings li.me { background: rgba(224, 83, 58, .28); box-shadow: inset 0 0 0 2px var(--you); }
#standings .pl { font-family: var(--font-display); font-size: 1.3rem; color: var(--gold); }
#standings .nm { font-weight: 800; min-width: 0; overflow-wrap: anywhere; }
#standings .sk { display: block; font-size: .75rem; opacity: .7; font-weight: 600; }
#standings .tm { font-weight: 800; }
#trail { border-radius: 10px; max-width: 100%; flex: none; }
.newbest { color: var(--go); font-weight: 800; }

/* Account panel */
.panel-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(5, 12, 8, .7); display: grid; place-items: center; overflow-y: auto;
  padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.panel { position: relative; width: min(100%, 380px); display: grid; gap: 14px; padding: 24px 20px 20px; border-radius: 22px; background: var(--hedge); box-shadow: 0 20px 60px rgba(0,0,0,.5), inset 0 0 0 1px rgba(251,246,232,.15); text-align: center; justify-items: center; }
.panel .close { position: absolute; top: 10px; right: 10px; padding: 6px 12px; font-size: 1rem; background: transparent; color: var(--paper); box-shadow: none; }
.form { display: grid; gap: 10px; width: 100%; }
.form .label { text-align: left; }
.status { margin: 0; min-height: 1.2em; font-weight: 800; color: var(--gold); line-height: 1.4; }

/* Stats page */
.stats-body { width: min(100%, 560px); display: grid; gap: 18px; text-align: left; padding-bottom: 12px; }
.stats-head { display: grid; gap: 4px; text-align: center; }
.banner { padding: 12px 16px; border-radius: 14px; background: rgba(255, 197, 61, .15); box-shadow: inset 0 0 0 1px rgba(255, 197, 61, .4); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-weight: 800; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 520px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { padding: 14px; border-radius: 16px; background: var(--card); box-shadow: inset 0 0 0 1px rgba(251,246,232,.12); display: grid; gap: 2px; }
.tile b { font-family: var(--font-display); font-weight: 400; font-size: 1.9rem; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile span { font-size: .8rem; opacity: .75; font-weight: 800; }
.section { display: grid; gap: 10px; }
.table-wrap { overflow-x: auto; border-radius: 14px; background: var(--card); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .92rem; }
th, td { padding: 9px 12px; text-align: left; white-space: nowrap; }
th { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
tr + tr td { border-top: 1px solid rgba(251,246,232,.08); }
td.num, th.num { text-align: right; }
.skillbar { display: inline-block; width: 60px; height: 6px; border-radius: 9px; background: rgba(251,246,232,.15); vertical-align: middle; overflow: hidden; }
.skillbar i { display: block; height: 100%; background: var(--gold); }
.empty { opacity: .75; font-weight: 600; margin: 0; }

@media (prefers-reduced-motion: reduce) { #go.pop { animation-duration: .01s; } button { transition: none; } .splash-screen { transition: none; } .loading-fill { animation: none; } }
