/* ============================================================
   IMPOSTOR GAME — app.css v2
   ============================================================ */

:root {
    --bg-deep:      #070710;
    --bg-card:      #0f0f1e;
    --bg-elevated:  #161628;
    --border:       #2a2a45;
    --border-glow:  #e74c3c44;
    --red:          #e74c3c;
    --red-dark:     #c0392b;
    --red-glow:     #e74c3c33;
    --amber:        #f39c12;
    --green:        #2ecc71;
    --text-primary: #f0f0f8;
    --text-secondary:#9090b0;
    --font-display: 'Bebas Neue', sans-serif;
    --font-body:    'Inter', sans-serif;
    --radius:       12px;
    --radius-sm:    8px;
    --shadow:       0 8px 32px rgba(0,0,0,0.4);
    --shadow-red:   0 4px 24px rgba(231,76,60,0.25);
    --transition:   all 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

/* ── Typography ── */
h1, h2, h3 { font-family: var(--font-display); letter-spacing: 0.05em; line-height: 1.1; }
h1 { font-size: clamp(2.5rem, 6vw, 4.5rem); }
h2 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
h3 { font-size: 1.4rem; }
p  { color: var(--text-secondary); }
a  { color: var(--red); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--text-primary); }

/* ── Layout ── */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 1.25rem;
    position: relative;
    z-index: 1;
}
.container--wide { max-width: 800px; }

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
}

/* ── Card ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--red), transparent);
}

/* ── Brand ── */
.brand { text-align: center; margin-bottom: 2rem; }
.brand__title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 10vw, 5rem);
    letter-spacing: 0.1em;
    color: var(--text-primary);
    text-shadow: 0 0 40px var(--red-glow);
    line-height: 1;
}
.brand__title span {
    color: var(--red);
    text-shadow: 0 0 30px var(--red), 0 0 60px var(--red-glow);
}
.brand__subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-top: 0.5rem;
}

