/* Penguintrack shell: menus, campaign, HUD, results, replays, tracks,
   settings and help. Builds on the tokens and .pt-* classes in style.css. */

/* ---------- Boot card ---------- */

.pt-boot {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    z-index: 60;
    transition: opacity 0.35s;
}

.pt-boot.out { opacity: 0; pointer-events: none; }
.pt-boot-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 24px; }
.pt-boot-card img { animation: pt-bob 1.6s ease-in-out infinite; }
.pt-boot-title { font-size: 34px; font-weight: 800; letter-spacing: 1px; }
.pt-boot-msg { color: var(--muted); max-width: 420px; }

@keyframes pt-bob {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-8px) rotate(2deg); }
}

/* ---------- Shared bits ---------- */

.pt-ico { display: inline-flex; align-items: center; justify-content: center; flex: none; line-height: 0; }
.pt-icon { display: block; }
.pt-btn .pt-kbd { margin-left: 4px; font-size: 11px; padding: 1px 5px 0; opacity: 0.75; border-bottom-width: 2px; }
.pt-btn.primary .pt-kbd { border-color: rgba(6, 18, 36, 0.4); background: rgba(6, 18, 36, 0.12); color: var(--accent-ink); }
.pt-btn.danger:disabled, .pt-btn:disabled .pt-ico { opacity: 0.6; }
a.pt-btn { text-decoration: none; }

.pt-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 11px; background: var(--sunken); border: var(--border) solid var(--line); }
.pt-seg .pt-btn { --btn-bg: transparent; --btn-line: transparent; box-shadow: none; }
.pt-seg .pt-btn:hover { --btn-bg-hover: var(--panel-2); border-color: var(--line-strong); }
.pt-seg .pt-btn.active { --btn-bg: var(--accent); --btn-bg-hover: var(--accent-2); --btn-line: var(--accent); color: var(--accent-ink); }

.pt-switch {
    appearance: none;
    position: relative;
    width: 50px;
    height: 28px;
    border-radius: 99px;
    border: var(--border) solid var(--line-strong);
    background: var(--sunken);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    flex: none;
}

.pt-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.15s, background 0.15s;
}

