/* ===========================================================
   CARDS AGAINST DEVIL — FLAT BLACK / WHITE / RED
   =========================================================== */

:root {
    --black:  #000000;
    --dark:   #111111;
    --gray-d: #222222;
    --gray:   #666666;
    --gray-l: #999999;
    --white:  #FFFFFF;
    --cream:  #F5F5F0;
    --red:    #E53935;
    --red-d:  #B71C1C;
    --font:   'Inter', -apple-system, sans-serif;
    --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: var(--font);
    background: var(--black);
    color: var(--white);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

#app { height: 100%; width: 100%; position: relative; }

/* ── Screens ──────────────────────────────────────────── */
.screen {
    position: absolute; inset: 0;
    display: none; flex-direction: column;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
    from { opacity: 0; } to { opacity: 1; }
}

.screen-pad {
    padding: 20px; width: 100%; max-width: 440px;
    margin: 0 auto; display: flex; flex-direction: column;
    align-items: center; gap: 16px;
}

/* ── SPLASH ───────────────────────────────────────────── */
.splash-content {
    display: flex; align-items: center; justify-content: center;
    height: 100%;
}
.splash-logo {
    width: 140px; height: 140px;
    animation: pop 0.4s ease;
}
@keyframes pop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ── BUTTONS ──────────────────────────────────────────── */
.btn-white {
    width: 100%; padding: 16px; border: none;
    background: var(--white); color: var(--black);
    font-family: var(--font); font-size: 16px; font-weight: 800;
    border-radius: var(--radius); cursor: pointer;
    letter-spacing: 0.5px; text-transform: uppercase;
    transition: transform 0.1s, opacity 0.2s;
}
.btn-white:active { transform: scale(0.97); }
.btn-white:disabled { opacity: 0.3; }

.btn-outline {
    width: 100%; padding: 16px; border: 2px solid var(--white);
    background: transparent; color: var(--white);
    font-family: var(--font); font-size: 16px; font-weight: 800;
    border-radius: var(--radius); cursor: pointer;
    letter-spacing: 0.5px; text-transform: uppercase;
    transition: background 0.2s;
}
.btn-outline:hover { background: rgba(255,255,255,0.05); }

.btn-red {
    width: 100%; padding: 16px; border: none;
    background: var(--red); color: var(--white);
    font-family: var(--font); font-size: 16px; font-weight: 800;
    border-radius: var(--radius); cursor: pointer;
    text-transform: uppercase;
}
.btn-red:active { background: var(--red-d); }

.btn-link {
    background: none; border: none; color: var(--gray-l);
    font-family: var(--font); font-size: 14px; cursor: pointer;
    padding: 8px; transition: color 0.2s;
}
.btn-link:hover { color: var(--white); }

.btn-icon {
    background: none; border: none; color: var(--gray-l);
    font-size: 16px; cursor: pointer; padding: 6px;
    line-height: 1;
}
.btn-icon:hover { color: var(--white); }

.btn-sm { padding: 12px 20px; font-size: 14px; }
.btn-full { width: 100%; }

.error-msg {
    color: var(--red); font-size: 13px; text-align: center;
    min-height: 18px; margin-top: 4px;
}

/* ── INPUTS ───────────────────────────────────────────── */
input[type="email"], input[type="password"], input[type="text"] {
    width: 100%; padding: 14px 16px;
    background: var(--dark); border: 1px solid var(--gray-d);
    border-radius: var(--radius); color: var(--white);
    font-family: var(--font); font-size: 15px; outline: none;
    transition: border-color 0.2s;
}
input:focus { border-color: var(--white); }
input::placeholder { color: var(--gray); }

/* ── TOP BAR ──────────────────────────────────────────── */
.top-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; width: 100%;
}
.nick-display {
    display: flex; align-items: center; gap: 6px;
}
#nick-label {
    font-weight: 700; font-size: 15px;
}

.nick-editor {
    position: absolute; top: 50px; left: 16px; right: 16px;
    z-index: 20; background: var(--dark);
    border: 1px solid var(--gray-d); border-radius: var(--radius);
    padding: 12px; display: flex; gap: 8px; align-items: center;
    animation: fadeIn 0.2s ease;
}
.nick-editor input { flex: 1; }
.nick-editor .btn-sm { width: auto; flex-shrink: 0; }

