/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --accent-primary: #e94560;
    --accent-secondary: #533483;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #6b7280;
    --success: #4ade80;
    --danger: #ef4444;
    --warning: #fbbf24;
    --border-radius: 12px;
    --transition-speed: 0.3s;
}

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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
}

/* ============================================
   SCREEN MANAGEMENT
   ============================================ */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
}

.container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 24px 16px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.container.center-content {
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    margin: 0;
    text-shadow: 0 0 30px rgba(233, 69, 96, 0.5);
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

p {
    color: var(--text-secondary);
}

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

.logo-emoji {
    font-size: 5rem;
    display: block;
    margin-bottom: 16px;
    animation: spy-float 3s ease-in-out infinite;
}

@keyframes spy-float {
    0%, 100% {
        transform: translateY(0) rotate(-5deg);
    }
    50% {
        transform: translateY(-15px) rotate(5deg);
    }
}

.tagline {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    padding: 16px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

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

.btn-primary:hover:not(:disabled) {
    background: #d63d56;
    transform: translateY(-2px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--accent-secondary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--accent-secondary);
    transform: translateY(-2px);
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

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

.btn-large {
    min-height: 64px;
    font-size: 1.2rem;
}

.btn-icon {
    font-size: 1.3rem;
}

.btn-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px 0;
    text-align: left;
    margin-bottom: 16px;
    -webkit-tap-highlight-color: transparent;
}

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

.btn-add {
    width: 56px;
    min-height: 56px;
    font-size: 1.5rem;
    font-weight: 700;
    flex-shrink: 0;
}

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

/* ============================================
   FORMS
   ============================================ */
input[type="text"] {
    flex: 1;
    padding: 16px;
    font-size: 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--bg-card);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    transition: border-color var(--transition-speed);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-primary);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

/* ============================================
   SETUP SCREEN
   ============================================ */
.setup-section {
    margin-bottom: 24px;
}

.setup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-weight: 600;
}

.player-count-badge {
    background: var(--bg-card);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.add-player-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.players-list {
    list-style: none;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    max-height: 240px;
    overflow-y: auto;
}

.players-list:empty {
    display: none;
}

.player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--bg-card);
}

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

.player-name-display {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-avatar {
    font-size: 1.2rem;
}

.player-name {
    font-weight: 500;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    -webkit-tap-highlight-color: transparent;
}

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

.warning-text {
    font-size: 0.85rem;
    color: var(--warning);
    text-align: center;
    margin-top: 12px;
}

.timer-options {
    display: flex;
    gap: 8px;
}

.timer-btn {
    flex: 1;
    padding: 12px;
    background: var(--bg-secondary);
    border: 2px solid var(--bg-card);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed);
    -webkit-tap-highlight-color: transparent;
}

.timer-btn:hover {
    border-color: var(--accent-secondary);
}

.timer-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* ============================================
   REVEAL SCREEN
   ============================================ */
.reveal-prompt {
    margin-bottom: 32px;
}

.reveal-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.reveal-name {
    font-size: 2rem;
    margin-bottom: 24px;
    color: var(--accent-primary);
}

.reveal-instruction {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.reveal-warning {
    font-size: 0.9rem;
    color: var(--warning);
}

.reveal-progress {
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================
   ROLE CARD
   ============================================ */
.role-card {
    width: 100%;
    max-width: 320px;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    margin-bottom: 24px;
    animation: card-reveal 0.5s ease-out;
}

@keyframes card-reveal {
    from {
        opacity: 0;
        transform: scale(0.9) rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotateY(0);
    }
}

.role-card.citizen {
    border: 3px solid var(--success);
}

.role-card.spy {
    border: 3px solid var(--accent-primary);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(233, 69, 96, 0.15) 100%);
}

.role-emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
}

