/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --color-bg: #1a1a2e;
    --color-bg-light: #252545;
    --color-primary: #e94560;
    --color-primary-dark: #c73e54;
    --color-secondary: #0f3460;
    --color-accent: #16c79a;
    --color-text: #ffffff;
    --color-text-muted: #a0a0a0;
    --color-gold: #ffd700;
    --color-silver: #c0c0c0;
    --color-bronze: #cd7f32;
    --color-error: #ff4757;
    --color-danger: #ff6b6b;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --transition-speed: 0.2s;
    --border-radius: 12px;
}

/* ============================================
   RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    height: 100dvh;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ============================================
   SCREENS
   ============================================ */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
}

.screen.active {
    display: flex;
}

.screen-content {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    min-height: 100%;
}

.center-content {
    justify-content: center;
}

/* ============================================
   LOGO
   ============================================ */
.logo {
    text-align: center;
    margin-bottom: 10px;
}

.logo-emoji {
    font-size: 64px;
    display: block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tagline {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    touch-action: manipulation;
    min-height: 48px;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--color-secondary);
    color: var(--color-text);
}

.btn-secondary:hover:not(:disabled) {
    background: #163d6e;
}

.btn-text {
    background: transparent;
    color: var(--color-text-muted);
}

.btn-text:hover {
    color: var(--color-text);
}

.btn-large {
    width: 100%;
    padding: 18px;
    font-size: 1.2rem;
}

.btn-icon {
    background: var(--color-bg-light);
    width: 48px;
    height: 48px;
    padding: 0;
    font-size: 1.5rem;
    border-radius: 50%;
}

.btn-icon.muted {
    opacity: 0.5;
}

.btn-add {
    width: 100%;
    background: var(--color-bg-light);
    border: 2px dashed var(--color-secondary);
    color: var(--color-text-muted);
}

.btn-add:hover {
    border-color: var(--color-primary);
    color: var(--color-text);
}

.btn-add.hidden {
    display: none;
}

.button-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.button-row {
    display: flex;
    gap: 12px;
    width: 100%;
}

.button-row .btn {
    flex: 1;
}

/* ============================================
   PLAYERS SECTION (Setup)
   ============================================ */
.players-section {
    width: 100%;
}

.players-section h2 {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.players-list {
    list-style: none;
    margin-bottom: 12px;
    max-height: 250px;
    overflow-y: auto;
}

.players-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-bg-light);
    border-radius: 8px;
    margin-bottom: 8px;
}

.players-list li:last-child {
    margin-bottom: 0;
}

.player-number {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    min-width: 24px;
}

.player-name-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--color-text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}

.player-name-input::placeholder {
    color: var(--color-text-muted);
}

.btn-remove-player {
    background: transparent;
    border: none;
    color: var(--color-danger);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.7;
    transition: opacity var(--transition-speed);
}

.btn-remove-player:hover {
    opacity: 1;
}

/* ============================================
   SETTINGS ROW
   ============================================ */
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 10px;
}

.personal-best {
    color: var(--color-gold);
    font-size: 0.9rem;
    font-weight: 600;
}

/* ============================================
   READY SCREEN
   ============================================ */
.ready-label {
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

.player-name-large {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--color-primary);
    text-transform: uppercase;
    text-align: center;
    word-break: break-word;
    margin: 20px 0;
}

.pass-phone-hint {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-top: 30px;
    text-align: center;
}

/* ============================================
   COUNTDOWN
   ============================================ */
.countdown-number {
    font-size: 10rem;
    font-weight: 900;
    color: var(--color-primary);
    animation: countdownPulse 1s ease-in-out;
    text-shadow: 0 0 40px var(--color-primary);
}

@keyframes countdownPulse {
    0% { transform: scale(1.5); opacity: 0; }
    50% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.8; }
}

.countdown-text {
    font-size: 1.5rem;
    color: var(--color-text-muted);
    margin-top: 20px;
}

/* ============================================
   PLAYING SCREEN
   ============================================ */