/* ── LOBBY ────────────────────────────────────────────── */
.lobby-center {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 0 24px; gap: 20px; width: 100%; max-width: 380px;
    margin: 0 auto;
}
.lobby-logo { width: 100px; height: 100px; }
.lobby-title {
    font-size: 22px; font-weight: 900; text-transform: uppercase;
    letter-spacing: 2px; text-align: center;
}
.lobby-buttons {
    width: 100%; display: flex; flex-direction: column; gap: 12px;
}
.join-input {
    width: 100%; display: flex; gap: 8px;
}
.join-input input {
    flex: 1; text-align: center; text-transform: uppercase;
    font-size: 22px; font-weight: 800; letter-spacing: 6px;
}
.join-input .btn-sm { width: auto; }

.lobby-bottom {
    padding: 12px; text-align: center;
}

/* ── MODAL ────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(0,0,0,0.85); display: flex;
    align-items: center; justify-content: center;
    padding: 20px; animation: fadeIn 0.2s ease;
}
.modal-box {
    background: var(--dark); border: 1px solid var(--gray-d);
    border-radius: var(--radius); width: 100%; max-width: 400px;
    max-height: 80vh; overflow-y: auto;
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--gray-d);
    font-weight: 800; font-size: 16px; text-transform: uppercase;
    letter-spacing: 1px;
}
.modal-body {
    padding: 20px; display: flex; flex-direction: column; gap: 12px;
}
.rules-body { gap: 16px; }
.rule {
    font-size: 14px; color: var(--gray-l); line-height: 1.6;
}
.rule b { color: var(--white); }

/* ── ROOM ─────────────────────────────────────────────── */
.room-top { text-align: center; width: 100%; }
.room-code {
    font-size: 40px; font-weight: 900; letter-spacing: 10px;
    margin: 8px 0 4px;
}
.room-hint { color: var(--gray); font-size: 13px; }

.player-list {
    width: 100%; display: flex; flex-direction: column; gap: 6px;
}
.player-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px; background: var(--dark);
    border-radius: var(--radius); border-left: 3px solid var(--red);
}
.player-nick { font-weight: 700; }
.player-badge {
    font-size: 11px; color: var(--red);
    text-transform: uppercase; letter-spacing: 1px; font-weight: 800;
}

.room-settings {
    width: 100%; padding: 12px 16px; background: var(--dark);
    border-radius: var(--radius);
}
.room-settings label {
    font-size: 14px; color: var(--gray-l);
    display: flex; align-items: center; gap: 8px;
}
.room-settings select {
    background: var(--black); color: var(--white);
    border: 1px solid var(--gray-d); border-radius: 6px;
    padding: 6px 10px;
}

/* ── GAME ─────────────────────────────────────────────── */
.game-layout {
    width: 100%; height: 100%;
    display: flex; flex-direction: column; position: relative;
}
.game-top-bar {
    padding: 8px 12px; background: var(--dark);
    border-bottom: 1px solid var(--gray-d); flex-shrink: 0;
}
.scores-bar {
    display: flex; gap: 6px; overflow-x: auto;
    scrollbar-width: none;
}
.scores-bar::-webkit-scrollbar { display: none; }
.score-chip {
    display: flex; align-items: center; gap: 5px;
    padding: 4px 10px; background: var(--black);
    border-radius: 20px; font-size: 13px;
    white-space: nowrap; flex-shrink: 0;
}
.score-chip.is-judge { border: 1px solid var(--red); }
.score-chip.is-judge::before { content: '⚖️'; font-size: 11px; }
.score-chip.is-me { background: var(--gray-d); }
.score-chip .chip-score { font-weight: 800; color: var(--red); }

.round-info {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; color: var(--gray); margin-top: 4px;
}