.role-title {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.role-location {
    font-size: 2rem;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 16px;
}

.role-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.role-assigned {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.role-card.spy .role-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 16px;
}

.role-card.spy .role-hint {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.role-warning {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ============================================
   PLAYING SCREEN
   ============================================ */
.timer-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

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

.timer {
    font-size: 3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.timer.warning {
    color: var(--warning);
    animation: pulse 1s ease-in-out infinite;
}

.timer.danger {
    color: var(--danger);
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.playing-content {
    flex: 1;
    text-align: center;
}

.playing-instruction {
    margin-bottom: 24px;
}

.playing-players {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    text-align: left;
}

.playing-players h3 {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.playing-players-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.playing-player-item {
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: 8px;
    font-size: 0.95rem;
}

.playing-footer {
    margin-top: 24px;
}

/* ============================================
   VOTING SCREENS
   ============================================ */
.vote-prompt {
    margin-bottom: 32px;
}

.vote-prompt-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
}

.vote-prompt-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
}

.vote-name {
    font-size: 1.8rem;
    color: var(--accent-primary);
    margin: 8px 0 16px;
}

.vote-instruction {
    font-size: 1.1rem;
}

.vote-progress {
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.voting-header {
    text-align: center;
    margin-bottom: 24px;
}

.voting-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 8px;
}

.voting-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.vote-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--bg-card);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    -webkit-tap-highlight-color: transparent;
}

.vote-option:hover {
    border-color: var(--accent-secondary);
}

.vote-option.selected {
    border-color: var(--accent-primary);
    background: rgba(233, 69, 96, 0.1);
}

.vote-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.vote-radio {
    width: 24px;
    height: 24px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-speed);
}

.vote-option.selected .vote-radio {
    border-color: var(--accent-primary);
}

.vote-option.selected .vote-radio::after {
    content: '';
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    border-radius: 50%;
}

.vote-option-name {
    flex: 1;
    font-weight: 500;
    font-size: 1.1rem;
}

.vote-option-tag {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================
   GUESS SCREEN
   ============================================ */
.guess-header {
    text-align: center;
    margin-bottom: 20px;
}

.guess-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 8px;
}

.guess-spy-name {
    margin-top: 12px;
    color: var(--accent-primary);
}

.locations-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    max-height: 350px;
    overflow-y: auto;
    padding: 4px;
}

.location-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--bg-secondary);
    border: 2px solid var(--bg-card);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-speed);
    -webkit-tap-highlight-color: transparent;
}

.location-btn:hover {
    border-color: var(--accent-secondary);
}

.location-btn.selected {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.location-emoji {
    font-size: 1.5rem;
}

/* ============================================
   RESULTS SCREEN
   ============================================ */
.result-content {
    margin-bottom: 24px;
}

.result-emoji {
    font-size: 5rem;
    display: block;
    margin-bottom: 16px;
    animation: result-bounce 0.6s ease-out;
}

@keyframes result-bounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.result-title {
    font-size: 1.8rem;
    font-weight: 700;
}

.result-title.win {
    color: var(--success);
}

.result-title.lose {
    color: var(--danger);
}

.result-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.result-details {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 320px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.result-item:not(:last-child) {
    border-bottom: 1px solid var(--bg-card);
}

.result-label {
    color: var(--text-secondary);
}

.result-value {
    font-weight: 600;
    font-size: 1.1rem;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

/* ============================================
   HELP SCREEN
   ============================================ */
.help-content {
    flex: 1;
}

.help-section {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 12px;
}

.help-section h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

.help-section p {
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.help-section p:last-child {
    margin-bottom: 0;
}

.help-section ul {
    list-style: none;
    font-size: 0.95rem;
    margin: 8px 0;
}

.help-section li {
    padding: 4px 0 4px 20px;
    color: var(--text-secondary);
    position: relative;
}

.help-section li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--accent-primary);
}

.help-section li strong {
    color: var(--text-primary);
}

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    animation: toast-in 0.3s ease-out;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 768px) {
    .container {
        padding: 32px 24px;
    }

    .logo-emoji {
        font-size: 6rem;
    }

    h1 {
        font-size: 3rem;
    }

    .locations-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .playing-players-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   SAFE AREA (notch)
   ============================================ */
@supports (padding-top: env(safe-area-inset-top)) {
    .container {
        padding-top: calc(24px + env(safe-area-inset-top));
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}
