/* Tipp-Rennen Styles */

/* ========== BASE LAYOUT ========== */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1rem 3rem;
}

/* ========== SCREEN MANAGEMENT ========== */
.game-section {
    display: none;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    opacity: 0;
}

.game-section.active {
    display: block;
    animation: sectionEnter 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes sectionEnter {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(18px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ========== GLASS CONTAINERS ========== */
.glass-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2rem;
    margin: 1rem 0;
}

.glass-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text);
}

/* ========== MENU SCREEN ========== */
.menu-container {
    max-width: 420px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
    text-align: center;
}

.name-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: var(--text);
    font-size: 1rem;
    text-align: center;
    margin-bottom: 1.5rem;
    transition: border-color 0.2s;
}

.name-input:focus {
    outline: none;
    border-color: var(--primary);
}

.mode-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.mode-btn {
    padding: 1.25rem 1rem;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.mode-btn:hover {
    border-color: var(--primary);
    background: rgba(162, 76, 255, 0.15);
    box-shadow: 0 0 20px rgba(162, 76, 255, 0.25);
    transform: translateY(-2px);
}

.mode-btn-icon {
    font-size: 2rem;
}

.mode-btn-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
}

/* ========== SOLO SETUP SCREEN ========== */
.duration-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.duration-btn {
    padding: 1.5rem 1rem;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    color: var(--text);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.duration-btn:hover {
    border-color: var(--primary);
    background: rgba(162, 76, 255, 0.15);
    box-shadow: 0 0 20px rgba(162, 76, 255, 0.25);
    transform: translateY(-2px);
}

.duration-time {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.duration-desc {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.25rem;
}

/* ========== BACK BUTTON ========== */
.btn-back {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.6);
    padding: 0.5rem 1.25rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    width: 100%;
}

.btn-back:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: var(--text);
}

/* ========== SOLO GAME SCREEN ========== */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.25rem;
    margin-bottom: 0.5rem;
}

.timer-display {
    font-size: 3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
    line-height: 1;
    min-width: 4rem;
}

.timer-display.timer-urgent {
    color: #ff4444;
    animation: timerPulse 0.5s ease infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.live-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
}

.live-stat-wpm {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.live-stat-acc {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}

/* ========== WORD DISPLAY AREA ========== */
.word-area {
    text-align: center;
    padding: 2.5rem 2rem;
    position: relative;
    cursor: text;
}

.word-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.65rem;
    justify-content: center;
    align-items: baseline;
    min-height: 3.2em;
    padding: 0.25rem 0;
}

.word-span {
    font-size: 1.5rem;
    font-weight: 600;
    transition: color 0.1s;
    line-height: 1.4;
}

.word-span.w-done {
    color: rgba(255, 255, 255, 0.2);
}

.word-span.w-active {
    font-size: 2rem;
    color: #fff;
}

.word-span.w-upcoming {
    color: rgba(255, 255, 255, 0.45);
}

/* ========== TYPING INPUT (hidden overlay) ========== */
.typing-input-hidden {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: text;
    border: none;
    background: none;
    padding: 0;
    font-size: 1rem;
    color: transparent;
    caret-color: transparent;
    z-index: 1;
}

