* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0f1419;
    --bg-card: #1a2030;
    --bg-elevated: #232a3d;
    --text: #e8eaed;
    --text-muted: #8a93a8;
    --accent: #4f8cff;
    --accent-hover: #6ba3ff;
    --success: #4ade80;
    --error: #ef4444;
    --warning: #fbbf24;
    --border: #2d3548;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 0 0 2rem 0;
    line-height: 1.5;
}

.container {
    padding: 0 1rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
    position: relative;
}

.topbar .brand {
    display: inline-flex;
    align-items: center;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.125rem;
}

.topbar .brand img {
    height: 30px;
    width: auto;
    display: block;
}

.topbar .brand:hover {
    opacity: 0.85;
}

.topbar-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-elevated);
    color: var(--text);
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-weight: 500;
    font-size: 0.95rem;
}

.topbar-menu-btn:hover {
    border-color: var(--accent);
}

.topbar-avatar {
    font-size: 1.4rem;
    line-height: 1;
}

.caret {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.dropdown {
    position: absolute;
    top: 100%;
    right: 1.5rem;
    margin-top: 0.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 180px;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.dropdown a,
.dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.95rem;
    cursor: pointer;
}

.dropdown a:hover,
.dropdown button:hover {
    background: var(--bg-elevated);
}

.dropdown button {
    color: var(--error);
}

.status.success {
    color: var(--success);
}

.welcome-banner {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin: 0 auto 1.25rem auto;
    padding: 0.9rem 1.1rem;
    max-width: 440px;
    background: linear-gradient(135deg, rgba(79, 140, 255, 0.12), rgba(74, 222, 128, 0.06));
    border: 1px solid var(--border);
    border-radius: 14px;
}

.welcome-avatar {
    font-size: 2.1rem;
    line-height: 1;
    width: 52px;
    height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: 12px;
    border: 2px solid var(--accent);
    flex-shrink: 0;
}

.welcome-text {
    min-width: 0;
}

.welcome-greet {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.1;
}

.welcome-name {
    font-size: 1.15rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.1rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 360px;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.history-row {
    display: grid;
    grid-template-columns: 50px 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border-radius: 8px;
    border-left: 3px solid var(--border);
}

.history-row.win {
    border-left-color: var(--warning);
}

.history-position {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--accent);
    text-align: center;
}

.history-row.win .history-position {
    color: var(--warning);
}

.history-meta {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.history-date {
    font-weight: 500;
    color: var(--text);
}

.history-stats {
    text-align: right;
    color: var(--text);
    font-weight: 500;
}

.history-stats small {
    color: var(--text-muted);
    font-weight: normal;
}

.history-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 1.5rem;
}

.profile-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.profile-header {
    margin-bottom: 1.5rem;
}

.profile-identity {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.profile-avatar-big {
    font-size: 3rem;
    line-height: 1;
    width: 80px;
    height: 80px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border-radius: 16px;
    border: 2px solid var(--accent);
}

.profile-header h1 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.profile-rating {
    color: var(--text-muted);
}

.profile-rating #profile-rating {
    color: var(--warning);
    font-weight: 700;
    font-size: 1.25rem;
}

.profile-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.ptab {
    background: none;
    color: var(--text-muted);
    padding: 0.75rem 1.25rem;
    border-radius: 8px 8px 0 0;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-weight: 500;
    font-size: 0.95rem;
}

.ptab:hover {
    color: var(--text);
    background: var(--bg-card);
}

.ptab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--bg-card);
}

.ppane {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
}

.kpi-rating {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(79, 140, 255, 0.08));
    border-color: rgba(251, 191, 36, 0.3);
}

.kpi-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
}