.playing-content {
    padding-top: 16px;
    padding-bottom: 16px;
    gap: 16px;
    justify-content: space-between;
}

.timer-display {
    font-size: 2.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.timer-icon {
    font-size: 1.5rem;
}

#timer-value {
    min-width: 80px;
    text-align: center;
}

.timer-unit {
    color: var(--color-text-muted);
    font-size: 1.5rem;
}

.timer-display.warning #timer-value {
    color: var(--color-gold);
}

.timer-display.danger #timer-value {
    color: var(--color-error);
    animation: timerBlink 0.5s ease-in-out infinite;
}

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

/* ============================================
   SMASH BUTTON
   ============================================ */
.smash-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 200px;
}

.btn-smash {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--color-primary), var(--color-primary-dark));
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow:
        0 10px 30px rgba(233, 69, 96, 0.4),
        inset 0 -5px 20px rgba(0, 0, 0, 0.2),
        inset 0 5px 20px rgba(255, 255, 255, 0.1);
    transition: transform 0.05s, box-shadow 0.05s;
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

.btn-smash:active,
.btn-smash.pressed {
    transform: scale(0.92);
    box-shadow:
        0 5px 15px rgba(233, 69, 96, 0.3),
        inset 0 -2px 10px rgba(0, 0, 0, 0.3),
        inset 0 2px 10px rgba(255, 255, 255, 0.05);
}

.smash-emoji {
    font-size: 4rem;
    transition: transform 0.05s;
}

.btn-smash.pressed .smash-emoji {
    transform: scale(0.9);
}

.smash-text {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: 2px;
}

.my-taps {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

#tap-count {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--color-accent);
    transition: transform 0.05s;
}

#tap-count.pop {
    transform: scale(1.1);
}

.taps-label {
    font-size: 1rem;
    color: var(--color-text-muted);
}

/* ============================================
   RESULT SCREEN
   ============================================ */
.result-player-name {
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

.result-player-name span {
    color: var(--color-text);
    font-weight: 600;
}

.result-taps {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
}

#result-taps-count {
    font-size: 5rem;
    font-weight: 900;
    color: var(--color-accent);
    line-height: 1;
}

.result-taps-label {
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

.result-tps {
    font-size: 1.1rem;
    color: var(--color-text-muted);
}

.result-tps span {
    color: var(--color-text);
    font-weight: 600;
}

.new-record {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.05));
    border: 2px solid var(--color-gold);
    padding: 12px 24px;
    border-radius: var(--border-radius);
    color: var(--color-gold);
    font-weight: 700;
    animation: recordPop 0.5s ease-out;
}

.new-record.hidden {
    display: none;
}

#btn-next.hidden {
    display: none;
}

@keyframes recordPop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* ============================================
   FINAL RANKING
   ============================================ */
.final-title {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.ranking {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 10px 0 20px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-bg-light);
    padding: 16px;
    border-radius: var(--border-radius);
    transition: transform 0.3s ease-out;
}

.ranking-item.rank-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.05));
    border: 2px solid var(--color-gold);
    transform: scale(1.02);
}

.ranking-item.rank-2 {
    border: 2px solid var(--color-silver);
}

.ranking-item.rank-3 {
    border: 2px solid var(--color-bronze);
}

.rank-medal {
    font-size: 2rem;
    width: 40px;
    text-align: center;
}

.rank-info {
    flex: 1;
}

.rank-name {
    font-size: 1.1rem;
    font-weight: 600;
}

.rank-tps {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.rank-taps {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-primary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 400px) {
    .logo-emoji {
        font-size: 80px;
    }

    .logo h1 {
        font-size: 2.2rem;
    }
}

@media (min-width: 768px) {
    .btn-smash {
        width: 250px;
        height: 250px;
    }

    .smash-emoji {
        font-size: 5rem;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.shake {
    animation: shake 0.1s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* ============================================
   SOLO MODE
   ============================================ */
.solo-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 8px;
}

.solo-divider {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
}

.solo-section .btn {
    width: 100%;
}

.solo-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 20px;
}

.solo-actions.hidden {
    display: none;
}