/* ========== CHARACTER COLORING ========== */
.c-correct { color: #fff; }
.c-wrong { color: #ff5555; }
.c-pending { color: rgba(255, 255, 255, 0.3); }
.c-extra { color: #ff3333; }

.c-cursor {
    display: inline-block;
    width: 2px;
    height: 1.15em;
    background: rgba(255, 255, 255, 0.85);
    margin: 0 1px;
    vertical-align: text-bottom;
    animation: cursorBlink 1s step-start infinite;
}

@keyframes cursorBlink {
    50% { opacity: 0; }
}

.word-counter {
    text-align: center;
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* ========== RESULTS SOLO SCREEN ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 1.25rem 0.75rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 0.4rem;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.btn-primary-tr {
    padding: 0.8rem 1.5rem;
    background: var(--primary);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-primary-tr:hover {
    background: rgba(162, 76, 255, 0.8);
    transform: translateY(-1px);
}

.btn-secondary-tr {
    padding: 0.7rem 1.5rem;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-secondary-tr:hover {
    border-color: rgba(255, 255, 255, 0.35);
    color: var(--text);
}

.lb-submit-status {
    text-align: center;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 0.5rem;
    min-height: 1.2em;
}

/* ========== LEADERBOARD SCREEN ========== */
.lb-tabs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.lb-tab {
    padding: 0.4rem 1.25rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.lb-tab.active {
    background: rgba(162, 76, 255, 0.25);
    border-color: var(--primary);
    color: var(--text);
}

.lb-list {
    max-height: 380px;
    overflow-y: auto;
}

.lb-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    margin-bottom: 4px;
    transition: background 0.15s;
}

.lb-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.lb-item.lb-me {
    background: rgba(162, 76, 255, 0.18);
    border: 1px solid rgba(162, 76, 255, 0.35);
}

.lb-rank {
    min-width: 2rem;
    font-size: 1.05rem;
    text-align: center;
}

.lb-name {
    flex: 1;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-you {
    color: var(--primary);
    font-size: 0.75em;
}

.lb-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
}

.lb-wpm {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.lb-acc {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
}

.lb-loading, .lb-empty {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.45);
}

/* ========== MP LOBBY SCREEN ========== */
.lobby-container {
    max-width: 420px;
    margin: 0 auto;
    text-align: center;
}

.or-divider {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.85rem;
    margin: 1rem 0;
}

.join-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.code-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: var(--text);
    font-size: 1.1rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    transition: border-color 0.2s;
}

.code-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ========== MP WAITING SCREEN ========== */
.room-code-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.room-code-badge {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    color: var(--primary);
    font-family: monospace;
}

.copy-btn {
    padding: 0.4rem 0.9rem;
    background: rgba(162, 76, 255, 0.2);
    border: 1px solid rgba(162, 76, 255, 0.4);
    border-radius: 8px;
    color: var(--primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: rgba(162, 76, 255, 0.35);
}

.room-code-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ========== FRIENDS INVITE MODAL ========== */
#tr-friends-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.tr-friends-box {
    background: rgba(18, 18, 36, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    max-height: 72vh;
    overflow-y: auto;
}

.tr-friends-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    text-align: center;
}

.tr-friend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tr-friend-item:last-child { border-bottom: none; }

.tr-friend-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.tr-friend-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.95rem;
}

.tr-invite-btn {
    padding: 0.3rem 0.85rem;
    background: rgba(162, 76, 255, 0.2);
    border: 1px solid rgba(162, 76, 255, 0.45);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.tr-invite-btn:hover:not(:disabled) { background: rgba(162, 76, 255, 0.38); }
.tr-invite-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.players-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    min-height: 60px;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    font-size: 0.95rem;
    color: var(--text);
}

.player-item .host-badge {
    font-size: 0.7rem;
    background: rgba(162, 76, 255, 0.3);
    color: var(--primary);
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    margin-left: auto;
}

.waiting-hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* ========== RACE SCREEN ========== */
.race-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.25rem;
    margin-bottom: 0.75rem;
}

.race-timer {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.race-progress-text {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
}

.race-bars {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1rem 1.25rem;
}

.race-player {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.race-player-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.85rem;
}

.race-player-name {
    font-weight: 600;
    color: var(--text);
    max-width: 60%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.race-player-name.is-me {
    color: var(--primary);
}

.race-player-wpm {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
}

.race-track {
    height: 14px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 7px;
    overflow: hidden;
}

.race-bar-fill {
    height: 100%;
    background: rgba(162, 76, 255, 0.7);
    border-radius: 7px;
    transition: width 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    min-width: 2px;
}

.race-bar-fill.is-me {
    background: var(--primary);
}

.race-bar-fill.finished {
    background: #22c55e;
}

/* ========== RESULTS MULTI SCREEN ========== */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}

.ranking-item.is-me {
    background: rgba(162, 76, 255, 0.15);
    border-color: rgba(162, 76, 255, 0.35);
}

.ranking-place {
    font-size: 1.5rem;
    min-width: 2rem;
    text-align: center;
}

.ranking-name {
    flex: 1;
    font-weight: 600;
    color: var(--text);
}

.ranking-wpm {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.ranking-detail {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    text-align: right;
}

/* ========== COUNTDOWN OVERLAY ========== */
#countdown-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

#countdown-number {
    font-size: 9rem;
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
    animation: countdownPop 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

#countdown-number.go {
    color: #22c55e;
    font-size: 6rem;
}

@keyframes countdownPop {
    0% { transform: scale(1.9); opacity: 0; }
    40% { transform: scale(0.85); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

#countdown-label {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 1rem;
}

/* ========== ALERT MODAL ========== */
#tr-alert-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 1rem;
}

.tr-alert-box {
    background: rgba(20, 20, 40, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    padding: 2rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
}

.tr-alert-msg {
    color: var(--text);
    margin-bottom: 1.25rem;
    font-size: 1rem;
    line-height: 1.5;
}

.tr-alert-btn {
    padding: 0.65rem 2rem;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}
