/* ============================================
   BOMBA DE PALABRAS - Mobile-First Styles
   Local Pass-and-Play Version
   ============================================ */

/* CSS Variables */
:root {
    --color-primary: #FF4444;
    --color-secondary: #FFB347;
    --color-accent: #FFD700;
    --color-success: #2ECC71;
    --color-error: #E74C3C;
    --color-bg: #1A1A2E;
    --color-card: #16213E;
    --color-surface: #0F3460;
    --color-text: #FFFFFF;
    --color-text-muted: #8B8B8B;
    --color-strike: #FF6B6B;
    --color-strike-lost: #333333;

    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition-speed: 0.3s;
    --border-radius: 12px;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    min-height: 100dvh;
}

/* ============================================
   SCREENS
   ============================================ */

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

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 400px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1 {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    line-height: 1.1;
    letter-spacing: 2px;
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    width: 100%;
    max-width: 280px;
    min-height: 52px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.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: #ff5555;
}

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

.btn-secondary:hover:not(:disabled) {
    background: #1a4a7a;
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    text-decoration: underline;
    cursor: pointer;
    padding: 8px;
}

.btn-icon {
    width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    border: none;
    border-radius: var(--border-radius);
    background: var(--color-primary);
    color: var(--color-text);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed);
    -webkit-tap-highlight-color: transparent;
}

.btn-icon:active {
    transform: scale(0.95);
}

.btn-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove {
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--color-error);
    color: var(--color-text);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity var(--transition-speed);
}

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

/* ============================================
   INPUTS
   ============================================ */

input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--color-surface);
    border-radius: var(--border-radius);
    background: var(--color-card);
    color: var(--color-text);
    font-size: 1rem;
    transition: border-color var(--transition-speed);
}

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

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

/* ============================================
   HOME SCREEN
   ============================================ */

.logo {
    text-align: center;
    margin-bottom: 16px;
}

.bomb-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 8px;
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.home-subtitle {
    color: var(--color-text-muted);
    font-size: 1rem;
    margin-bottom: 24px;
}

/* ============================================
   SETUP SCREEN
   ============================================ */

.setup-hint {
    color: var(--color-primary);
    font-weight: 600;
    margin-top: -8px;
}

.players-list {
    list-style: none;
    background: var(--color-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    width: 100%;
    max-width: 320px;
    min-height: 60px;
}

.players-list:empty::after {
    content: 'Agrega jugadores';
    display: block;
    padding: 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-style: italic;
}

.players-list li {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--color-surface);
}

.players-list li:last-child {
    border-bottom: none;
}

.player-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

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

.add-player-form {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 320px;
}

.add-player-form input {
    flex: 1;
}

.setup-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 280px;
    margin-top: 8px;
}

.setup-min-hint {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-align: center;
}

/* ============================================
   PASS DEVICE SCREEN
   ============================================ */

.pass-visual {
    text-align: center;
}

.pass-emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 8px;
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

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

.pass-player-name {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--color-accent);
    margin: 16px 0;
}

.pass-strikes {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

/* ============================================
   PLAYING SCREEN
   ============================================ */

.playing-container {
    padding-top: 16px;
    gap: 12px;
}

.player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 320px;
    background: var(--color-card);
    padding: 12px 16px;
    border-radius: var(--border-radius);
}

.current-player-name {
    font-size: 1.2rem;
    font-weight: 700;
}

.player-strikes {
    display: flex;
    gap: 4px;
}

.syllable-display {
    text-align: center;
    margin: 8px 0;
}

.syllable {
    font-size: 3rem;
    font-weight: 900;
    color: var(--color-accent);
    letter-spacing: 4px;
    margin-top: 8px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.bomb-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
}

.bomb {
    position: relative;
    font-size: 5rem;
    line-height: 1;
}

.bomb-emoji {
    display: block;
    animation: shake 0.5s ease-in-out infinite;
}

.bomb.calm .bomb-emoji {
    animation: none;
}

.bomb.nervous .bomb-emoji {
    animation: shake 0.3s ease-in-out infinite;
}

.bomb.panic .bomb-emoji {
    animation: shake 0.1s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(-3px) rotate(-2deg); }
    75% { transform: translateX(3px) rotate(2deg); }
}

