:root {
    color-scheme: dark;
    --bg: #000;
    --panel: #171719;
    --panel-strong: #242427;
    --panel-soft: rgba(255, 255, 255, .08);
    --line: rgba(255, 255, 255, .1);
    --text: #fff;
    --muted: #929298;
    --accent: #48b997;
    --accent-strong: #63d5b2;
    --danger: #ff5c66;
    --warning: #ffbf47;
    --safe-top: max(18px, env(safe-area-inset-top));
    --safe-bottom: max(18px, env(safe-area-inset-bottom));
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --shadow: 0 20px 60px rgba(0, 0, 0, .45);
    font-family: ui-rounded, "SF Pro Rounded", "Nunito Sans", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, [role="button"] { touch-action: manipulation; }
img { max-width: 100%; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: 2px;
}

#app { min-height: 100dvh; }
.app-shell {
    position: relative;
    width: min(100%, 620px);
    min-height: 100dvh;
    margin: 0 auto;
    overflow: hidden;
    background: #000;
    isolation: isolate;
}
.screen {
    min-height: 100dvh;
    padding: var(--safe-top) 18px var(--safe-bottom);
    display: flex;
    flex-direction: column;
    animation: screen-in .32s cubic-bezier(.22, .8, .24, 1) both;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(8px) scale(.995); } }

