html { height: 100%; overflow: hidden; }
body.rally-student { height: 100%; min-height: 0; overflow: hidden; font-family: Inter, system-ui, sans-serif; background: #0a092b; color: #fff; }
body.rally-student.light-mode { --color-primary: #4f6dff; --color-primary-light: #2a3b7d; --color-primary-dark: #3a5bf0; --color-secondary: #ffcd1f; --color-bg: #0a092b; --color-bg-secondary: #1a2342; --color-card-bg: #232e54; --color-text-primary: #fff; --color-text-secondary: #f0f3ff; --color-border: #3a497c; background: #0a092b; color: #fff; }
[hidden] { display: none !important; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--color-secondary); outline-offset: 4px; }
h1[tabindex="-1"]:focus { outline: none; }
.student-shell { position: relative; width: 100%; height: 100%; height: 100dvh; min-height: 0; }
.screen { position: absolute; inset: 0; min-height: 0; overflow: hidden; animation: enter .2s ease-out; }
.entry-view { display: grid; place-items: center; padding: 24px; }
.join-box { width: min(100%, 300px); transform: translateY(-12px); }
.rally-logo { display: flex; align-items: center; justify-content: center; gap: 13px; width: max-content; max-width: 100%; margin: 0 auto; user-select: none; }
.rally-logo img { display: block; height: auto; object-fit: contain; flex-shrink: 0; }
.rally-logo span { font-size: 2rem; font-weight: 700; line-height: 1; letter-spacing: -.04em; color: #fff; }
.entry-logo { margin-bottom: 30px; }
.entry-logo img { width: 112px; }
#join-form { position: relative; margin: 0; }
.join-input { display: block; width: 100%; height: 58px; padding: 14px 16px; border: 2px solid var(--color-border); border-radius: var(--border-radius-button); background: var(--color-bg-secondary); color: #fff; font-size: 1.15rem; font-weight: 600; text-align: center; box-shadow: none; }
.join-input::placeholder { color: #b5bdd4; font-weight: 500; letter-spacing: normal; text-transform: none; opacity: 1; }
.join-input:focus { border-color: var(--color-primary); }
.join-input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--color-primary-light); }
.join-input[aria-invalid=true] { border-color: var(--color-incorrect); }
.code-input { text-transform: uppercase; letter-spacing: .13em; }
#join-submit { width: 100%; min-height: 52px; margin-top: 12px; background: var(--color-primary-dark); }
#join-submit:disabled { cursor: wait; opacity: .7; }
.join-error { color: #ffb6b2; font-size: .85rem; line-height: 1.5; text-align: center; margin: 12px 0 0; }
.join-error:empty { display: none; }
.text-button { border: 0; background: transparent; color: #b8c4f0; font-weight: 500; font-size: .85rem; padding: 10px; border-radius: 8px; cursor: pointer; min-height: 44px; }
.text-button:hover { color: #fff; }
.change-code { display: block; margin: 6px auto 0; }
.screen-logo { position: absolute; top: max(25px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); gap: 10px; }
.screen-logo img { width: 86px; }
.screen-logo span { font-size: 1.5rem; }
.waiting-view { display: grid; place-items: center; padding: 100px 24px 120px; }
.waiting-copy { width: min(100%, 520px); text-align: center; }
.waiting-copy h1, .round-copy h1 { font-size: clamp(2rem, 5vw, 3.25rem); font-weight: 800; line-height: 1.15; margin: 0 0 20px; letter-spacing: -.04em; }
.student-name { font-size: clamp(1.1rem, 3.5vw, 1.45rem); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; margin: 0; }
.student-team { color: var(--color-secondary); font-size: 1rem; font-weight: 600; margin: 8px 0 0; }
.waiting-status { color: #adb7d1; font-size: .85rem; margin: 24px 0 0; }
.games-toggle { position: absolute; left: 50%; bottom: max(40px, env(safe-area-inset-bottom)); translate: -50% 0; white-space: nowrap; background: transparent; border-width: 1px; color: #c4cdea; font-size: .85rem; font-weight: 600; padding: 11px 17px; min-height: 44px; }
.leave-room { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); left: 15px; font-size: .78rem; color: #8e9bbf; }
.round-view { display: grid; place-items: center; padding: 100px 24px 40px; }
.round-copy { width: min(100%, 520px); text-align: center; }
.round-copy h1 { margin-bottom: 16px; }
.round-copy p { font-size: .9rem; line-height: 1.5; color: #b6c0da; margin: 0 auto 20px; max-width: 420px; }
.round-copy p:empty { display: none; }
.countdown { font-size: clamp(4rem, 18vh, 7rem); font-weight: 800; line-height: 1.1; color: var(--color-secondary); font-variant-numeric: tabular-nums; }
.countdown:empty { display: none; }
#games-dialog { position: fixed; inset: 16px; width: calc(100% - 32px); height: calc(100% - 32px); height: calc(100dvh - 32px); max-width: none; max-height: none; min-width: 0; min-height: 0; padding: 0; margin: 0; border: 1px solid var(--color-border); border-radius: 18px; background: var(--color-bg); color: #fff; overflow: hidden; }
#games-dialog[open] { display: flex; flex-direction: column; }
#games-dialog::backdrop { background: rgba(0, 0, 0, .65); }
.games-toolbar { display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 8px 12px 8px 20px; border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.games-toolbar h2 { flex: 1; font-size: .95rem; font-weight: 600; margin: 0; min-width: 0; }
.games-toolbar:has(#games-back:not([hidden])) h2 { text-align: center; }
.games-toolbar #games-back { padding-left: 0; white-space: nowrap; }
.close-games { display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: #c4cdea; cursor: pointer; }
.close-games:hover { background: var(--color-bg-secondary); color: #fff; }
.close-games svg { width: 22px; height: 22px; }
.game-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 190px)); align-content: center; justify-content: center; gap: 14px; min-height: 0; flex: 1; padding: 24px; }
.game-choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 126px; padding: 20px 12px; border: 1px solid var(--color-border); border-radius: 14px; background: var(--color-bg-secondary); color: #fff; font-size: .9rem; font-weight: 600; cursor: pointer; }
.game-choice:hover { border-color: var(--color-primary); background: var(--color-card-bg); }
.game-symbol { color: var(--color-secondary); font-size: 1.8rem; font-weight: 700; line-height: 1; }
.snake-icon { display:block;width:1.8rem;height:1.8rem; }
.game-stage { display: flex; flex: 1 1 0; min-width: 0; min-height: 0; overflow: hidden; width: 100%; position: relative; }
.game-stage iframe { display: block; width: 100%; height: 100%; border: 0; flex: 1; min-width: 0; min-height: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.noscript-message { position: fixed; bottom: 18px; left: 20px; right: 20px; color: #ffb6b2; font-size: .85rem; text-align: center; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (max-height: 500px) { .screen-logo { top: 14px; } .screen-logo img { width: 65px; } .screen-logo span { font-size: 1.2rem; } .waiting-view { padding: 70px 24px 85px; } .waiting-copy h1 { font-size: 2rem; margin-bottom: 10px; } .waiting-status { margin-top: 12px; } .games-toggle { bottom: 20px; } .entry-logo { margin-bottom: 18px; } .entry-logo img { width: 90px; } .entry-logo span { font-size: 1.6rem; } .join-box { transform: none; } .game-picker { grid-template-columns: repeat(4,minmax(0,160px)); padding: 16px; gap: 10px; } .game-choice { min-height: 100px; padding: 14px 8px; } }
@media (max-width: 480px) { #games-dialog { inset: 0; width: 100%; height: 100%; height: 100dvh; border: 0; border-radius: 0; } .games-toolbar { padding-left: 15px; padding-top: max(8px, env(safe-area-inset-top)); } .game-picker { gap: 12px; padding: 20px; } .games-toggle { bottom: max(55px, env(safe-area-inset-bottom)); } }
@media (max-width: 480px) and (max-height: 500px) { .game-picker { grid-template-columns: repeat(2,minmax(0,160px)); padding: 10px; gap: 8px; } .game-choice { min-height: 65px; padding: 10px; flex-direction: row; } .game-symbol { font-size: 1.2rem; } .snake-icon { width:1.2rem;height:1.2rem; } .games-toggle { bottom: 18px; } .leave-room { bottom: 0; left: 5px; padding: 5px; min-height: 30px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
#turnstile-placement { display: flex; justify-content: center; margin-top: 12px; }
.waiting-view { padding-top: 40px; }
.round-view { padding-top: 40px; }
.entry-view { overflow-y: auto; }
.how-it-works { display: block; margin: 2px auto 0; padding: 10px 12px; text-decoration: underline; text-underline-offset: 4px; }
#how-body { font-size: .92rem; line-height: 1.5; }
.how-steps { margin: 0; padding-left: 22px; }
.how-steps li { margin-bottom: 12px; padding-left: 4px; }
.how-steps strong { display: block; }
.how-blue { color: var(--rally-discussion-blue); font-weight: 700; }
#how-body h3 { margin: 18px 0 8px; font-size: 1rem; }
.how-notes { margin: 0; padding-left: 20px; color: var(--color-text-secondary); font-size: .86rem; }
.how-notes li { margin-bottom: 7px; }
.how-done { display: flex; width: 100%; min-height: 44px; margin-top: 16px; }

/* One entrance per visible step; live name/team updates stay still. */
#nickname-field:not([hidden]), #student-view:not([hidden]) .waiting-copy { animation: rally-join-arrive .4s cubic-bezier(.2,.8,.2,1) both; }
#student-view:not([hidden]) :is(.waiting-status, .how-it-works) { animation: rally-join-arrive .4s .12s cubic-bezier(.2,.8,.2,1) both; }
.game-choice { transition: transform .18s ease, border-color .18s ease, background-color .18s ease; }
@media(hover:hover) { .game-choice:hover { transform: translateY(-3px); } }
.game-choice:active { transform: translateY(1px) scale(.98); }
#join-form[aria-busy=true] #join-submit::before { content: ''; display: inline-block; width: 14px; height: 14px; margin-right: 9px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -2px; animation: rally-join-spin .8s linear infinite; }
@keyframes rally-join-arrive { from { opacity: 0; translate: 0 12px; } to { opacity: 1; translate: 0 0; } }
@keyframes rally-join-spin { to { rotate: 360deg; } }
.rally-sound-waiting { position: absolute; right: 15px; bottom: max(8px, env(safe-area-inset-bottom)); color: #8e9bbf; }

/* While morphing, the dialog's background is the moving 1px outline and ::before is the fill just inside it. */
#games-dialog.games-morphing { background: var(--color-border); }
#games-dialog.games-morphing::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--color-bg); }
.games-morph-label { position: absolute; white-space: nowrap; pointer-events: none; opacity: 0; }