/* ── Forms ── */
.form-group { margin-bottom: 1.1rem; }
.form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}
.form-input {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 0.75rem 1rem;
    outline: none;
    transition: var(--transition);
    -webkit-appearance: none;
}
.form-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-glow); }
.form-input::placeholder { color: var(--text-secondary); opacity: 0.6; }
.form-input--code {
    text-transform: uppercase;
    letter-spacing: 0.4em;
    font-size: 1.4rem;
    font-family: var(--font-display);
    text-align: center;
}
select.form-input { cursor: pointer; }
.form-hint { font-size: 0.72rem; color: var(--text-secondary); margin-top: 0.35rem; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn:active { transform: scale(0.96); }
.btn--primary { background: var(--red); color: #fff; box-shadow: var(--shadow-red); width: 100%; }
.btn--primary:hover { background: var(--red-dark); color: #fff; }
.btn--outline { background: transparent; color: var(--text-primary); border: 1px solid var(--border); width: 100%; }
.btn--outline:hover { border-color: var(--red); color: var(--red); background: var(--red-glow); }
.btn--ghost { background: transparent; color: var(--text-secondary); padding: 0.5rem 1rem; }
.btn--ghost:hover { color: var(--text-primary); }
.btn--danger { background: transparent; color: var(--red); border: 1px solid var(--red); width: 100%; }
.btn--danger:hover { background: var(--red); color: #fff; }
.btn--sm { padding: 0.4rem 0.9rem; font-size: 0.8rem; width: auto; }
.btn--lg { padding: 0.9rem 2rem; font-size: 1rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Tabs ── */
.tabs {
    display: flex;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 1.5rem;
    gap: 4px;
}
.tab {
    flex: 1;
    padding: 0.65rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: transparent;
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
}
.tab.active { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

/* ── Divider ── */
.divider {
    display: flex; align-items: center; gap: 1rem;
    margin: 1.25rem 0;
    color: var(--text-secondary); font-size: 0.75rem;
    letter-spacing: 0.1em; text-transform: uppercase;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Alerts ── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: flex; align-items: flex-start; gap: 0.5rem;
}
.alert--error   { background: rgba(231,76,60,0.1);  border: 1px solid rgba(231,76,60,0.3);  color: #ff8070; }
.alert--success { background: rgba(46,204,113,0.1); border: 1px solid rgba(46,204,113,0.3); color: #5dde8f; }
.alert--info    { background: rgba(52,152,219,0.1); border: 1px solid rgba(52,152,219,0.3); color: #70b8ff; }

/* ── Player list ── */
.player-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.player-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
}
.player-item--host { border-color: var(--amber); }
.player-item--you  { border-color: var(--red); }
.player-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--bg-deep);
    border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--red);
    flex-shrink: 0;
    text-transform: uppercase;
}
.player-info { flex: 1; min-width: 0; }
.player-name { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-badge {
    font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase;
    padding: 0.15rem 0.5rem; border-radius: 99px; font-weight: 700; white-space: nowrap;
}
.player-badge--host      { background: rgba(243,156,18,0.15); color: var(--amber); }
.player-badge--you       { background: rgba(231,76,60,0.15);  color: var(--red); }
.player-badge--connected { background: rgba(46,204,113,0.15); color: var(--green); }
.player-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; box-shadow: 0 0 6px var(--green); }
.player-status-dot--off  { background: var(--text-secondary); box-shadow: none; }

/* ── Room code ── */
.room-code {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
}
.room-code__label { font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-secondary); }
.room-code__value { font-family: var(--font-display); font-size: 2.2rem; letter-spacing: 0.3em; color: var(--red); text-shadow: 0 0 20px var(--red-glow); }
.room-code__copy {
    background: transparent; border: 1px solid var(--border); border-radius: 6px;
    color: var(--text-secondary); cursor: pointer; padding: 0.45rem 0.7rem;
    font-size: 0.8rem; transition: var(--transition); white-space: nowrap;
    font-family: var(--font-body);
}
.room-code__copy:hover { border-color: var(--red); color: var(--red); }

/* ── Word card ── */
.word-card { text-align: center; position: relative; }
.word-card__label { font-size: 0.68rem; letter-spacing: 0.25em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 1rem; }
.word-card__value {
    font-family: var(--font-display);
    font-size: clamp(2rem, 7vw, 3rem);
    letter-spacing: 0.1em;
    color: var(--text-primary);
    filter: blur(8px);
    transition: filter 0.35s ease, color 0.35s ease;
    user-select: none;
    min-height: 3.5rem;
    display: flex; align-items: center; justify-content: center;
}
.word-card__value.revealed { filter: blur(0); }
.word-card__value--impostor { color: var(--red); text-shadow: 0 0 20px var(--red-glow); }
.word-card__actions { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }
.word-btn {
    background: var(--bg-deep); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text-secondary); cursor: pointer; padding: 0.5rem 0.85rem;
    font-size: 0.82rem; transition: var(--transition);
    display: flex; align-items: center; gap: 0.4rem;
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
}
.word-btn:hover, .word-btn:active { border-color: var(--red); color: var(--red); }
.word-tooltip {
    position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 0.6rem 0.9rem; font-size: 0.8rem; color: var(--text-secondary);
    max-width: 260px; white-space: normal; text-align: center;
    box-shadow: var(--shadow); z-index: 10; display: none;
}
.word-tooltip.visible { display: block; }
.word-tooltip::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: var(--border);
}

/* ── Turn list ── */
.turn-list { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.turn-item {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-elevated); border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.turn-number { font-family: var(--font-display); font-size: 1.1rem; color: var(--text-secondary); width: 22px; text-align: center; flex-shrink: 0; }
.turn-item--you { border-color: var(--red); }
.turn-item--you .turn-number { color: var(--red); }

/* ── Results ── */
.impostor-reveal {
    text-align: center; padding: 1.75rem;
    background: var(--bg-elevated); border: 1px solid var(--red);
    border-radius: var(--radius); margin-bottom: 1rem; box-shadow: var(--shadow-red);
}
.impostor-reveal__label { font-size: 0.72rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 0.5rem; }
.impostor-reveal__name { font-family: var(--font-display); font-size: 2.2rem; color: var(--red); text-shadow: 0 0 30px var(--red-glow); }

/* ── Section header ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.85rem; }
.section-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-secondary); }
.section-count { font-size: 0.72rem; color: var(--text-secondary); background: var(--bg-elevated); padding: 0.2rem 0.6rem; border-radius: 99px; border: 1px solid var(--border); }
.min-warning { font-size: 0.8rem; color: var(--amber); text-align: center; padding: 0.5rem; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(7, 7, 16, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 1.25rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    max-width: 340px;
    width: 100%;
    position: relative;
    transform: translateY(16px) scale(0.97);
    transition: transform 0.25s ease;
    box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
.modal-overlay.active .modal { transform: translateY(0) scale(1); }

.modal::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--red), transparent);
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal__icon { font-size: 2rem; text-align: center; margin-bottom: 0.75rem; }
.modal__title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.5rem;
}
.modal__message { font-size: 0.875rem; color: var(--text-secondary); text-align: center; margin-bottom: 1.5rem; line-height: 1.5; }
.modal__actions { display: flex; flex-direction: column; gap: 0.6rem; }
.modal__actions .btn { width: 100%; }

/* ── Lobby bg ── */
.lobby-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.lobby-bg__circle { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.06; }
.lobby-bg__circle--1 { width: 500px; height: 500px; background: var(--red); top: -200px; left: -100px; }
.lobby-bg__circle--2 { width: 400px; height: 400px; background: #8b5cf6; bottom: -150px; right: -100px; }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse  { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes glow   { 0%, 100% { text-shadow: 0 0 20px var(--red-glow); } 50% { text-shadow: 0 0 40px var(--red), 0 0 80px var(--red-glow); } }
.fade-in { animation: fadeIn 0.4s ease forwards; }
.pulse   { animation: pulse 2s ease-in-out infinite; }
.glow    { animation: glow  3s ease-in-out infinite; }

/* ============================================================
   MOBILE OPTIMIZATIONS
   ============================================================ */
@media (max-width: 480px) {
    .page { padding: 1rem 0 2rem; justify-content: flex-start; }
    .container { padding: 0 1rem; }
    .card { padding: 1.25rem; }
    .brand { margin-bottom: 1.5rem; margin-top: 1rem; }
    .room-code__value { font-size: 1.8rem; }
    .word-card__value { font-size: 1.8rem; }
    .impostor-reveal__name { font-size: 1.8rem; }
    .btn--lg { padding: 0.85rem 1.5rem; }
    .player-item { padding: 0.6rem 0.75rem; }
    .tabs .tab { font-size: 0.8rem; padding: 0.55rem; }
    .modal { padding: 1.5rem; }
    /* Safe area para iPhones con notch */
    .page { padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }
}

/* Evitar zoom en inputs en iOS */
@media (max-width: 480px) {
    .form-input { font-size: 16px !important; }
}