.timer {
    padding: 3px 12px; border-radius: 20px;
    font-weight: 800; font-size: 13px;
    background: var(--gray-d); color: var(--white);
}
.timer.warning { color: #FFC107; }
.timer.critical { color: var(--red); animation: blink 0.5s infinite; }
@keyframes blink { 50% { opacity: 0.5; } }

.round-history {
    display: flex; gap: 4px; padding: 4px 12px;
    overflow-x: auto; scrollbar-width: none; flex-shrink: 0;
}
.round-history::-webkit-scrollbar { display: none; }
.history-chip {
    padding: 2px 8px; background: var(--dark);
    border-radius: 10px; font-size: 11px;
    color: var(--gray-l); white-space: nowrap;
}
.history-chip .history-winner { color: var(--red); font-weight: 700; }

/* ── CARDS ────────────────────────────────────────────── */
.card {
    border-radius: var(--radius); padding: 20px;
    display: flex; flex-direction: column; justify-content: space-between;
    transition: transform 0.15s;
}
.black-card {
    background: var(--black); border: 2px solid var(--gray-d);
    color: var(--white); min-height: 170px;
}
.black-card .card-text {
    font-size: 18px; font-weight: 800; line-height: 1.5;
}
.black-card .card-text .blank {
    display: inline-block; width: 70px;
    border-bottom: 3px solid var(--red); margin: 0 4px;
}
.black-card .card-footer {
    font-size: 10px; color: var(--gray); font-weight: 800;
    letter-spacing: 4px; margin-top: 12px; align-self: flex-end;
    text-transform: uppercase;
}
.white-card {
    background: var(--cream); color: var(--black);
    border: none; min-height: 130px;
}
.white-card .card-text {
    font-size: 15px; font-weight: 700; line-height: 1.5;
}
.white-card .card-footer {
    font-size: 9px; color: var(--gray); font-weight: 800;
    letter-spacing: 3px; margin-top: 12px; align-self: flex-end;
}

.black-card-area {
    display: flex; justify-content: center;
    padding: 12px 20px; flex-shrink: 0;
}
.black-card-area .black-card { width: 100%; max-width: 340px; }

.played-cards-area {
    padding: 12px 16px; overflow-y: auto; flex: 1;
    display: flex; flex-wrap: wrap; gap: 10px;
    justify-content: center; align-content: flex-start;
}
.played-card-wrapper { width: calc(50% - 5px); max-width: 170px; }
.played-card-wrapper .white-card {
    width: 100%; min-height: 110px; cursor: pointer; font-size: 13px;
}
.played-card-wrapper .white-card:active { transform: scale(0.96); }
.played-card-wrapper .white-card.selected-winner {
    outline: 3px solid var(--red);
    outline-offset: 2px;
}

.hand-area {
    padding: 10px 10px 20px; flex-shrink: 0;
    background: linear-gradient(to top, var(--dark), transparent);
}
.hand-controls { display: flex; justify-content: center; margin-top: 10px; }
.hand-controls .btn-white { max-width: 220px; }

.player-hand {
    display: flex; gap: 8px; overflow-x: auto;
    padding-bottom: 6px; scroll-snap-type: x mandatory;
    scrollbar-width: none;
}
.player-hand::-webkit-scrollbar { display: none; }
.player-hand .white-card {
    width: 135px; min-width: 135px; min-height: 155px;
    cursor: pointer; scroll-snap-align: start; font-size: 13px;
}
.player-hand .white-card:active { transform: scale(0.95); }
.player-hand .white-card.selected {
    outline: 3px solid var(--red);
    outline-offset: 2px;
    transform: translateY(-14px);
}

.waiting-text {
    text-align: center; color: var(--gray-l); font-size: 14px;
    padding: 30px; flex: 1;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 12px;
}
.spinner {
    width: 24px; height: 24px;
    border: 2px solid var(--gray-d); border-top-color: var(--white);
    border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.round-result {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.95);
    display: flex; align-items: center; justify-content: center;
    z-index: 10;
}
.result-content {
    text-align: center; padding: 24px; max-width: 300px;
}
.result-content h3 {
    font-size: 20px; font-weight: 900; color: var(--red);
    margin-bottom: 16px; text-transform: uppercase;
}
.result-content .white-card { margin: 0 auto 20px; max-width: 220px; }

.btn-exit {
    position: absolute; bottom: 12px; left: 12px; z-index: 5;
    background: var(--dark); color: var(--gray-l);
    border: 1px solid var(--gray-d); border-radius: 50%;
    width: 36px; height: 36px; font-size: 14px;
    cursor: pointer; display: flex; align-items: center;
    justify-content: center;
}
.btn-exit:hover { color: var(--red); border-color: var(--red); }

/* ── GAME OVER ────────────────────────────────────────── */
.gameover {
    justify-content: center; align-items: center; text-align: center;
}
.winner {
    font-size: 32px; font-weight: 900; color: var(--white);
    text-transform: uppercase; margin-top: 12px;
}
.winner-sub {
    color: var(--red); font-size: 14px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 2px;
    margin-bottom: 20px;
}
.final-scores {
    width: 100%; max-width: 280px; display: flex;
    flex-direction: column; gap: 6px; margin-bottom: 20px;
}
.final-score-row {
    display: flex; justify-content: space-between;
    padding: 10px 14px; background: var(--dark);
    border-radius: 8px;
}
.final-score-row:first-child { border: 1px solid var(--red); }
.fs-name { font-weight: 700; }
.fs-pts { color: var(--red); font-weight: 800; }

/* ── Responsive ───────────────────────────────────────── */
@media (min-width: 600px) {
    .player-hand .white-card { width: 155px; min-width: 155px; }
    .played-card-wrapper { width: calc(33% - 7px); }
}
@media (display-mode: standalone) {
    body { padding-top: env(safe-area-inset-top); }
}