.pt-switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent-2); }
.pt-switch[aria-checked="true"]::after { transform: translateX(22px); background: var(--accent-ink); }
.pt-switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.pt-toast { display: inline-flex; align-items: center; gap: 8px; max-width: min(560px, calc(100vw - 32px)); text-align: center; transition: opacity 0.25s, transform 0.25s; }
.pt-toast.out { opacity: 0; transform: translateY(6px); }
.pt-toast-bad { border-color: var(--bad); color: #ffd6dd; }
.pt-toast-good { border-color: #3fae78; }
.pt-toast-gold { border-color: var(--gold); color: #fff3c4; box-shadow: 0 6px 0 var(--accent-shadow); }

.pt-modal-back { animation: pt-fade-in 0.15s ease-out; }
.pt-modal-back.out { opacity: 0; transition: opacity 0.14s; }
.pt-modal { animation: pt-pop-in 0.18s ease-out; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
.pt-modal-msg { margin: 0; line-height: 1.45; color: var(--text); }
.pt-modal-actions { justify-content: flex-end; }
.pt-code { width: 100%; min-height: 96px; word-break: break-all; user-select: text; }
.nogl-icon { color: var(--accent); }

@keyframes pt-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pt-pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* Falling snow over the menus */
.pt-snowfall { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }

.pt-snowfall span {
    position: absolute;
    top: -10px;
    border-radius: 50%;
    background: #fff;
    filter: blur(0.4px);
    animation-name: pt-snow-fall, pt-snow-sway;
    animation-timing-function: linear, ease-in-out;
    animation-iteration-count: infinite, infinite;
    animation-direction: normal, alternate;
}

@keyframes pt-snow-fall { to { top: 105%; } }
@keyframes pt-snow-sway { from { transform: translateX(-14px); } to { transform: translateX(14px); } }
.pt-reduce-motion .pt-snowfall { display: none; }

/* ---------- Logo ---------- */

.pt-logo { display: flex; align-items: center; gap: clamp(6px, 1.5vw, 16px); }
.pt-logo-penguin { flex: none; filter: drop-shadow(0 5px 0 rgba(4, 12, 26, 0.7)); animation: pt-bob 3.2s ease-in-out infinite; }
.pt-logo-penguin svg { width: clamp(72px, 10vw, 132px); height: auto; display: block; }

.pt-logo-word {
    display: flex;
    flex-wrap: nowrap;
    font-size: clamp(34px, 6.6vw, 88px);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: 0.01em;
}

.pt-logo-word span {
    position: relative;
    display: inline-block;
    color: var(--text);
    /* Outline from stacked drop-shadows: text-stroke would trace the font's overlapping contours. */
    filter: drop-shadow(2px 0 0 #061224) drop-shadow(-2px 0 0 #061224) drop-shadow(0 -2px 0 #061224) drop-shadow(0 6px 0 #061224);
    padding-top: 0.08em;
}

.pt-logo-word .pt-logo-b { color: var(--accent); }

/* Snow piled on the letters: a white copy of the word, masked to a wavy top band. */
.pt-logo-word span::after {
    content: attr(data-snow);
    position: absolute;
    inset: 0;
    padding-top: inherit;
    color: #ffffff;
    background: none;
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 100' preserveAspectRatio='none'><path d='M0 0H120V36C113 42 108 33 101 39S88 45 81 37 69 44 61 38 48 46 41 38 29 44 21 37 9 43 0 37Z' fill='black'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 100' preserveAspectRatio='none'><path d='M0 0H120V36C113 42 108 33 101 39S88 45 81 37 69 44 61 38 48 46 41 38 29 44 21 37 9 43 0 37Z' fill='black'/></svg>");
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    filter: none;
    pointer-events: none;
}

/* ---------- Menu ---------- */

.menu-screen {
    background:
        linear-gradient(90deg, rgba(6, 18, 40, 0.88) 0%, rgba(6, 18, 40, 0.62) 38%, rgba(6, 18, 40, 0.08) 72%, rgba(6, 18, 40, 0) 100%),
        linear-gradient(0deg, rgba(6, 18, 40, 0.55), rgba(6, 18, 40, 0) 30%);
}

.menu-screen > * { position: relative; z-index: 1; }
.menu-screen > .pt-snowfall { position: absolute; z-index: 0; }
.menu-top { display: flex; align-items: center; gap: 10px; }
.menu-site { color: var(--muted); }
.menu-support .pt-ico { color: #ff7aa8; }

.menu-account { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 99px; }
.menu-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    background: var(--accent);
    color: var(--accent-ink);
    border: var(--border) solid var(--accent-2);
    flex: none;
}
.menu-account.guest .menu-avatar { background: var(--panel-2); border-color: var(--line-strong); color: var(--accent-2); }
.menu-account-name { font-weight: 800; line-height: 1.1; }
.menu-account-gold { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

.res-coin {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 0 0 1.5px rgba(0, 0, 0, 0.35);
    flex: none;
}

.menu-main { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.menu-tag { margin: -4px 0 6px; color: var(--accent-2); font-weight: 600; font-size: clamp(15px, 1.6vw, 19px); text-shadow: 0 2px 0 var(--btn-shadow); }
.menu-nav { display: flex; flex-direction: column; gap: 12px; max-width: 540px; }
.menu-play { width: 100%; max-width: 540px; font-size: 26px; padding: 16px 26px 13px; }
.menu-play-row { display: flex; gap: 10px; }
.menu-play-row .menu-play { flex: 1.5; min-width: 0; }
.menu-friends { --btn-bg: #1f6b50; --btn-bg-hover: #278462; --btn-line: #3fae78; --btn-drop: #0b2c20; flex: 1; min-width: 0; font-size: 19px; padding: 12px 14px 9px; }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.menu-item { --btn-bg: var(--panel); --btn-line: var(--line); justify-content: flex-start; gap: 12px; padding: 10px 14px 8px; text-align: left; }
.menu-item .pt-ico { color: var(--accent); }
.menu-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.menu-item-label { font-size: 17px; }
.menu-item-hint { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-foot { display: flex; align-items: flex-end; gap: 12px; font-size: 13px; }
.menu-showing { display: flex; align-items: center; gap: 6px; text-shadow: 0 1px 0 var(--btn-shadow), 0 0 3px var(--bg); }
.menu-keys .pt-kbd { font-size: 11px; }
[data-input="touch"] .menu-keys, [data-input="touch"] .camp-keys { display: none; }

/* ---------- Generic list screens (replays, my tracks, settings, help) ---------- */

.replays-screen, .mytracks-screen, .settings-screen, .help-screen, .campaign-screen {
    background: rgba(7, 19, 38, 0.86);
    gap: 14px;
}

.list-head, .camp-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.list-head .pt-title, .camp-head .pt-title { margin-right: 6px; }
.list-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 6px; }
.rep-list { flex: 1; min-height: 0; padding: 4px 10px 10px; }
.list-section { margin: 16px 4px 8px; font-size: 15px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent-2); }
.list-section:first-child { margin-top: 8px; }
.list-empty { margin: 0 4px 10px; }

.list-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--line);
    background: var(--bg-2);
    margin-bottom: 6px;
}

.list-row:hover, .list-row:focus-within { border-color: var(--line-strong); background: var(--panel-2); }
.list-row.stale { opacity: 0.7; }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row-sub { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.list-row-mood { color: var(--accent-2); }
.list-blank { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 16px; }
.list-blank-icon { color: var(--accent); opacity: 0.85; }
.list-blank p { margin: 0 0 8px; max-width: 420px; }

/* ---------- Campaign ---------- */

.camp-tabs { display: flex; gap: 6px; padding: 4px; border-radius: 12px; background: var(--sunken); border: var(--border) solid var(--line); }
.camp-tab { --btn-bg: transparent; --btn-line: transparent; box-shadow: none; }
.camp-tab.active { --btn-bg: var(--accent); --btn-bg-hover: var(--accent-2); --btn-line: var(--accent-2); --btn-drop: var(--accent-shadow); color: var(--accent-ink); box-shadow: 0 3px 0 var(--btn-drop); }
.camp-tab .pt-ico { opacity: 0.85; }
.camp-keys { font-size: 13px; }
.camp-keys .pt-kbd { margin-right: 2px; font-size: 11px; }
.camp-main { flex: 1; min-height: 0; display: flex; gap: 18px; }
.camp-body { flex: 1; min-width: 0; padding: 2px 8px 24px 2px; }
.camp-tier { margin-bottom: 20px; }
.camp-tier-head { display: flex; align-items: center; gap: 10px; margin: 0 0 10px 2px; }
.camp-tier-swatch { width: 16px; height: 16px; border-radius: 5px; background: var(--tier); border: 2px solid var(--line-strong); flex: none; }
.camp-tier-name { margin: 0; font-size: 20px; font-weight: 800; }
.camp-tier-progress { font-size: 13px; }
/* Five tracks per tier, five to a row, like a Trackmania campaign sheet. */
.camp-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }

.camp-card {
    appearance: none;
    text-align: left;
    font: inherit;
    color: var(--text);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px 10px;
    min-height: 104px;
    border-radius: var(--radius-sm);
    border: var(--border) solid var(--line);
    border-top: 6px solid var(--tier);
    /* Solid layered surface: the card, a darker footer band, a hard drop. */
    background: var(--panel-2);
    box-shadow: inset 0 -30px 0 var(--panel), 0 4px 0 var(--btn-shadow);
    transition: transform 0.06s, border-color 0.12s, box-shadow 0.06s;
}

.camp-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: inset 0 -30px 0 var(--panel), 0 6px 0 var(--btn-shadow); }
.camp-card:focus-visible { border-color: var(--accent); outline: 2px solid var(--focus); outline-offset: 3px; }
.camp-card:active { transform: translateY(3px); box-shadow: inset 0 -30px 0 var(--panel), 0 1px 0 var(--btn-shadow); }
.camp-card-top { display: flex; align-items: center; justify-content: space-between; }
.camp-card-id { font-size: 13px; font-weight: 800; color: var(--accent-2); }
.camp-card-mood { color: var(--muted); }
.camp-card-name { font-weight: 800; font-size: 17px; line-height: 1.15; flex: 1; }
.camp-card-foot { display: flex; align-items: center; gap: 7px; font-size: 14px; flex-wrap: wrap; }
.camp-card-pb { color: var(--muted); }
.camp-card.has-emperor { background: #1b4670; }
.camp-card.has-emperor .camp-card-pb, .camp-card.has-gold .camp-card-pb { color: var(--text); }

.camp-detail { width: 300px; flex: none; align-self: flex-start; display: flex; flex-direction: column; gap: 10px; max-height: 100%; overflow-y: auto; }
.camp-detail.empty { visibility: hidden; }
.camp-detail-head { display: flex; align-items: center; gap: 8px; padding-left: 10px; border-left: 4px solid var(--tier); }
.camp-detail-tier { color: var(--muted); font-size: 13px; font-weight: 700; }
.camp-detail-name { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.1; }
.camp-detail-desc { margin: 0; font-size: 14px; line-height: 1.4; }
.camp-detail-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.camp-detail-meta .pt-tag .pt-icon { width: 14px; height: 14px; }
.camp-detail-pb { display: flex; align-items: center; gap: 8px; font-size: 15px; padding: 8px 10px; border-radius: var(--radius-sm); background: rgba(4, 14, 32, 0.45); }
.camp-detail-pb .pt-mono { font-weight: 800; margin-left: auto; }
.camp-targets { display: flex; flex-direction: column; gap: 4px; }
.camp-target { display: grid; grid-template-columns: 20px auto 1fr auto; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; font-size: 15px; }
.camp-target-text { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.camp-target.got { opacity: 0.55; }
.camp-target.next { background: var(--panel-2); box-shadow: inset 0 0 0 1.5px var(--accent); opacity: 1; }
.camp-next { font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--accent); }
.camp-go { width: 100%; }
.camp-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.camp-actions .pt-btn { min-width: 0; justify-content: center; padding-left: 10px; padding-right: 10px; white-space: nowrap; }

/* Three-category leaderboard (js/game/leaderboard.js) */
.lb { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: var(--radius-sm); background: rgba(4, 14, 32, 0.45); }
.lb-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.lb-tab { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 5px 4px 3px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; line-height: 1.2; }
.lb-tab .lb-dot { margin-bottom: 2px; }
.lb-tab:hover, .lb-tab:focus-visible { color: var(--text); border-color: var(--line-strong); outline: none; }
.lb-tab.active { color: var(--text); border-color: var(--ghost); background: var(--panel-2); box-shadow: inset 0 -3px 0 var(--ghost); }
.lb-best { font-size: 11px; font-weight: 700; color: var(--muted); }
.lb-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ghost); flex: none; }
.lb-hint { margin: 2px 2px 0; font-size: 12px; line-height: 1.3; }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.lb-row { display: grid; grid-template-columns: 16px auto 1fr auto; align-items: baseline; gap: 6px; padding: 3px 6px; border-radius: 6px; font-size: 13px; }
.lb-row.lead { background: var(--panel-2); }
.lb-row.lead .lb-time { font-weight: 800; }
.lb-rank { color: var(--muted); font-size: 12px; }
.lb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.lb-resp, .lb-date { font-size: 11px; white-space: nowrap; }
.lb-resp { grid-column: 3; }
.lb-empty { margin: 4px 2px; font-size: 13px; line-height: 1.35; }
.lb-foot { display: flex; justify-content: flex-end; }
.lb-ghost { gap: 6px; }
.lb-ghost .lb-dot { opacity: 0.35; }
.lb-ghost[aria-pressed="true"] { border-color: var(--ghost); }
.lb-ghost[aria-pressed="true"] .lb-dot { opacity: 1; }


/* ---------- Settings ---------- */

.set-body { flex: 1; min-height: 0; padding: 4px 14px 16px; display: flex; flex-wrap: wrap; gap: 0 32px; align-content: flex-start; }
.set-col { flex: 1 1 380px; min-width: 0; }
.set-section { padding: 8px 0 10px; }
.set-title { display: flex; align-items: center; gap: 8px; margin: 8px 0 6px; font-size: 17px; color: var(--accent-2); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid rgba(200, 230, 255, 0.07); min-height: 44px; }
.set-label { display: flex; flex-direction: column; font-weight: 700; }
.set-hint { font-size: 12px; font-weight: 600; color: var(--muted); }
.set-control { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.set-control input[type="range"] { width: 160px; }
.set-value { min-width: 46px; text-align: right; color: var(--muted); font-size: 13px; }
.set-note { margin: 0 0 6px; font-size: 13px; }
.set-key { min-width: 64px; font-family: var(--mono); }
.set-key.capturing { border-color: var(--warn); color: var(--warn); animation: pt-pulse 1s ease-in-out infinite; }
.set-key-clear { padding: 6px 7px; }
.set-saved { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.set-quick .pt-row { flex-wrap: nowrap; }
.set-quick-body { max-height: min(62vh, 520px); padding-right: 6px; }
.set-quick-body .set-control input[type="range"] { width: 130px; }
.set-modal { max-width: min(520px, 100%); }

@keyframes pt-pulse { 50% { box-shadow: 0 0 0 3px rgba(255, 207, 90, 0.25); } }

/* ---------- Help ---------- */

.help-body { flex: 1; min-height: 0; padding-right: 6px; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; align-items: start; padding-bottom: 16px; }
.help-section .set-title { margin-top: 0; }
.help-section p { line-height: 1.45; }
.help-small { font-size: 13px; }
.help-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.help-table th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; padding: 4px 6px; }
.help-table td { padding: 5px 6px; border-top: 1px solid rgba(200, 230, 255, 0.07); }
.help-table .pt-kbd { margin-right: 4px; }
.help-medals { display: flex; flex-direction: column; gap: 6px; }
.help-medal { display: grid; grid-template-columns: 22px 80px 1fr auto; gap: 8px; align-items: center; }
.help-gold { font-weight: 800; color: var(--gold); font-size: 14px; }
.help-list { display: flex; flex-direction: column; gap: 10px; }
.help-item { display: flex; gap: 12px; align-items: flex-start; }
.help-item p { margin: 2px 0 0; font-size: 14px; }
.help-swatch { width: 28px; height: 28px; border-radius: 8px; flex: none; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.3); }
.help-pad { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex: none; }
.help-item.tip { padding-left: 10px; border-left: 3px solid var(--accent); }

/* Effect tones: help pads, and HUD chips (on a dark base so they read over bright snow) */
.help-pad.boost { background: rgba(127, 220, 255, 0.22); color: #c8f4ff; }
.help-pad.bad { background: rgba(255, 107, 129, 0.2); color: #ffd0d8; }
.help-pad.cool { background: rgba(184, 241, 255, 0.16); color: var(--accent-2); }
.help-pad.warn { background: rgba(255, 207, 90, 0.2); color: #ffeab0; }
.hud-effect.boost { color: #8fe6ff; border-color: rgba(127, 220, 255, 0.75); }
.hud-effect.bad { color: #ffb3c0; border-color: rgba(255, 107, 129, 0.8); }
.hud-effect.cool { color: #d4f6ff; border-color: rgba(184, 241, 255, 0.6); }
.hud-effect.warn { color: #ffe08a; border-color: rgba(255, 207, 90, 0.75); }

/* ---------- Screen unavailable (lazy screen failed to load) ---------- */

.soon-screen { align-items: center; justify-content: center; background: rgba(7, 19, 38, 0.84); }
.soon-card { position: relative; z-index: 1; max-width: 520px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 28px 24px; }
.soon-icon { color: var(--accent); width: 92px; height: 92px; border-radius: 22px; display: flex; align-items: center; justify-content: center; background: var(--panel-2); border: var(--border) solid var(--line-strong); box-shadow: 0 5px 0 var(--btn-shadow); margin-bottom: 6px; }
.soon-lead { margin: 0; font-size: 18px; font-weight: 700; }
.soon-card p { margin: 0; }
.soon-actions { margin-top: 12px; justify-content: center; }
.soon-error { max-width: 100%; overflow: auto; font: 12px/1.4 var(--mono); color: #ffd0d8; background: rgba(4, 14, 32, 0.6); padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; text-align: left; }

/* ---------- Play: HUD ---------- */

.play-screen { padding: 0; }
.pt-hud { position: absolute; inset: 0; pointer-events: none; color: var(--text); text-shadow: 0 2px 0 rgba(4, 12, 26, 0.75); }
.pt-hud .pt-panel { pointer-events: none; }

.hud-tl { position: absolute; left: 16px; top: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.hud-track { padding: 6px 12px 6px 10px; border-left: 4px solid var(--accent); background: rgba(7, 19, 38, 0.78); border-radius: 0 8px 8px 0; }
.hud-track-name { font-weight: 800; font-size: 18px; line-height: 1.1; }
.hud-track-sub { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.hud-minimap { border-radius: 14px; background: rgba(7, 19, 38, 0.55); border: var(--border) solid var(--line); box-shadow: var(--shadow); }

.hud-tc { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hud-chips { display: flex; gap: 8px; }
.hud-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 18px; padding: 5px 14px 3px; border-radius: 99px; background: rgba(6, 18, 40, 0.62); border: 1px solid var(--line); }
.hud-chip .pt-icon { color: var(--accent); }

.hud-split { display: flex; flex-direction: column; align-items: center; padding: 6px 18px 4px; border-radius: 14px; background: rgba(6, 18, 40, 0.72); border: 1px solid var(--line-strong); }
.hud-split.pop { animation: hud-pop 0.25s ease-out; }
.hud-split-time { font-size: 20px; font-weight: 800; }
.hud-split-diff { font-size: 26px; font-weight: 800; line-height: 1; }
.hud-split-diff:empty { display: none; }
.ahead { color: #6fb8ff; }
.even { color: var(--text); }
.behind { color: #ff6b81; }

.hud-tr { position: absolute; right: 16px; top: 14px; }
.hud-medals { padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; min-width: 186px; background: rgba(6, 18, 40, 0.6); }
.hud-medal-row { display: grid; grid-template-columns: 20px 1fr auto 14px; align-items: center; gap: 8px; font-size: 14px; padding: 2px 4px; border-radius: 7px; }
.hud-medal-row .pt-medal { width: 16px; height: 16px; }
.hud-medal-row.got { opacity: 0.55; }
.hud-medal-row.next { background: rgba(14, 34, 64, 0.85); box-shadow: inset 0 0 0 1.5px var(--accent); opacity: 1; }
.hud-medal-label { font-weight: 700; }
.hud-medal-time { font-weight: 800; font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-medal-check { color: var(--good); }

.hud-bc { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud-timer { font-size: clamp(36px, 5vw, 58px); font-weight: 800; letter-spacing: 1px; line-height: 1; padding: 6px 22px 2px; border-radius: 16px; background: rgba(6, 18, 40, 0.5); }
.hud-pb { font-size: 14px; font-weight: 800; color: var(--accent-2); padding: 1px 10px 0; border-radius: 99px; background: rgba(6, 18, 40, 0.5); }
.hud-effects { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 6px; }
.hud-effect { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 3px 8px; border-radius: 99px; font-weight: 800; font-size: 15px; background: rgba(6, 18, 40, 0.78); border: 1.5px solid var(--line-strong); text-shadow: none; animation: hud-pop 0.25s ease-out; }

.hud-br { position: absolute; right: 18px; bottom: 12px; }
.hud-speedo { position: relative; width: 156px; height: 156px; }
.hud-speedo::before { content: ""; position: absolute; inset: 16px; border-radius: 50%; background: radial-gradient(circle, rgba(6, 18, 40, 0.62) 0%, rgba(6, 18, 40, 0.42) 70%, rgba(6, 18, 40, 0) 72%); }
.hud-dial { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 3px 8px rgba(0, 10, 30, 0.6)); }
.hud-dial path { fill: none; stroke-linecap: round; }
.hud-dial-bg { stroke: rgba(6, 18, 40, 0.65); stroke-width: 11; }
.hud-dial-red { stroke: rgba(255, 107, 129, 0.45); stroke-width: 4; }
.hud-dial-rpm { stroke: var(--accent); stroke-width: 7; transition: stroke 0.15s; }
.hud-dial-rpm.hot { stroke: #ffb3c0; }
.hud-speed-read { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hud-speed-num { font-size: 44px; font-weight: 800; line-height: 1; }
.hud-speed-unit { font-size: 13px; font-weight: 800; color: var(--accent-2); }
.hud-gear-wrap { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; align-items: baseline; gap: 4px; font-size: 11px; color: var(--accent-2); font-weight: 800; text-transform: uppercase; padding: 0 8px; border-radius: 99px; background: rgba(6, 18, 40, 0.6); }
.hud-gear { font-size: 22px; color: var(--text); font-weight: 800; }

.hud-banner {
    position: absolute;
    left: 50%;
    top: 24%;
    transform: translateX(-50%);
    font-size: clamp(22px, 3.2vw, 36px);
    font-weight: 800;
    padding: 8px 24px 5px;
    border-radius: 16px;
    background: rgba(6, 18, 40, 0.72);
    border: 1px solid var(--line-strong);
    white-space: pre;
}

.hud-banner.bad { border-color: var(--bad); color: #ffd0d8; background: rgba(60, 10, 26, 0.75); }
.hud-banner.lap { border-color: var(--accent); }
.hud-banner.finish { font-size: clamp(34px, 5vw, 60px); top: 30%; border-color: var(--accent); }
.hud-banner.finish.ahead { color: #ffffff; border-color: #6fb8ff; box-shadow: 0 6px 0 #1d4f86; }
.hud-banner.finish.behind { color: #ffffff; }

.hud-count {
    position: absolute;
    left: 50%;
    top: 36%;
    transform: translate(-50%, -50%);
    font-size: clamp(90px, 16vw, 180px);
    font-weight: 800;
    line-height: 1;
    color: #ffffff;
    -webkit-text-stroke: 3px #0b2546;
    text-shadow: 0 8px 0 #0b2546, 0 16px 30px rgba(0, 10, 30, 0.6);
}

.hud-count.pop { animation: hud-pop-c 0.5s ease-out; }
.hud-count.go { color: var(--good); }

@keyframes hud-pop { from { transform: scale(0.9); opacity: 0.2; } to { transform: none; opacity: 1; } }
@keyframes hud-pop-c { from { transform: translate(-50%, -50%) scale(1.5); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.hud-banner.pop { animation: hud-pop-x 0.3s ease-out; }
@keyframes hud-pop-x { from { transform: translateX(-50%) scale(0.85); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }

.play-autopilot { position: absolute; left: 16px; bottom: 16px; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 800; padding: 3px 10px 1px; border-radius: 99px; background: rgba(40, 28, 4, 0.72); color: var(--warn); border: 1px solid rgba(255, 207, 90, 0.5); pointer-events: none; text-shadow: none; }

/* Pause menu */
.play-pause { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(4, 12, 28, 0.7); pointer-events: auto; animation: pt-fade-in 0.15s ease-out; }
.play-pause-panel { width: min(380px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 16px; padding: 22px; animation: pt-pop-in 0.18s ease-out; }
.play-pause-head .pt-title { font-size: 36px; }
.play-pause .pt-btn.big { justify-content: flex-start; width: 100%; font-size: 20px; padding: 13px 18px 10px; }
.play-pause .pt-btn .pt-kbd { margin-left: auto; }
.play-pause-hint { font-size: 12px; text-align: center; line-height: 1.9; }
.play-ghosts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; font-size: 13px; }
.play-ghost-chip { gap: 6px; }
.play-ghost-chip .play-ghost-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ghost); opacity: 0.35; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4); }
.play-ghost-chip[aria-pressed="true"] { border-color: var(--ghost); }
.play-ghost-chip[aria-pressed="true"] .play-ghost-dot { opacity: 1; }
.play-quicktas { position: absolute; left: 16px; bottom: 16px; min-width: 210px; padding: 8px 12px 6px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; font-size: 13px; border-color: var(--line-strong); }
.play-quicktas .qt-head { display: flex; gap: 6px; align-items: center; color: var(--accent); }
.play-quicktas .qt-state { margin-left: auto; font-size: 11px; font-weight: 800; padding: 1px 8px 0; border-radius: 99px; background: rgba(107, 255, 176, 0.16); color: var(--good); }
.play-quicktas.used .qt-state { background: rgba(255, 122, 217, 0.18); color: #ff9be3; }
.play-quicktas .qt-info { font-size: 14px; color: var(--text); }
.play-quicktas .qt-keys { font-size: 11px; }
.play-quicktas .qt-keys .pt-kbd { font-size: 10px; margin-right: 2px; }
.pt-touch-on .play-quicktas { bottom: 150px; }
.play-pause-hint .pt-kbd { font-size: 11px; }

/* Replay viewer */
.pt-hud.replay .hud-tr { display: none; }
.pt-hud.replay .hud-bc { bottom: 132px; }
.pt-hud.replay .hud-br { bottom: 126px; }
.replay-ui { position: absolute; inset: 0; pointer-events: none; }
.replay-info { position: absolute; right: 16px; top: 14px; pointer-events: auto; max-width: 320px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.replay-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
.replay-title { font-size: 18px; font-weight: 800; line-height: 1.15; }
.replay-info .pt-muted { font-size: 13px; }
.replay-bar { position: absolute; left: 16px; right: 16px; bottom: 14px; pointer-events: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; }
.replay-row { display: flex; align-items: center; gap: 10px; }
.replay-row.wrap { flex-wrap: wrap; }
.replay-play { width: 46px; height: 42px; padding: 0; }
.replay-time { font-weight: 800; font-size: 15px; white-space: nowrap; min-width: 150px; text-align: center; }
.replay-track { position: relative; flex: 1; min-width: 120px; display: flex; align-items: center; height: 30px; }
.replay-scrub { width: 100%; margin: 0; }
.replay-marks { position: absolute; left: 8px; right: 8px; top: 0; height: 8px; pointer-events: none; }
.replay-mark { position: absolute; top: 0; width: 3px; height: 8px; margin-left: -1px; border-radius: 2px; background: #5aa8ff; }
.replay-mark.respawn { background: var(--warn); }
.replay-mark.finish { background: #fff; width: 4px; }
.replay-mark.lap { background: var(--good); }

/* ---------- Touch controls ---------- */

.pt-touch { position: fixed; inset: 0; z-index: 30; pointer-events: none; touch-action: none; }
.pt-touch-left, .pt-touch-right, .pt-touch-top { position: absolute; display: flex; gap: 14px; pointer-events: none; }
.pt-touch-left { left: max(18px, env(safe-area-inset-left)); bottom: 22px; }
.pt-touch-right { right: max(18px, env(safe-area-inset-right)); bottom: 22px; align-items: flex-end; }
.pt-touch-top { right: max(16px, env(safe-area-inset-right)); top: 12px; gap: 10px; }
.pt-touch-col { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.pt-touch-tas { position: absolute; right: max(16px, env(safe-area-inset-right)); top: 76px; display: none; gap: 10px; pointer-events: none; }
.pt-touch.tas .pt-touch-tas { display: flex; }

.pt-touch-btn {
    pointer-events: auto;
    appearance: none;
    border: 2px solid rgba(220, 240, 255, 0.45);
    background: rgba(12, 30, 60, 0.45);
    color: #fff;
    font: 800 18px var(--font);
    border-radius: 50%;
    width: 84px;
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 0 rgba(4, 12, 26, 0.6);
}

.pt-touch-btn.down { background: rgba(245, 183, 56, 0.55); border-color: #fff; transform: translateY(3px); }
.pt-touch-btn.gas { width: 104px; height: 104px; background: rgba(60, 170, 110, 0.4); border-color: rgba(160, 255, 200, 0.6); }
.pt-touch-btn.brake { background: rgba(170, 50, 70, 0.4); border-color: rgba(255, 170, 185, 0.6); }
.pt-touch-btn.small { width: 52px; height: 52px; }
.pt-touch-on .hud-br { right: 150px; bottom: 140px; transform: scale(0.8); transform-origin: bottom right; }
.pt-touch-on .hud-tr { display: none; }
.pt-touch-on .hud-bc { bottom: 10px; }

/* ---------- Results ---------- */

.results-screen { align-items: center; justify-content: center; background: rgba(7, 19, 38, 0.6); }
.res-panel { width: min(900px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 14px; padding: 20px 24px; animation: pt-pop-in 0.25s ease-out; overflow: hidden; }
.res-kicker { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); }
.res-track { margin: 2px 0 0; font-size: clamp(24px, 3vw, 34px); font-weight: 800; line-height: 1.05; }
.res-body { display: flex; gap: 22px; min-height: 0; flex: 1; }
.res-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.res-time { font-size: clamp(48px, 7vw, 76px); font-weight: 800; line-height: 1; letter-spacing: 1px; }
.res-diff { display: flex; align-items: baseline; gap: 10px; font-size: 24px; font-weight: 800; flex-wrap: wrap; }
.res-diff-label { font-size: 16px; color: var(--text); }
.res-diff.ahead .res-diff-label { color: #9fd0ff; }
.res-diff.first .res-diff-label { color: var(--accent-2); }
.res-stats { display: flex; gap: 14px; flex-wrap: wrap; }
.res-stats:empty { display: none; }
.res-stat, .res-gold { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.res-board.cat-pure { color: #cfeaff; }
.res-board.cat-tas { color: #ff9be3; }
.res-board.cat-ai { color: #9dffb8; }
.res-note { margin: 0; font-size: 13px; }
.pt-tag.res-tas-tag { color: #ff9be3; border-color: rgba(255, 122, 217, 0.5); }
.res-gold { color: var(--gold); }

.res-medal-big { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.res-medal-big .pt-medal.big { width: 64px; height: 64px; border-width: 4px; }
.res-medal-big.in .pt-medal.big { animation: res-medal-in 0.7s cubic-bezier(0.2, 1.4, 0.4, 1); }
.res-medal-big.in.emperor .pt-medal.big { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--emperor), inset 0 -4px 0 rgba(0, 0, 0, 0.22); }
.res-medal-big.in.gold .pt-medal.big { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--gold), inset 0 -4px 0 rgba(0, 0, 0, 0.22); }
.res-medal-big.wait { opacity: 0; }
.res-medal-name { font-size: 22px; font-weight: 800; }
.res-medal-big.none .res-medal-name { color: var(--muted); font-size: 18px; }
.res-medal-big.emperor .res-medal-name { color: var(--emperor); }
.res-medal-big.gold .res-medal-name { color: var(--gold); }
.res-medal-big.silver .res-medal-name { color: var(--silver); }
.res-medal-big.bronze .res-medal-name { color: var(--bronze); }

@keyframes res-medal-in {
    0% { transform: scale(0.2) rotateY(180deg); opacity: 0; }
    60% { transform: scale(1.2) rotateY(0deg); opacity: 1; }
    100% { transform: scale(1); }
}

.res-ladder { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.res-step { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; border-radius: var(--radius-sm); background: rgba(4, 14, 32, 0.45); border: 1px solid var(--line); opacity: 0.55; transition: opacity 0.2s, transform 0.2s, border-color 0.2s; }
.res-step .pt-medal { filter: grayscale(0.7); }
.res-step.got { opacity: 1; }
.res-step.got .pt-medal { filter: none; }
.res-step.wait { opacity: 0.55; }
.res-step.wait .pt-medal { filter: grayscale(0.7); }
.res-step.lit { animation: res-lit 0.35s ease-out; border-color: var(--line-strong); }
.res-step-name { font-size: 13px; font-weight: 800; }
.res-step-time { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.3; }

@keyframes res-lit { 50% { transform: translateY(-4px); } }

.res-side { width: 280px; flex: none; display: flex; flex-direction: column; min-height: 0; }
.res-side-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin-bottom: 6px; }
.res-splits { flex: 1; min-height: 0; border-radius: var(--radius-sm); background: rgba(4, 14, 32, 0.45); border: 1px solid var(--line); }
.res-splits table { width: 100%; border-collapse: collapse; font-size: 15px; }
.res-splits td { padding: 6px 10px; border-bottom: 1px solid rgba(200, 230, 255, 0.07); }
.res-splits td:nth-child(2), .res-splits td:nth-child(3) { text-align: right; }
.res-splits tr.fin td { font-weight: 800; border-bottom: 0; }
.res-splits tr.lap td { color: var(--accent-2); }
.res-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.res-actions .pt-btn:last-child { margin-left: auto; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .camp-detail { width: 260px; }
    .camp-card { padding: 9px 10px; }
    .camp-card-name { font-size: 15px; }
}

@media (max-width: 900px) {
    .camp-cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .camp-main { flex-direction: column; }
    .camp-detail { display: none; }
    .res-side { width: 220px; }
    .list-row { flex-wrap: wrap; }
    .list-row-actions { width: 100%; justify-content: flex-start; }
    .help-grid { grid-template-columns: 1fr; }
}

@media (max-height: 640px) {
    .pt-screen { padding-top: 14px; padding-bottom: 14px; }
    .menu-main { gap: 8px; }
    .menu-play { font-size: 22px; padding: 12px 20px 10px; }
    .menu-friends { font-size: 17px; padding: 10px 12px 8px; }
    .menu-item { padding: 7px 12px 5px; }
    .menu-item-hint { display: none; }
    .pt-logo-word { font-size: clamp(36px, 5.6vw, 70px); }
    .pt-logo-penguin svg { width: clamp(60px, 8vw, 100px); }
    .hud-speedo { width: 128px; height: 128px; }
    .hud-speed-num { font-size: 36px; }
    .hud-medals { min-width: 168px; padding: 6px 8px; }
    .hud-medal-row { font-size: 13px; }
    .res-panel { padding: 14px 18px; gap: 10px; }
    .res-time { font-size: clamp(40px, 6vw, 60px); }
    .res-medal-big .pt-medal.big { width: 48px; height: 48px; }
}

@media (max-height: 460px) {
    .menu-tag { display: none; }
    .menu-top { position: absolute; top: 10px; left: 16px; right: 16px; }
    .menu-main { max-width: none; flex-direction: row; align-items: center; gap: 20px; }
    .pt-logo { flex-direction: column; align-items: flex-start; gap: 0; }
    .pt-logo-penguin { display: none; }
    .pt-logo-word { font-size: 40px; flex-direction: column; }
    .menu-nav { flex: 1; gap: 8px; }
    .menu-play { font-size: 20px; padding: 9px 16px 7px; }
    .menu-friends { font-size: 15px; padding: 8px 10px 6px; }
    .menu-grid { grid-template-columns: 1fr 1fr 1fr 1fr; gap: 6px; }
    .menu-item { flex-direction: column; gap: 2px; padding: 6px 4px 4px; text-align: center; justify-content: center; }
    .menu-item-label { font-size: 13px; }
    .menu-foot { display: none; }
    .pt-title { font-size: 26px; }
    .hud-minimap { display: none; }
    .hud-tl .hud-track-sub { display: none; }
    .hud-tr { display: none; }
    .hud-speedo { width: 110px; height: 110px; }
    .hud-speed-num { font-size: 30px; }
    .hud-timer { font-size: 32px; }
    .res-body { flex-direction: row; }
    .res-side { display: none; }
    .res-ladder { display: none; }
    .res-panel { padding: 10px 14px; gap: 6px; }
    .res-time { font-size: 40px; }
    .replay-info { display: none; }
    .pt-hud.replay .hud-bc { bottom: 108px; }
    .pt-hud.replay .hud-br { bottom: 102px; }
    .replay-bar { padding: 6px 10px; gap: 4px; }
    .pt-touch-btn { width: 70px; height: 70px; }
    .pt-touch-btn.gas { width: 86px; height: 86px; }
    .pt-touch-btn.small { width: 44px; height: 44px; }
}