.kpi-rating .kpi-value {
    background: linear-gradient(135deg, var(--warning), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.kpi-sub {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.4rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

.dash-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.dash-card.span-2 {
    grid-column: span 2;
}

@media (max-width: 900px) {
    .dash-card.span-2 { grid-column: span 1; }
}

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
}

.dash-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.chart-wrap {
    height: 260px;
    position: relative;
}

.leaderboard {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.leaderboard li {
    display: grid;
    grid-template-columns: 40px 32px 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-elevated);
    border-radius: 8px;
}

.leaderboard li.me {
    background: rgba(79, 140, 255, 0.15);
    border: 1px solid var(--accent);
}

.lb-rank {
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
}

.lb-avatar {
    font-size: 1.4rem;
    line-height: 1;
}

.lb-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-rating {
    font-weight: 700;
    color: var(--warning);
}

.lb-sep {
    text-align: center !important;
    color: var(--text-muted);
    display: block !important;
    background: none !important;
    padding: 0 !important;
}

.lb-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;
    background: var(--bg-elevated);
    border-radius: 8px;
}

.epic-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.epic-item {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.75rem;
    background: var(--bg-elevated);
    border-radius: 10px;
    border-left: 3px solid var(--warning);
}

.epic-icon {
    font-size: 1.75rem;
    line-height: 1;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(251, 191, 36, 0.12);
    border-radius: 10px;
}

.epic-text { flex: 1; min-width: 0; }

.epic-title {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.epic-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.epic-sub {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.epic-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;
}

.card.narrow {
    max-width: 520px;
    margin: 0 auto;
}

.kpi-grid-compact {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    max-width: 900px;
}

.dash-card label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.dash-card .avatar-current {
    margin-bottom: 1rem;
}

.dash-card .avatar-text {
    flex: 1;
}

.settings-label {
    color: var(--text);
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.dash-card .avatar-picker {
    margin-bottom: 0;
}

.dash-card input[type="text"],
.dash-card input[type="password"] {
    margin-bottom: 0.75rem;
}

.dash-card .primary {
    width: auto;
    min-width: 160px;
}

.signup-teaser {
    background: linear-gradient(135deg, rgba(79, 140, 255, 0.15), rgba(74, 222, 128, 0.12));
    border: 1px solid var(--accent);
    border-radius: 14px;
    padding: 1.5rem;
    margin: 1.5rem auto 0;
    max-width: 480px;
    text-align: center;
}

.signup-teaser .teaser-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.signup-teaser h3 {
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.signup-teaser p {
    color: var(--text);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.signup-teaser strong {
    color: var(--warning);
}

.signup-teaser .btn-link {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    text-decoration: none;
    margin-top: 0;
    max-width: 280px;
    width: 100%;
}

.stat-cpm-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.cpm-vs {
    font-size: 0.78rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.cpm-vs strong { color: var(--text); }

.cpm-vs.safe {
    border-color: var(--success);
    color: var(--success);
    background: rgba(74, 222, 128, 0.12);
}
.cpm-vs.safe strong { color: var(--success); }

.cpm-vs.danger {
    border-color: var(--error);
    color: var(--error);
    background: rgba(239, 68, 68, 0.15);
    animation: pulse 0.8s ease-in-out infinite;
}
.cpm-vs.danger strong { color: var(--error); }

.min-cpm-warn {
    margin-top: 0.75rem;
    text-align: center;
    padding: 0.6rem;
    border-radius: 8px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
}

.min-cpm-warn.danger {
    background: rgba(239, 68, 68, 0.18);
    color: #ff8b8b;
    border: 1px solid var(--error);
    animation: pulse 0.6s ease-in-out infinite;
}

.min-cpm-warn.eliminated {
    background: rgba(239, 68, 68, 0.25);
    color: #ff8b8b;
    border: 1px solid var(--error);
    animation: none;
}

.text-display .char.consumed {
    color: var(--error) !important;
    background: rgba(239, 68, 68, 0.18) !important;
    text-decoration: line-through;
    opacity: 0.45;
    animation: charFall 0.5s ease-out forwards;
}

@keyframes charFall {
    0% { transform: translateY(-2px); opacity: 1; }
    60% { opacity: 0.7; }
    100% { transform: translateY(0); opacity: 0.45; }
}

.big-cta {
    font-size: 1.1rem !important;
    padding: 1rem 1.5rem !important;
    background: linear-gradient(135deg, var(--accent), var(--success)) !important;
}

.big-cta:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

.quickplay-waiting {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-top: 1rem;
}

.quickplay-spinner {
    font-size: 3rem;
    animation: pulse 1.5s ease-in-out infinite;
    margin-bottom: 0.5rem;
}

.quickplay-waiting h3 {
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.quickplay-waiting strong {
    color: var(--warning);
    font-size: 1.1em;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.25rem;
    margin-bottom: 0.25rem;
}

.hero h1 {
    font-size: 2.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--success));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.02em;
}

.hero-logo {
    margin: 0 auto 0.5rem;
}

.hero-logo img {
    width: min(380px, 82vw);
    height: auto;
    display: block;
    margin: 0 auto;
}

.subtitle {
    color: var(--text-muted);
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    max-width: 420px;
    margin: 0 auto;
}

.card h2 {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    margin-bottom: 1rem;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

button {
    cursor: pointer;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.15s;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button.primary {
    background: var(--accent);
    color: white;
    width: 100%;
}

button.primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

button.secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
}

button.secondary:hover:not(:disabled) {
    background: var(--border);
}

button.secondary.ready {
    background: var(--success);
    color: var(--bg);
    border-color: var(--success);
}

.status {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
}

.status.error {
    color: var(--error);
}

#race-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.badge {
    background: var(--bg-elevated);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
}

.badge.racing { background: var(--accent); color: white; }
.badge.countdown { background: var(--warning); color: var(--bg); }
.badge.finished { background: var(--success); color: var(--bg); }

#countdown-display {
    text-align: center;
    padding: 3rem 0;
}

#countdown-number {
    font-size: 6rem;
    font-weight: bold;
    color: var(--warning);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.track {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    min-height: 80px;
}

.player-lane {
    display: grid;
    grid-template-columns: 200px 1fr 100px;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
}

.player-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.player-name .name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.player-name .ready-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.player-name .ready-dot.ready {
    background: var(--success);
}

.progress-bar {
    height: 28px;
    background: var(--bg-elevated);
    border-radius: 999px;
    position: relative;
    margin: 0 1.25rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 999px;
    transition: width 0.2s ease-out;
    width: 0%;
}

.progress-fill.me {
    background: linear-gradient(90deg, var(--success), #6ee7a8);
}

.progress-fill.finished {
    background: linear-gradient(90deg, var(--warning), #fcd34d);
}

.car-icon {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.75rem;
    line-height: 1;
    transition: left 0.2s ease-out;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
    z-index: 2;
    pointer-events: none;
}

.player-lane {
    grid-template-columns: 160px 1fr 110px;
}

.progress-bar {
    height: 34px;
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1rem;
}

.results-actions .primary {
    max-width: 280px;
    width: 100%;
}

.player-stats {
    text-align: right;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.player-stats .position {
    color: var(--warning);
    font-weight: bold;
    font-size: 1rem;
}

.text-display {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 1.125rem;
    line-height: 1.8;
    letter-spacing: 0.02em;
}

.text-display .char {
    transition: color 0.05s;
}

.text-display .char.correct {
    color: var(--success);
}

.text-display .char.incorrect {
    color: var(--error);
    background: rgba(239, 68, 68, 0.15);
    border-radius: 2px;
}

.text-display .char.current {
    background: var(--accent);
    color: white;
    border-radius: 2px;
}

.stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 12px;
    margin-top: 1rem;
}

.stats strong {
    color: var(--accent);
    font-size: 1.25rem;
}

#results {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
}

#results h2 {
    margin-bottom: 1rem;
}

#results-list {
    list-style: none;
    margin: 1.5rem 0;
    text-align: left;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

#results-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

#results-list li.first { border: 2px solid var(--warning); }
#results-list li.me { border: 2px solid var(--success); }

#lobby-actions {
    text-align: center;
    margin-top: 1rem;
}

.lobby-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.lobby-buttons button {
    width: auto;
    min-width: 180px;
}

.crown {
    margin-left: 0.25rem;
}

.hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.hidden {
    display: none !important;
}

.view {
    display: block;
}

.logo {
    color: inherit;
    text-decoration: none;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    background: none;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-weight: 500;
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.secondary-card {
    margin-top: 1.5rem;
    background: var(--bg-elevated);
}

.secondary-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.125rem;
}

.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.link-btn {
    background: none;
    color: var(--accent);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.link-btn:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.link-btn.danger {
    color: var(--error);
}

.link-btn.danger:hover {
    color: #ff7878;
}

#race-actions {
    text-align: center;
    margin-top: 1rem;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.btn-link {
    display: inline-block;
    text-align: center;
    text-decoration: none;
    margin-top: 1rem;
}

.badge.code {
    background: var(--bg-elevated);
    color: var(--accent);
    font-family: 'Consolas', monospace;
    letter-spacing: 0.1em;
    margin-right: 0.5rem;
}

.badge.mode {
    background: linear-gradient(135deg, var(--accent), var(--success));
    color: white;
    margin-right: 0.5rem;
}

.badge.alive {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
    border: 1px solid var(--error);
    margin-right: 0.5rem;
}

.badge.alive strong {
    color: var(--text);
}

.br-cta {
    background: linear-gradient(135deg, #8b1538, #ef4444) !important;
    color: white !important;
    border-color: var(--error) !important;
}

.br-cta:hover:not(:disabled) {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.modes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 720px) {
    .modes-grid { grid-template-columns: 1fr; }
}

.mode-card {
    padding: 1.75rem 1.5rem;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--border);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mode-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.mode-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

.mode-card:hover::before {
    opacity: 0.3;
}

.mode-online {
    background: linear-gradient(135deg, rgba(79, 140, 255, 0.18), rgba(74, 222, 128, 0.1));
    border-color: rgba(79, 140, 255, 0.5);
}

.mode-online::before {
    background: radial-gradient(circle, rgba(79, 140, 255, 0.4), transparent 60%);
}

.mode-online:hover {
    border-color: var(--accent);
}

.mode-battle {
    background: linear-gradient(135deg, rgba(139, 21, 56, 0.35), rgba(239, 68, 68, 0.12));
    border-color: rgba(239, 68, 68, 0.55);
}

.mode-battle::before {
    background: radial-gradient(circle, rgba(239, 68, 68, 0.4), transparent 60%);
}

.mode-battle:hover {
    border-color: var(--error);
}

.mode-icon {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 0.6rem;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.mode-card h3 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.mode-online h3 {
    background: linear-gradient(135deg, var(--accent), var(--success));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.mode-battle h3 {
    color: var(--error);
}

.mode-card p {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
    flex: 1;
}

.mode-cta {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--success));
    color: white;
    border: none;
    cursor: pointer;
    transition: filter 0.15s, transform 0.15s;
    position: relative;
    z-index: 1;
}

.mode-cta:hover:not(:disabled) {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.mode-cta:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.br-cta-btn {
    background: linear-gradient(135deg, #8b1538, #ef4444) !important;
}

.private-card {
    padding: 1.25rem 1.5rem;
}

.private-card h3 {
    margin-bottom: 0.25rem;
}

.private-row {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.private-row .secondary {
    flex: 0 0 auto;
    padding: 0.6rem 1rem;
}

.private-row input {
    flex: 1;
    margin-bottom: 0;
    min-width: 140px;
}

.or-divider {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0 0.25rem;
}

.anon-cta {
    margin-top: 1.5rem;
    text-align: center;
}

.anon-cta h3 {
    margin-bottom: 0.25rem;
}

.anon-cta > .hint {
    margin-bottom: 1rem;
}

.anon-cta .mode-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.anon-cta .mode-card {
    padding: 1.25rem 1rem;
}

.anon-cta .mode-icon {
    font-size: 2.25rem;
}

.text-display.endless {
    max-height: 220px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.text-display.endless::-webkit-scrollbar {
    width: 8px;
}

.text-display.endless::-webkit-scrollbar-track {
    background: var(--bg);
}

.text-display.endless::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.avatar-section {
    margin-bottom: 1rem;
}

.avatar-section h3 {
    margin-bottom: 0.5rem;
    font-size: 1.125rem;
}

.avatar-current {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.avatar-preview {
    font-size: 2.5rem;
    line-height: 1;
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border-radius: 12px;
    border: 2px solid var(--accent);
}

.avatar-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 0.4rem;
    background: var(--bg-elevated);
    padding: 0.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.avatar-option {
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.4rem;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-option:hover {
    transform: scale(1.1);
    border-color: var(--accent);
}

.avatar-option.selected {
    background: var(--accent);
    border-color: var(--accent-hover);
}