.fuse {
    position: absolute;
    top: -8px;
    right: 15px;
    width: 8px;
    height: 20px;
    background: linear-gradient(to top, var(--color-primary), var(--color-secondary));
    border-radius: 4px;
    animation: burn 0.5s ease-in-out infinite alternate;
}

@keyframes burn {
    0% { opacity: 0.6; box-shadow: 0 0 5px var(--color-secondary); }
    100% { opacity: 1; box-shadow: 0 0 15px var(--color-accent), 0 0 30px var(--color-secondary); }
}

.input-area {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 320px;
}

.input-area input {
    flex: 1;
}

.input-area .btn {
    width: auto;
    max-width: none;
    min-width: 100px;
}

.used-words-section {
    text-align: center;
    width: 100%;
    max-width: 320px;
}

.used-words {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 4px;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   CORRECT SCREEN
   ============================================ */

.correct-visual {
    text-align: center;
}

.correct-emoji {
    font-size: 5rem;
    display: block;
    margin-bottom: 8px;
    animation: pop 0.5s ease-out;
}

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

.correct-word {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-success);
    margin: 16px 0 8px;
}

.correct-text {
    color: var(--color-text-muted);
}

/* ============================================
   EXPLOSION SCREEN
   ============================================ */

.explosion-container {
    animation: explosionShake 0.5s ease-out;
}

@keyframes explosionShake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-15px); }
    20% { transform: translateX(15px); }
    30% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    50% { transform: translateX(-5px); }
    60% { transform: translateX(5px); }
}

.explosion-visual {
    text-align: center;
    position: relative;
}

.explosion-emoji {
    font-size: 6rem;
    display: block;
    animation: explode 0.5s ease-out;
}

@keyframes explode {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}

.boom-text {
    font-size: 3rem;
    font-weight: 900;
    color: var(--color-primary);
    letter-spacing: 4px;
    text-shadow: 0 0 20px var(--color-primary);
}

.explosion-info {
    text-align: center;
    margin-top: 24px;
}

#explosion-player {
    font-size: 1.5rem;
    font-weight: 700;
}

.explosion-text {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    margin: 8px 0 16px;
}

.strikes-display {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* ============================================
   ELIMINATED SCREEN
   ============================================ */

.eliminated-visual {
    text-align: center;
}

.eliminated-emoji {
    font-size: 5rem;
    display: block;
    margin-bottom: 8px;
}

.eliminated-player {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-error);
    margin: 16px 0 8px;
}

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

/* ============================================
   FINISHED SCREEN
   ============================================ */

.winner-visual {
    text-align: center;
}

.trophy-emoji {
    font-size: 5rem;
    display: block;
    margin-bottom: 8px;
    animation: bounce 1s ease infinite;
}

.winner-name {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--color-accent);
    margin: 16px 0 8px;
}

.winner-text {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.game-stats {
    background: var(--color-card);
    padding: 12px 24px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
}

.game-stats p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ============================================
   STRIKES
   ============================================ */

.strike {
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.strike.lost {
    filter: grayscale(1) brightness(0.4);
}

.strike-large {
    font-size: 2rem;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-content {
    position: relative;
    background: var(--color-card);
    border-radius: var(--border-radius);
    padding: 24px;
    max-width: 360px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 16px;
}

.help-section {
    margin-bottom: 20px;
}

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

.help-section p,
.help-section ul {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.help-section ul {
    padding-left: 20px;
}

.help-section li {
    margin-bottom: 4px;
}

#btn-got-it {
    margin-top: 8px;
}

/* ============================================
   TOAST
   ============================================ */

.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-card);
    color: var(--color-text);
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 200;
    text-align: center;
    max-width: 300px;
    border: 2px solid var(--color-error);
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: var(--color-success);
}

/* ============================================
   MEDIA QUERIES
   ============================================ */

@media (min-width: 400px) {
    h1 {
        font-size: 2.5rem;
    }

    .bomb {
        font-size: 6rem;
    }

    .syllable {
        font-size: 3.5rem;
    }

    .pass-player-name,
    .winner-name {
        font-size: 3rem;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 500px;
    }

    .btn,
    .setup-actions {
        max-width: 340px;
    }

    .input-area,
    .used-words-section,
    .players-list,
    .add-player-form,
    .player-header {
        max-width: 400px;
    }
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    .screen {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