.home-screen { justify-content: flex-end; }
.home-art {
    position: absolute;
    z-index: -2;
    inset: 0 0 auto;
    height: 58%;
    background: linear-gradient(to bottom, transparent 48%, #000 100%), url('/assets/background.jpg') center top / cover no-repeat;
    opacity: .9;
}
.home-art::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 35%, rgba(82, 209, 166, .12), transparent 36%);
}
.topbar {
    position: absolute;
    inset: var(--safe-top) 18px auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 5;
}
.server-status { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 14px currentColor; }
.status-dot.online { background: #3ddc84; }
.status-dot.offline { background: var(--danger); }
.icon-button {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(28, 28, 30, .84);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    cursor: pointer;
}
.icon-button img { width: 31px; height: 31px; object-fit: contain; }
.home-content { display: grid; gap: 18px; padding-bottom: 4px; }
.brand { text-align: center; }
.brand-logo { width: 70px; height: 70px; object-fit: contain; }
.brand h1 { margin: 6px 0 4px; font-size: clamp(34px, 10vw, 44px); line-height: 1; letter-spacing: -.045em; }
.brand p { margin: 0; color: var(--muted); font-size: 15px; }

.action-stack { display: grid; gap: 10px; }
.button {
    min-height: 54px;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel-strong);
    font-weight: 800;
    cursor: pointer;
    transition: transform .16s ease, background .16s ease, opacity .16s ease;
}
.button:active { transform: scale(.975); }
.button.primary { color: #07130f; background: #fff; border-color: #fff; }
.button.accent { color: #04130e; background: var(--accent-strong); border-color: transparent; }
.button.ghost { background: var(--panel-soft); }
.button.danger { color: var(--danger); background: rgba(255, 92, 102, .1); border-color: rgba(255, 92, 102, .22); }
.button:disabled { opacity: .38; cursor: default; transform: none; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-button { display: flex; align-items: center; justify-content: space-between; text-align: left; }
.home-button small { padding: 5px 9px; border-radius: 999px; color: #d7d7dc; background: rgba(255,255,255,.08); font-size: 11px; }
.legal { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 10px; color: #66666c; font-size: 11px; text-align: center; }
.legal a { color: #7e7e84; text-decoration: none; }

.page-header { display: flex; align-items: center; gap: 12px; padding: 6px 0 20px; }
.page-header h1 { margin: 0; flex: 1; font-size: 20px; text-align: center; }
.page-header .header-spacer { width: 46px; }
.page-body { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.page-body::-webkit-scrollbar, .card-track::-webkit-scrollbar { display: none; }
.eyebrow { margin: 0 0 7px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.title { margin: 0; font-size: clamp(27px, 8vw, 38px); line-height: 1.08; letter-spacing: -.035em; }
.subtitle { margin: 10px 0 0; color: var(--muted); line-height: 1.45; }
.section-title { margin: 24px 2px 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }

.field-group { display: grid; gap: 8px; }
.field-label { color: #b4b4ba; font-size: 13px; font-weight: 700; }
.field {
    width: 100%;
    min-height: 54px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    color: var(--text);
    background: var(--panel);
}
textarea.field { min-height: 116px; resize: none; }
.code-field { font-size: 42px; font-weight: 900; text-align: center; letter-spacing: .22em; padding-left: calc(16px + .22em); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--panel); border-radius: 18px; }
.segment { border: 0; border-radius: 14px; padding: 11px; color: var(--muted); background: transparent; font-weight: 800; cursor: pointer; }
.segment.active { color: #000; background: #fff; }

.profile-hero { display: grid; place-items: center; gap: 12px; margin: 8px 0 22px; }
.avatar-picker { position: relative; display: grid; place-items: center; width: 116px; height: 116px; border: 0; border-radius: 50%; background: #28282c; overflow: hidden; cursor: pointer; }
.avatar-picker img { width: 84px; height: 84px; object-fit: contain; }
.avatar-picker .camera { font-size: 30px; }
.avatar-picker.loading::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.62); }
.spinner { width: 24px; height: 24px; border: 3px solid rgba(255,255,255,.18); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); padding: 14px 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); }
.stat { text-align: center; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat strong { display: block; font-size: 21px; }
.stat span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.config-list { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--line); }
.config-row { min-height: 72px; display: flex; align-items: center; gap: 13px; padding: 12px 14px; border: 0; background: var(--panel); text-align: left; cursor: pointer; }
.config-row:disabled { cursor: default; }
.config-icon { width: 42px; height: 42px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 50%; background: rgba(255,255,255,.1); font-size: 21px; }
.config-copy { min-width: 0; flex: 1; }
.config-copy strong, .config-copy span { display: block; }
.config-copy span { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.check { width: 26px; height: 26px; display: grid; place-items: center; border: 2px solid #5f5f65; border-radius: 50%; font-size: 16px; }
.check.checked { color: #000; border-color: #fff; background: #fff; }
.range-row { padding: 18px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); }
.range-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.range-top strong { font-size: 16px; }
.peppers { min-width: 68px; text-align: right; letter-spacing: -3px; }
input[type="range"] { width: 100%; margin: 18px 0 4px; accent-color: var(--accent); }
.stepper { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.stepper button { width: 42px; height: 42px; border: 0; border-radius: 13px; background: rgba(255,255,255,.1); font-size: 22px; cursor: pointer; }
.stepper div { text-align: center; }
.stepper strong, .stepper span { display: block; }
.stepper span { color: var(--muted); font-size: 11px; }
.sticky-action { position: sticky; bottom: 0; padding: 16px 0 2px; background: linear-gradient(transparent, #000 25%); }

.lobby-code { text-align: center; padding-top: 18px; }
.lobby-code span { color: var(--muted); font-size: 13px; }
.lobby-code strong { display: block; margin-top: 3px; font-size: 42px; letter-spacing: .14em; }
.copy-code { margin-top: 8px; border: 0; border-radius: 999px; padding: 8px 12px; background: var(--panel-soft); font-size: 12px; font-weight: 800; cursor: pointer; }
.player-panel { margin: auto 0 18px; overflow: hidden; border-radius: 28px; background: var(--panel); border: 1px solid var(--line); }
.player-panel-head { display: flex; justify-content: space-between; padding: 16px 20px; color: var(--muted); background: rgba(255,255,255,.04); font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.player-list { max-height: 42dvh; overflow-y: auto; }
.player-row { display: flex; align-items: center; gap: 13px; min-height: 62px; padding: 10px 16px; border-top: 1px solid var(--line); }
.player-row:first-child { border-top: 0; }
.player-row .name { min-width: 0; flex: 1; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { padding: 5px 9px; border-radius: 999px; color: #d7d7dc; background: rgba(255,255,255,.1); font-size: 11px; font-weight: 800; }
.tag.danger { color: #ffc2c6; background: rgba(255,92,102,.15); }
.avatar { position: relative; width: var(--avatar-size, 44px); height: var(--avatar-size, 44px); flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: var(--avatar-color, #48b997); box-shadow: 0 8px 25px rgba(0,0,0,.28); }
.avatar img { width: 72%; height: 72%; object-fit: contain; }
.avatar .initial { font-weight: 900; color: rgba(255,255,255,.72); }

.game-screen { padding-left: 0; padding-right: 0; }
.game-content { flex: 1; display: flex; min-height: 0; flex-direction: column; align-items: center; justify-content: center; padding: 24px 20px 134px; text-align: center; }
.game-content.with-cards { justify-content: flex-start; padding-top: 68px; padding-bottom: 0; }
.judge-chip { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 22px; padding: 5px 13px 5px 5px; border-radius: 999px; background: var(--panel-strong); font-weight: 900; }
.judge-chip .avatar { --avatar-size: 46px; margin: -1px 0 -1px -1px; }
.black-card-text { width: min(100%, 480px); margin: 0; font-size: clamp(27px, 7vw, 42px); line-height: 1.17; letter-spacing: -.035em; text-wrap: balance; }
.dots { margin-top: 17px; color: #85858a; letter-spacing: 5px; font-size: 19px; }
.round-label { margin-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.center-avatar { --avatar-size: 114px; margin-bottom: 24px; box-shadow: 0 0 54px color-mix(in srgb, var(--avatar-color), transparent 62%); }
.waiting-copy { width: min(100%, 340px); margin: 0; font-size: 22px; line-height: 1.34; text-wrap: balance; }
.waiting-copy.small { color: var(--muted); font-size: 17px; }
.success-mark { width: 118px; height: 118px; display: grid; place-items: center; margin-bottom: 24px; border-radius: 50%; color: #06130a; background: #30d65c; font-size: 56px; font-weight: 900; }
.waiting-panel { width: min(100%, 430px); margin-top: 42px; padding: 18px; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); }
.waiting-panel p { margin: 0 0 13px; color: var(--muted); font-size: 13px; }
.avatar-stack { display: flex; justify-content: center; padding-left: 14px; }
.avatar-stack .avatar { margin-left: -14px; border: 3px solid var(--panel); }

.prompt-area { min-height: 260px; display: grid; place-items: center; align-content: center; padding: 0 22px; }
.card-stage { width: 100%; margin-top: auto; }
.card-track { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: calc((100vw - min(76vw, 320px)) / 2); padding: 16px calc((100vw - min(76vw, 320px)) / 2) 22px; }
.answer-card { position: relative; width: min(76vw, 320px); height: min(58dvh, 430px); flex: 0 0 auto; scroll-snap-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 24px; border: 1px solid rgba(255,255,255,.06); border-radius: 28px; background: #171719; box-shadow: 0 18px 46px rgba(0,0,0,.3); text-align: center; cursor: pointer; }
.answer-card.active { background: #2a2a2d; }
.answer-card p { margin: 0; font-size: clamp(22px, 6.2vw, 31px); line-height: 1.18; font-weight: 800; text-wrap: balance; }
.answer-card .new-tag { position: absolute; top: 17px; right: 17px; padding: 7px 11px; border-radius: 999px; color: #04140e; background: var(--accent-strong); font-size: 11px; font-weight: 900; }
.answer-card.utility { gap: 14px; background: #29292c; }
.utility-icon { width: 72px; height: 72px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.17); font-size: 31px; }
.answer-card.utility h2 { max-width: 230px; margin: 4px 0 0; font-size: 28px; line-height: 1.06; }
.answer-card.utility p { max-width: 248px; color: #b3b3b8; font-size: 16px; line-height: 1.35; font-weight: 500; }
.counter { margin-top: 8px; padding: 8px 15px; border-radius: 999px; color: #000; background: #fff; font-weight: 900; }
.card-indicator { height: 17px; color: #77777d; font-size: 11px; text-align: center; }

.game-bottom { position: absolute; inset: auto 18px var(--safe-bottom); display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.game-bottom > * { pointer-events: auto; }
.score-pill { min-width: 52px; height: 50px; display: flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); font-weight: 900; }
.score-pill::before { content: "✦"; font-size: 23px; }

.review-track .answer-card { justify-content: center; }
.review-number { position: absolute; top: 18px; left: 18px; color: var(--muted); font-size: 12px; font-weight: 900; }
.winner-card { width: min(100%, 430px); padding: 0 22px 28px; border: 1px solid var(--line); border-radius: 28px; background: var(--panel); }
.winner-card .avatar { --avatar-size: 96px; margin: -48px auto 8px; }
.winner-card h2 { margin: 8px 0 14px; font-size: clamp(25px, 7vw, 37px); line-height: 1.18; }
.winner-note { margin-top: 22px; color: var(--muted); }
.podium { width: 100%; display: grid; gap: 8px; margin: 24px 0; }
.podium-row { display: grid; grid-template-columns: 34px 46px 1fr auto; align-items: center; gap: 10px; padding: 10px 13px; border-radius: 18px; background: var(--panel); }
.podium-row .avatar { --avatar-size: 42px; }
.podium-row strong { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-row .score { font-weight: 900; }

.floating-cluster { position: relative; width: min(78vw, 330px); aspect-ratio: 1; margin-bottom: 24px; }
.floating-avatar { position: absolute; left: calc(50% + var(--x)); top: calc(50% + var(--y)); transform: translate(-50%, -50%) scale(var(--scale, 1)); animation: float-avatar var(--duration, 5s) ease-in-out var(--delay, 0s) infinite alternate; z-index: var(--z, 1); }
.floating-avatar .avatar { --avatar-size: var(--size, 74px); }
.particle { position: absolute; left: 50%; top: 50%; width: var(--size); height: var(--size); margin: calc(var(--size) / -2); border-radius: 50%; background: #36363a; opacity: .75; animation: orbit var(--duration) linear var(--delay) infinite; }
@keyframes float-avatar { to { transform: translate(calc(-50% + var(--dx, 5px)), calc(-50% + var(--dy, -7px))) scale(calc(var(--scale, 1) * 1.04)); } }
@keyframes orbit { from { transform: rotate(var(--start)) translateX(var(--radius)) rotate(calc(var(--start) * -1)); } to { transform: rotate(calc(var(--start) + 360deg)) translateX(var(--radius)) rotate(calc((var(--start) + 360deg) * -1)); } }

.connection-overlay { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 30px; background: rgba(0,0,0,.72); backdrop-filter: blur(12px); }
.connection-card { display: grid; justify-items: center; gap: 12px; max-width: 310px; padding: 28px; border: 1px solid var(--line); border-radius: 26px; background: #111113; text-align: center; }
.connection-card h2 { margin: 0; }
.connection-card p { margin: 0; color: var(--muted); line-height: 1.4; }

.modal-backdrop { position: fixed; z-index: 80; inset: 0; display: grid; align-items: end; background: rgba(0,0,0,.7); backdrop-filter: blur(8px); animation: fade-in .2s ease both; }
.modal { width: min(100%, 620px); max-height: min(90dvh, 820px); margin: 0 auto; overflow-y: auto; padding: 14px 18px calc(var(--safe-bottom) + 8px); border: 1px solid var(--line); border-bottom: 0; border-radius: 30px 30px 0 0; background: #171719; box-shadow: var(--shadow); animation: sheet-in .28s cubic-bezier(.22,.8,.25,1) both; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(35px); opacity: 0; } }
.modal-handle { width: 42px; height: 5px; margin: 0 auto 14px; border-radius: 999px; background: #56565c; }
.modal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.modal-header h2 { flex: 1; margin: 0; text-align: center; font-size: 20px; }
.modal-header .icon-button { width: 40px; height: 40px; }
.modal-header .spacer { width: 40px; }
.modal-copy { color: var(--muted); line-height: 1.45; text-align: center; }

#toast-root { position: fixed; z-index: 100; inset: var(--safe-top) 14px auto; display: grid; justify-items: center; pointer-events: none; }
.toast { max-width: min(92vw, 480px); padding: 12px 16px; border: 1px solid var(--line); border-radius: 999px; background: rgba(35,35,38,.94); box-shadow: var(--shadow); font-size: 13px; font-weight: 800; animation: toast-in .25s ease both; }
.toast.error { color: #ffd6d8; border-color: rgba(255,92,102,.28); background: rgba(94,25,31,.96); }
@keyframes toast-in { from { transform: translateY(-12px); opacity: 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; }
.hidden { display: none !important; }

@media (min-width: 621px) {
    body { background: #09090a; }
    .app-shell { box-shadow: 0 0 0 1px rgba(255,255,255,.05), 0 40px 100px rgba(0,0,0,.5); }
    .card-track { scroll-padding-inline: 150px; padding-left: 150px; padding-right: 150px; }
}

@media (max-height: 720px) {
    .brand-logo { width: 56px; height: 56px; }
    .home-content { gap: 12px; }
    .home-button { min-height: 50px; }
    .prompt-area { min-height: 210px; }
    .answer-card { height: min(53dvh, 370px); }
    .center-avatar { --avatar-size: 92px; margin-bottom: 17px; }
}

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

