/*
 * style.css - Coup Web Client
 * Dark-panel Saturn aesthetic, fully responsive
 * Palette from coup_ui.h
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Panel / background */
    --bg-dark: #08081A;
    --bg-grid: #404080;
    --panel-dark: #141428;
    --panel-mid: #1E1E3C;
    --panel-light: #282850;
    --panel-header: #1A1A40;
    --panel-status: #101030;
    --panel-log: #0C0C20;
    --panel-alert: #3C1420;
    --panel-prompt: #142840;
    --panel-select: #283014;
    --panel-my-turn: #142814;
    --panel-ref-bg: #0C0C24;

    /* Accent / borders */
    --accent-gold: #D0A820;
    --accent-blue: #4060D0;
    --accent-red: #C04040;
    --accent-green: #40B060;
    --accent-purple: #8050C0;
    --accent-dim: #303050;

    /* Text */
    --text-white: #FFFFFF;
    --text-yellow: #F9E2AF;
    --text-blue: #89B4FA;
    --text-red: #F38BA8;
    --text-green: #A6E3A1;
    --text-gray: #6C7086;
    --text-pink: #F5C2E7;
    --text-orange: #FAB387;

    /* Card character colors */
    --char-duke: #A050D0;
    --char-assassin: #C03030;
    --char-captain: #3060C0;
    --char-ambassador: #30A040;
    --char-contessa: #D09020;
    --char-facedown: #203060;
    --char-none: #101010;

    /* Button prompt */
    --btn-a: #60C080;
    --btn-b: #C06060;
}

html, body {
    width: 100%; height: 100%;
    background: #000;
    color: var(--text-white);
    font-family: 'Courier New', 'Consolas', 'Liberation Mono', monospace;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: #000;
}

/* === GAME VIEWPORT - Full screen, letterbox only on ultra-wide === */
.game-viewport {
    position: relative;
    width: 100%; height: 100%;
    background: var(--bg-dark);
    overflow: hidden;
}

@media (min-aspect-ratio: 21/9) {
    .game-viewport {
        max-width: 177.78vh;
        max-height: 56.25vw;
    }
}

.screen {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    animation: screenFadeIn 0.3s ease-out;
}

/* ============================================================
   TITLE SCREEN
   ============================================================ */

.screen-title {
    background: var(--bg-dark);
    overflow: hidden;
}

/* Scrolling character parade */
.title-character-parade {
    position: absolute;
    top: 8%; left: 0; right: 0;
    height: 48%;
    overflow: hidden;
    mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}

.title-character-track {
    display: flex;
    gap: 4%;
    position: absolute;
    top: 0; height: 100%;
    animation: scrollCharacters 20s linear infinite;
    will-change: transform;
}

.title-char-card {
    flex: 0 0 auto;
    width: 28vmin;
    height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    position: relative;
}

.title-char-card img,
.title-char-card video {
    width: 100%; height: 80%;
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(208, 168, 32, 0.3));
    pointer-events: none;
}

.title-char-card .char-name-tag {
    font-size: clamp(8px, 1.2vmin, 14px);
    font-weight: bold;
    letter-spacing: 2px;
    margin-top: 4px;
    text-shadow: 0 0 8px currentColor;
}

.title-char-card:nth-child(1) .char-name-tag { color: var(--char-duke); }
.title-char-card:nth-child(2) .char-name-tag { color: var(--char-assassin); }
.title-char-card:nth-child(3) .char-name-tag { color: var(--char-captain); }
.title-char-card:nth-child(4) .char-name-tag { color: var(--char-ambassador); }
.title-char-card:nth-child(5) .char-name-tag { color: var(--char-contessa); }
.title-char-card:nth-child(6) .char-name-tag { color: var(--char-duke); }
.title-char-card:nth-child(7) .char-name-tag { color: var(--char-assassin); }
.title-char-card:nth-child(8) .char-name-tag { color: var(--char-captain); }
.title-char-card:nth-child(9) .char-name-tag { color: var(--char-ambassador); }
.title-char-card:nth-child(10) .char-name-tag { color: var(--char-contessa); }

/* Idle breathing animation per card (only for static images) */
.title-char-card img {
    animation: characterIdle 3s ease-in-out infinite;
}
.title-char-card video {
    animation: none;
}
.title-char-card:nth-child(2) img { animation-delay: -0.6s; }
.title-char-card:nth-child(3) img { animation-delay: -1.2s; }
.title-char-card:nth-child(4) img { animation-delay: -1.8s; }
.title-char-card:nth-child(5) img { animation-delay: -2.4s; }
.title-char-card:nth-child(6) img { animation-delay: -0.3s; }
.title-char-card:nth-child(7) img { animation-delay: -0.9s; }
.title-char-card:nth-child(8) img { animation-delay: -1.5s; }
.title-char-card:nth-child(9) img { animation-delay: -2.1s; }
.title-char-card:nth-child(10) img { animation-delay: -2.7s; }

.title-overlay {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-end;
    padding-bottom: 8%;
    z-index: 2;
    pointer-events: none;
}

.title-logo {
    font-size: clamp(36px, 10vmin, 96px);
    font-weight: bold;
    color: var(--accent-gold);
    letter-spacing: clamp(6px, 2vmin, 20px);
    text-shadow: 0 0 60px rgba(208,168,32,0.5), 0 4px 12px rgba(0,0,0,0.9);
    margin-bottom: 1%;
    pointer-events: auto;
}

.title-subtitle {
    font-size: clamp(8px, 1.6vmin, 16px);
    color: var(--text-gray);
    letter-spacing: clamp(2px, 0.8vmin, 8px);
    margin-bottom: 4%;
}

.title-buttons {
    display: flex; flex-direction: column;
    align-items: center; gap: clamp(8px, 1.5vmin, 16px);
    pointer-events: auto;
}

.title-footer {
    position: absolute; bottom: 2%; left: 0; right: 0;
    text-align: center;
    font-size: clamp(8px, 1.2vmin, 12px);
    color: var(--text-gray);
    pointer-events: auto;
}

/* ============================================================
   BUTTONS - Universal
   ============================================================ */

.btn {
    font-family: inherit;
    font-size: clamp(10px, 1.6vmin, 16px);
    font-weight: bold;
    padding: clamp(6px, 1vmin, 12px) clamp(14px, 3vmin, 32px);
    border: 2px solid var(--accent-dim);
    border-radius: 3px;
    background: var(--panel-mid);
    color: var(--text-white);
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}
.btn:hover { background: var(--panel-light); border-color: var(--accent-gold); color: var(--text-yellow); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-gold   { border-color: var(--accent-gold); color: var(--text-yellow); }
.btn-blue   { border-color: var(--accent-blue); color: var(--text-blue); }
.btn-red    { border-color: var(--accent-red); color: var(--text-red); }
.btn-green  { border-color: var(--accent-green); color: var(--text-green); }
.btn-dim    { border-color: var(--accent-dim); color: var(--text-gray); }
.btn-purple { border-color: var(--accent-purple); color: var(--text-pink); }

.btn-lg {
    font-size: clamp(14px, 2.4vmin, 24px);
    padding: clamp(10px, 1.8vmin, 20px) clamp(24px, 5vmin, 56px);
    letter-spacing: 3px;
}

.btn-play {
    animation: pulseGlow 2s ease-in-out infinite;
    border-color: var(--accent-gold);
    color: var(--text-yellow);
    background: var(--panel-select);
}

/* ============================================================
   CONNECTING SCREEN
   ============================================================ */

.screen-connecting {
    background: var(--bg-dark);
    align-items: center; justify-content: center;
}

.connecting-panel {
    background: var(--panel-dark);
    border: 2px solid var(--accent-blue);
    border-radius: 4px;
    padding: clamp(20px, 4vmin, 48px);
    text-align: center;
    width: 80%; max-width: 420px;
    position: relative;
}

.connecting-panel::before, .connecting-panel::after {
    content: ''; position: absolute;
    background: var(--accent-blue); height: 2px;
}
.connecting-panel::before { top: -1px; left: 10%; right: 10%; }
.connecting-panel::after  { bottom: -1px; left: 10%; right: 10%; }

.connecting-title {
    font-size: clamp(16px, 3vmin, 28px);
    color: var(--text-yellow);
    letter-spacing: 4px;
    margin-bottom: 8px;
}

.connecting-accent {
    width: 50%; height: 2px;
    background: var(--accent-gold);
    margin: 0 auto 16px;
}

.connecting-stage { color: var(--text-white); font-size: clamp(11px, 1.6vmin, 14px); margin-bottom: 4px; }
.connecting-detail { color: var(--text-gray); font-size: clamp(9px, 1.3vmin, 12px); margin-bottom: 16px; }

.connecting-progress-bg {
    width: 100%; height: clamp(8px, 1.4vmin, 14px);
    background: var(--panel-dark);
    border: 1px solid var(--accent-dim);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 16px;
}

.connecting-progress-bar {
    height: 100%;
    background: var(--accent-blue);
    width: 0%;
    animation: progressPulse 2s ease-in-out infinite;
    border-radius: 1px;
}

.connecting-log {
    text-align: left;
    font-size: clamp(9px, 1.2vmin, 11px);
    color: var(--text-gray);
    max-height: 60px;
    overflow-y: auto;
    margin-bottom: 16px;
    border-top: 1px solid var(--accent-dim);
    padding-top: 8px;
}

/* ============================================================
   NAME ENTRY SCREEN
   ============================================================ */

.screen-name-entry {
    background: var(--bg-dark);
    align-items: center; justify-content: center;
}

.name-panel {
    background: var(--panel-dark);
    border: 2px solid var(--accent-gold);
    border-radius: 4px;
    padding: clamp(20px, 4vmin, 40px);
    text-align: center;
    width: 85%; max-width: 400px;
}

.name-panel::before { content: ''; display: block; height: 2px; background: var(--accent-gold); margin: -20px -20px 16px; }

.name-title {
    font-size: clamp(14px, 2.4vmin, 22px);
    color: var(--text-yellow);
    letter-spacing: 3px;
    margin-bottom: 16px;
}

.name-input-wrapper {
    background: var(--panel-mid);
    border: 2px solid var(--accent-blue);
    border-radius: 3px;
    padding: clamp(8px, 1.5vmin, 14px);
    margin-bottom: 8px;
}

.name-input {
    font-family: inherit;
    font-size: clamp(16px, 2.8vmin, 26px);
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-white);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 3px;
    width: 100%;
    outline: none;
}

.name-char-hint {
    font-size: clamp(9px, 1.3vmin, 12px);
    color: var(--text-yellow);
    margin-bottom: 4px;
}

.name-hint { font-size: clamp(8px, 1.1vmin, 11px); color: var(--text-gray); margin-bottom: 8px; }
.name-error { font-size: clamp(10px, 1.4vmin, 13px); color: var(--text-red); min-height: 18px; margin-bottom: 12px; }

/* ============================================================
   LOBBY SCREEN
   ============================================================ */

.screen-lobby {
    background: var(--bg-dark);
}

.lobby-header {
    flex: 0 0 auto;
    background: var(--panel-header);
    padding: clamp(4px, 0.8vmin, 8px) clamp(8px, 1.5vmin, 16px);
    border-bottom: 2px solid var(--accent-gold);
    display: flex; align-items: center; justify-content: space-between;
}

.lobby-header-title {
    font-size: clamp(12px, 2vmin, 20px);
    color: var(--text-yellow);
    letter-spacing: 3px;
}

.lobby-header-status {
    font-size: clamp(9px, 1.3vmin, 13px);
    color: var(--text-gray);
}

.lobby-body {
    flex: 1; display: flex; flex-direction: column;
    padding: clamp(6px, 1.2vmin, 12px);
    gap: clamp(4px, 0.8vmin, 8px);
    overflow: hidden;
}

.lobby-player-list {
    flex: 1;
    overflow-y: auto;
    display: flex; flex-direction: column;
    gap: 2px;
}

.lobby-slot {
    display: flex; align-items: center;
    padding: clamp(4px, 0.8vmin, 8px) clamp(8px, 1.2vmin, 12px);
    background: var(--panel-mid);
    border-radius: 2px;
    min-height: clamp(28px, 4vmin, 40px);
    transition: background 0.2s;
}

.lobby-slot.self       { border-left: 3px solid var(--accent-blue); }
.lobby-slot.ready      { background: var(--panel-select); }
.lobby-slot.ready .lobby-slot-status { color: var(--text-green); }
.lobby-slot.bot        { border-left: 3px solid var(--accent-purple); }
.lobby-slot.empty      { background: var(--panel-dark); opacity: 0.5; }
.lobby-slot.cursor     { background: var(--panel-light); }

.lobby-slot-ready-bar {
    width: 6px; height: 100%;
    background: var(--accent-green);
    border-radius: 1px;
    margin-right: 8px;
    opacity: 0;
}
.lobby-slot.ready .lobby-slot-ready-bar { opacity: 1; }

.lobby-slot-id {
    font-size: clamp(9px, 1.2vmin, 12px);
    color: var(--text-gray);
    width: 3em;
}

.lobby-slot-name {
    flex: 1;
    font-size: clamp(11px, 1.6vmin, 15px);
    font-weight: bold;
    color: var(--text-white);
}

.lobby-slot.self .lobby-slot-name { color: var(--text-blue); }
.lobby-slot.bot .lobby-slot-name { color: var(--text-pink); }

.lobby-slot-type {
    font-size: clamp(8px, 1.1vmin, 11px);
    color: var(--accent-purple);
    margin-right: 12px;
}

.lobby-slot-status {
    font-size: clamp(9px, 1.3vmin, 13px);
    color: var(--text-gray);
    text-align: right;
    min-width: 5em;
}

.lobby-slot-difficulty {
    font-size: clamp(8px, 1.1vmin, 11px);
    margin-left: 8px;
}
.lobby-slot-difficulty.easy   { color: var(--text-green); }
.lobby-slot-difficulty.medium { color: var(--text-yellow); }
.lobby-slot-difficulty.hard   { color: var(--text-red); }

.lobby-controls {
    flex: 0 0 auto;
    background: var(--panel-dark);
    border: 1px solid var(--accent-dim);
    border-top: 2px solid var(--accent-blue);
    padding: clamp(6px, 1vmin, 12px);
    display: flex; flex-wrap: wrap;
    gap: clamp(4px, 0.8vmin, 8px);
    align-items: center; justify-content: center;
}

.lobby-log {
    flex: 0 0 auto;
    max-height: clamp(40px, 8vmin, 80px);
    overflow-y: auto;
    background: var(--panel-log);
    border: 1px solid var(--accent-dim);
    padding: clamp(4px, 0.6vmin, 6px) clamp(6px, 1vmin, 10px);
    font-size: clamp(9px, 1.2vmin, 11px);
    color: var(--text-gray);
}

.lobby-status-bar {
    flex: 0 0 auto;
    background: var(--panel-status);
    border-top: 1px solid var(--accent-dim);
    padding: clamp(4px, 0.6vmin, 6px) clamp(8px, 1.2vmin, 12px);
    display: flex; justify-content: space-between; align-items: center;
    font-size: clamp(9px, 1.3vmin, 13px);
}

.lobby-status-left { color: var(--text-gray); }
.lobby-status-right { color: var(--text-yellow); }
.lobby-status-right.all-ready { color: var(--text-green); }

/* ============================================================
   GAME SCREEN - 5 regions
   ============================================================ */

.screen-game {
    background: var(--bg-grid);
}

.game-header-bar {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: var(--panel-header);
    border-bottom: 1px solid var(--accent-dim);
}

.game-header-buttons {
    display: flex;
    gap: 6px;
}

.game-header-bar .game-turn-label {
    font-size: clamp(10px, 1.4vmin, 14px);
    color: var(--text-gray);
    letter-spacing: 1px;
}

.game-header-bar .game-turn-label.my-turn {
    color: var(--text-green);
    font-weight: bold;
}

.btn-sm {
    font-size: clamp(11px, 1.4vmin, 14px);
    padding: clamp(5px, 0.8vmin, 8px) clamp(10px, 1.6vmin, 16px);
    min-height: 32px;
}

.btn-green.btn-sm {
    background: var(--panel-select);
    border-color: var(--accent-green);
    color: var(--text-green);
    font-weight: bold;
}

.game-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.6fr) minmax(0, 1fr);
    grid-template-rows: 1fr auto;
    grid-template-areas:
        "left   center right"
        "log    log    log";
    gap: 2px;
}

/* --- Game Log (bottom, spans all columns, scrollable) --- */
.game-log-panel {
    grid-area: log;
    background: var(--panel-log);
    padding: clamp(4px, 0.6vmin, 6px) clamp(6px, 1vmin, 10px);
    min-height: 60px;
    max-height: clamp(80px, 15vmin, 140px);
    overflow-y: auto;
    position: relative;
    font-size: clamp(10px, 1.4vmin, 13px);
    line-height: 1.4;
    border-top: 2px solid var(--accent-green);
}

.game-log-panel .log-line {
    padding: 1px 0;
    color: var(--text-gray);
}
.game-log-panel .log-line:last-child { color: var(--text-white); }
.game-log-panel .log-line.event-challenge { color: var(--text-red); }
.game-log-panel .log-line.event-block { color: var(--text-pink); }
.game-log-panel .log-line.event-action { color: var(--text-yellow); }

.log-scroll-hint {
    position: sticky; bottom: 0; right: 0;
    text-align: right;
    font-size: 10px;
    color: var(--text-yellow);
}

/* --- Left Seats --- */
.game-seats-col {
    display: flex; flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

/* --- Grid area assignments --- */
#seats-left { grid-area: left; }
#seats-right { grid-area: right; }

/* --- Center Column --- */
.game-center-col {
    grid-area: center;
    display: flex; flex-direction: column;
    gap: 2px;
}

.game-phase-panel {
    flex: 1;
    background: var(--panel-dark);
    border: 1px solid var(--accent-dim);
    display: flex; flex-direction: column;
    overflow: hidden;
    position: relative;
}

.phase-title-bar {
    flex: 0 0 auto;
    padding: clamp(3px, 0.5vmin, 6px) clamp(6px, 1vmin, 10px);
    background: var(--panel-header);
    border-bottom: 2px solid var(--accent-gold);
    font-size: clamp(10px, 1.4vmin, 14px);
    color: var(--text-yellow);
    font-weight: bold;
    letter-spacing: 1px;
}

.phase-title-bar.accent-red    { border-bottom-color: var(--accent-red); }
.phase-title-bar.accent-blue   { border-bottom-color: var(--accent-blue); }
.phase-title-bar.accent-purple { border-bottom-color: var(--accent-purple); }
.phase-title-bar.accent-green  { border-bottom-color: var(--accent-green); }

.phase-body {
    flex: 1;
    padding: clamp(4px, 0.8vmin, 8px);
    display: flex; flex-direction: column;
    gap: clamp(2px, 0.4vmin, 4px);
    overflow-y: auto;
}

.phase-menu-item {
    display: flex; align-items: center;
    padding: clamp(3px, 0.6vmin, 6px) clamp(6px, 1vmin, 10px);
    background: var(--panel-mid);
    border: 1px solid transparent;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: clamp(10px, 1.4vmin, 14px);
}

.phase-menu-item:hover { background: var(--panel-light); border-color: var(--accent-gold); }
.phase-menu-item.selected { background: var(--panel-select); border-color: var(--accent-green); }
.phase-menu-item.disabled { opacity: 0.3; cursor: default; }

.phase-menu-item .item-label { flex: 1; font-weight: bold; }
.phase-menu-item .item-detail { color: var(--text-gray); font-size: clamp(8px, 1.1vmin, 11px); margin-left: 8px; }
.phase-menu-item .item-cost { color: var(--text-yellow); margin-left: 8px; }

.phase-menu-item.char-duke      .item-label { color: var(--char-duke); }
.phase-menu-item.char-assassin  .item-label { color: var(--char-assassin); }
.phase-menu-item.char-captain   .item-label { color: var(--char-captain); }
.phase-menu-item.char-ambassador .item-label { color: var(--char-ambassador); }
.phase-menu-item.char-contessa  .item-label { color: var(--char-contessa); }

/* Timer bar */
.phase-timer {
    flex: 0 0 auto;
    height: clamp(3px, 0.5vmin, 5px);
    background: var(--panel-dark);
    border-top: 1px solid var(--accent-dim);
}

.phase-timer-bar {
    height: 100%;
    background: var(--accent-red);
    transition: width 0.5s linear;
}

.phase-timer-bar.blue   { background: var(--accent-blue); }
.phase-timer-bar.purple { background: var(--accent-purple); }

/* Status bar below phase panel */
.game-status-bar {
    flex: 0 0 auto;
    background: var(--panel-status);
    padding: clamp(2px, 0.4vmin, 4px) clamp(6px, 1vmin, 10px);
    text-align: center;
    font-size: clamp(10px, 1.4vmin, 14px);
    color: var(--text-gray);
    letter-spacing: 1px;
    border: 1px solid var(--accent-dim);
}
.game-status-bar.my-turn { background: var(--panel-my-turn); color: var(--text-green); font-weight: bold; }

/* --- Opponent Seat --- */

.seat {
    flex: 1;
    background: var(--panel-dark);
    border: 1px solid var(--accent-dim);
    padding: clamp(2px, 0.4vmin, 4px);
    display: flex; flex-direction: column;
    overflow: hidden;
    min-height: 0;
    transition: all 0.2s;
}

.seat.active-turn { background: var(--panel-prompt); border-color: var(--accent-blue); }
.seat.dead { opacity: 0.35; }

.seat-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: clamp(1px, 0.2vmin, 3px);
}

.seat-name {
    font-size: clamp(8px, 1.1vmin, 12px);
    font-weight: bold;
    color: var(--text-white);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 70%;
}
.seat.dead .seat-name { color: var(--text-gray); }

.seat-coins {
    font-size: clamp(9px, 1.2vmin, 13px);
    color: var(--text-yellow);
    font-weight: bold;
}
.seat.dead .seat-coins { display: none; }

.seat-dead-label {
    display: none;
    font-size: clamp(8px, 1.1vmin, 11px);
    color: var(--text-red);
    font-weight: bold;
}
.seat.dead .seat-dead-label { display: inline; }

.seat-cards {
    display: flex; gap: clamp(2px, 0.3vmin, 4px);
    flex: 1;
    min-height: 0;
}

.seat-card {
    flex: 1;
    border: 2px solid var(--accent-dim);
    border-radius: 2px;
    background: var(--panel-mid);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: clamp(24px, 4vmin, 48px);
    overflow: hidden;
    position: relative;
}

.seat-card.revealed { background: var(--panel-dark); border-style: dashed; opacity: 0.5; }
.seat-card .card-abbrev {
    font-size: clamp(18px, 4vmin, 28px);
    font-weight: bold;
    color: var(--text-yellow);
    text-shadow: 0 0 10px rgba(249, 226, 175, 0.8), 0 0 20px rgba(208, 168, 32, 0.4);
    letter-spacing: 1px;
}

.seat-card .card-abbrev.revealed-abbrev {
    color: var(--text-gray);
    text-shadow: none;
    opacity: 0.7;
}

/* --- My Hand Panel (inside center column) --- */

.game-hand-panel {
    flex: 0 0 auto;
    background: var(--panel-dark);
    border-top: 2px solid var(--accent-gold);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(6px, 1vmin, 12px);
    gap: clamp(4px, 0.6vmin, 8px);
    min-height: clamp(120px, 22vmin, 200px);
}

.game-hand-panel.my-turn { background: var(--panel-my-turn); border-top-color: var(--accent-green); }

/* Hand info bar (name + coins above cards) */
.hand-info-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 2vmin, 20px);
    width: 100%;
}

.hand-info-bar .hand-player-name {
    font-size: clamp(12px, 1.8vmin, 18px);
}

.hand-info-bar .hand-coins {
    font-size: clamp(14px, 2.2vmin, 22px);
}

/* Large character portrait cards */
.hand-cards {
    display: flex;
    gap: clamp(10px, 2vmin, 24px);
    justify-content: center;
}

.hand-card {
    width: clamp(100px, 16vmin, 160px);
    height: clamp(130px, 22vmin, 200px);
    border: 3px solid var(--accent-dim);
    border-radius: 4px;
    background: var(--panel-mid);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.hand-card:hover:not(.revealed) {
    transform: translateY(-4px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.6);
}

.hand-card.revealed {
    opacity: 0.35;
    cursor: default;
    border-style: dashed;
}

.hand-card .card-portrait {
    width: 90%; height: 78%;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(255,255,255,0.15));
    pointer-events: none;
}

.hand-card video.card-portrait {
    border-radius: 2px;
}

.hand-card:not(.revealed) img.card-portrait {
    animation: characterIdle 3s ease-in-out infinite;
}

.hand-card:nth-child(2):not(.revealed) img.card-portrait {
    animation-delay: -1.5s;
}

.hand-card .card-char-name {
    font-size: clamp(9px, 1.3vmin, 14px);
    font-weight: bold;
    letter-spacing: 1px;
    margin-top: 2px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.hand-card.revealed .card-char-name::after {
    content: ' (DEAD)';
    color: var(--text-red);
}

/* Card glow ring for character color */
.hand-card::after {
    content: '';
    position: absolute; inset: -1px;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0.3;
}
.hand-card.char-duke::after      { box-shadow: inset 0 0 20px var(--char-duke); }
.hand-card.char-assassin::after  { box-shadow: inset 0 0 20px var(--char-assassin); }
.hand-card.char-captain::after   { box-shadow: inset 0 0 20px var(--char-captain); }
.hand-card.char-ambassador::after{ box-shadow: inset 0 0 20px var(--char-ambassador); }
.hand-card.char-contessa::after  { box-shadow: inset 0 0 20px var(--char-contessa); }

.hand-info {
    flex: 1;
    display: flex; flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: clamp(2px, 0.4vmin, 6px);
    min-width: 0;
}

.hand-player-name {
    font-size: clamp(11px, 1.6vmin, 16px);
    font-weight: bold;
    color: var(--text-white);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.game-hand-panel.my-turn .hand-player-name { color: var(--text-green); }

.hand-coins {
    font-size: clamp(18px, 3.5vmin, 36px);
    font-weight: bold;
    color: var(--text-yellow);
    display: flex; align-items: center; gap: 4px;
}

.coin-symbol {
    display: inline-block;
    width: clamp(14px, 2.4vmin, 24px);
    height: clamp(14px, 2.4vmin, 24px);
    background: radial-gradient(circle at 35% 35%, #F0D040, #A08010);
    border-radius: 50%;
    border: 2px solid #A08010;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.hand-spectator {
    font-size: clamp(12px, 2vmin, 18px);
    color: var(--text-pink);
    letter-spacing: 3px;
    font-weight: bold;
}

.hand-dead-label {
    font-size: clamp(14px, 2.4vmin, 22px);
    color: var(--text-red);
    font-weight: bold;
    letter-spacing: 3px;
}

/* --- Corner panels --- */
.game-corner-left, .game-corner-right {
    background: var(--panel-status);
    border: 1px solid var(--accent-dim);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
}
.game-corner-left:hover, .game-corner-right:hover { background: var(--panel-light); }

.corner-label {
    font-size: clamp(8px, 1.1vmin, 12px);
    color: var(--text-gray);
    letter-spacing: 1px;
}

/* ============================================================
   RULES OVERLAY
   ============================================================ */

.rules-overlay {
    position: absolute; inset: 0;
    background: rgba(8, 8, 26, 0.95);
    z-index: 100;
    display: flex; flex-direction: column;
    animation: screenFadeIn 0.2s ease-out;
}

.rules-header {
    flex: 0 0 auto;
    background: var(--panel-header);
    padding: clamp(4px, 0.8vmin, 8px) clamp(8px, 1.5vmin, 16px);
    border-bottom: 2px solid var(--accent-gold);
    display: flex; justify-content: space-between; align-items: center;
}

.rules-title {
    font-size: clamp(12px, 2vmin, 20px);
    color: var(--text-white);
    letter-spacing: 2px;
}

.rules-page-indicator {
    font-size: clamp(9px, 1.3vmin, 13px);
    color: var(--text-gray);
}

.rules-body {
    flex: 1;
    overflow-y: auto;
    padding: clamp(10px, 2.5vmin, 24px);
}

.rules-section {
    margin-bottom: clamp(12px, 2vmin, 20px);
}

.rules-section-title {
    font-size: clamp(14px, 2.2vmin, 20px);
    font-weight: bold;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--accent-dim);
}

.rules-char-row {
    display: flex;
    align-items: center;
    gap: clamp(6px, 1vmin, 12px);
    padding: clamp(4px, 0.6vmin, 8px);
    margin-bottom: 4px;
    background: var(--panel-dark);
    border-radius: 3px;
    border-left: 4px solid var(--accent-dim);
}

.rules-char-row.duke      { border-left-color: var(--char-duke); }
.rules-char-row.assassin  { border-left-color: var(--char-assassin); }
.rules-char-row.captain   { border-left-color: var(--char-captain); }
.rules-char-row.ambassador{ border-left-color: var(--char-ambassador); }
.rules-char-row.contessa  { border-left-color: var(--char-contessa); }

.rules-char-portrait {
    width: clamp(56px, 10vmin, 90px);
    height: clamp(72px, 13vmin, 115px);
    object-fit: contain;
    flex: 0 0 auto;
    pointer-events: none;
}

.rules-char-info { flex: 1; }
.rules-char-name {
    font-weight: bold;
    font-size: clamp(13px, 1.9vmin, 18px);
    margin-bottom: 2px;
}
.rules-char-ability {
    font-size: clamp(11px, 1.6vmin, 15px);
    color: var(--text-gray);
}
.rules-char-blocks {
    font-size: clamp(10px, 1.4vmin, 13px);
    color: var(--text-dim);
    font-style: italic;
}

.rules-text {
    font-size: clamp(13px, 1.9vmin, 17px);
    color: var(--text-gray);
    line-height: 1.6;
}
.rules-text strong { color: var(--text-white); }
.rules-text .highlight { color: var(--text-yellow); }

.rules-nav {
    flex: 0 0 auto;
    background: var(--panel-dark);
    border-top: 2px solid var(--accent-blue);
    padding: clamp(6px, 1vmin, 10px);
    display: flex; justify-content: center; gap: clamp(6px, 1vmin, 12px);
    align-items: center;
}

/* ============================================================
   GAME OVER SCREEN
   ============================================================ */

.screen-game-over {
    background: var(--bg-dark);
    align-items: center; justify-content: center;
}

.gameover-bg {
    position: absolute; inset: 0;
    background-size: cover; background-position: center;
    opacity: 0.5;
}
.gameover-bg.victory { background-image: url('../assets/winscreen.png'); }
.gameover-bg.defeat  { background-image: url('../assets/Coup%20Game%20Over.png'); }

.gameover-content {
    position: relative; z-index: 1;
    text-align: center;
    display: flex; flex-direction: column;
    align-items: center; gap: clamp(12px, 3vmin, 32px);
}

.gameover-title {
    font-size: clamp(28px, 8vmin, 72px);
    color: var(--accent-gold);
    text-shadow: 0 0 40px rgba(208,168,32,0.6), 0 4px 8px rgba(0,0,0,0.9);
    letter-spacing: clamp(4px, 1.5vmin, 12px);
    animation: pulseGlow 2s ease-in-out infinite;
}

.gameover-portrait {
    width: clamp(80px, 16vmin, 160px);
    height: clamp(100px, 20vmin, 200px);
    object-fit: contain;
    filter: drop-shadow(0 0 24px rgba(208,168,32,0.4));
    animation: characterIdle 3s ease-in-out infinite;
}

.gameover-winner {
    font-size: clamp(14px, 3vmin, 28px);
    color: var(--text-white);
    letter-spacing: 2px;
}

.gameover-subtitle {
    font-size: clamp(10px, 1.6vmin, 16px);
    color: var(--text-gray);
    letter-spacing: 1px;
}

/* ============================================================
   VIDEO - hide mobile play button overlay
   ============================================================ */

video::-webkit-media-controls-start-playback-button,
video::-webkit-media-controls-panel,
video::-webkit-media-controls {
    display: none !important;
    -webkit-appearance: none;
}
video::-webkit-media-controls-overlay-play-button {
    display: none !important;
}

/* ============================================================
   FULLSCREEN CARD OVERLAY
   ============================================================ */

.card-fullscreen-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    cursor: pointer;
    animation: screenFadeIn 0.2s ease-out;
}

.card-fullscreen-overlay video {
    max-width: 90vw;
    max-height: 75vh;
    object-fit: contain;
    border: 3px solid var(--accent-gold);
    border-radius: 8px;
    box-shadow: 0 0 60px rgba(208, 168, 32, 0.4);
}

.card-fullscreen-overlay .card-fullscreen-name {
    margin-top: 16px;
    font-size: clamp(18px, 4vmin, 32px);
    font-weight: bold;
    letter-spacing: 3px;
    text-shadow: 0 0 12px currentColor;
}

.card-fullscreen-overlay .card-fullscreen-hint {
    margin-top: 8px;
    font-size: clamp(10px, 1.6vmin, 14px);
    color: var(--text-gray);
}

/* Seat zoom overlay */
.seat-zoom-name {
    font-size: clamp(22px, 5vmin, 40px);
    font-weight: bold;
    color: var(--text-white);
    letter-spacing: 3px;
    text-shadow: 0 0 12px rgba(255,255,255,0.3);
}
.seat-zoom-name.active {
    color: var(--text-blue);
    text-shadow: 0 0 16px rgba(137, 180, 250, 0.6);
}

.seat-zoom-coins {
    font-size: clamp(18px, 4vmin, 32px);
    color: var(--text-yellow);
    font-weight: bold;
    margin: 8px 0 16px;
    text-shadow: 0 0 8px rgba(249, 226, 175, 0.5);
}

.seat-zoom-cards {
    display: flex;
    gap: clamp(12px, 3vmin, 24px);
    justify-content: center;
    margin-bottom: 16px;
}

.seat-zoom-card {
    width: clamp(120px, 28vmin, 200px);
    height: clamp(160px, 38vmin, 280px);
    border: 3px solid var(--accent-dim);
    border-radius: 8px;
    background: var(--panel-mid);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    overflow: hidden;
    position: relative;
}

.seat-zoom-portrait {
    width: 90%;
    height: 70%;
    object-fit: contain;
    pointer-events: none;
}

.seat-zoom-abbrev {
    font-size: clamp(36px, 10vmin, 64px);
    font-weight: bold;
    color: var(--text-yellow);
    text-shadow: 0 0 16px rgba(249, 226, 175, 0.8), 0 0 32px rgba(208, 168, 32, 0.5);
}

.seat-zoom-label {
    font-size: clamp(12px, 2vmin, 18px);
    font-weight: bold;
    letter-spacing: 2px;
}

.seat-zoom-status {
    font-size: clamp(9px, 1.4vmin, 12px);
    color: var(--text-red);
    font-weight: bold;
    letter-spacing: 1px;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--panel-dark); }
::-webkit-scrollbar-thumb { background: var(--accent-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes screenFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scrollCharacters {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

@keyframes characterIdle {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.03) translateY(-2px); }
}

@keyframes pulseGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

@keyframes progressPulse {
    0% { width: 5%; }
    50% { width: 80%; }
    100% { width: 5%; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============================================================
   RESPONSIVE - Tablet (601-900px)
   ============================================================ */

@media (max-width: 900px) {
    .game-layout {
        grid-template-columns: minmax(0, 1fr) minmax(0, 3fr) minmax(0, 1fr);
    }

    .btn { min-height: 40px; }
    .phase-menu-item { min-height: 40px; }
    .lobby-slot { min-height: 40px; }

    /* Title cards bigger on tablet/iPad */
    .title-char-card {
        width: 40vw;
    }

    /* Hand cards bigger on tablet/iPad */
    .hand-card {
        width: clamp(120px, 18vmin, 170px);
        height: clamp(160px, 24vmin, 220px);
    }

    .hand-card .card-char-name {
        font-size: clamp(11px, 1.6vmin, 15px);
    }

    /* Seat card abbreviations bigger on tablet */
    .seat-card .card-abbrev {
        font-size: clamp(20px, 3.5vmin, 28px);
    }

    /* Seat zoom cards bigger on iPad */
    .seat-zoom-card {
        width: clamp(160px, 30vmin, 240px);
        height: clamp(220px, 40vmin, 320px);
    }

    .seat-zoom-abbrev {
        font-size: clamp(42px, 10vmin, 72px);
    }
}

/* ============================================================
   RESPONSIVE - Mobile (<=600px)
   ============================================================ */

@media (max-width: 600px) {
    /* Title screen - 2.5x bigger portraits */
    .title-char-card {
        width: 70vw;
    }
    .title-character-parade {
        height: 55%;
    }
    .title-char-card .char-name-tag {
        font-size: clamp(14px, 3vw, 20px);
    }

    /* Switch game from grid to stacked column */
    .game-layout {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }

    #seats-left { order: 0; flex: 0 0 auto; }
    #seats-right { order: 1; flex: 0 0 auto; }

    .game-seats-col {
        flex-direction: row;
        overflow-x: auto;
        gap: 2px;
    }

    .seat {
        flex: 0 0 110px;
        min-height: 60px;
    }

    .game-center-col {
        order: 2;
        flex: 1 1 auto;
        min-height: 200px;
        overflow: hidden;
    }

    .game-hand-panel {
        min-height: 260px;
    }

    /* Hand cards - 2.5x bigger on mobile */
    .hand-card {
        width: 42vw;
        height: 56vw;
    }

    .hand-card .card-char-name {
        font-size: clamp(12px, 3vw, 16px);
    }

    .hand-card .card-portrait {
        width: 92%;
        height: 80%;
    }

    .game-log-panel {
        order: 3;
        flex: 0 0 auto;
        min-height: 60px;
        max-height: 120px;
        border-top: 2px solid var(--accent-green);
    }

    /* Touch-friendly targets (44px minimum) */
    .btn {
        min-height: 44px;
        padding: 10px 16px;
        font-size: clamp(12px, 2vmin, 16px);
    }

    .phase-menu-item {
        min-height: 44px;
        padding: 8px 12px;
        font-size: clamp(12px, 1.8vmin, 14px);
    }

    .btn-sm {
        min-height: 36px;
        font-size: 12px;
    }

    /* Lobby */
    .lobby-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .lobby-controls .btn {
        width: 100%;
        text-align: center;
        min-height: 44px;
    }

    .lobby-slot {
        min-height: 44px;
        padding: 8px 12px;
    }

    /* Font minimums */
    .lobby-slot-name { font-size: clamp(13px, 2vmin, 15px); }
    .lobby-slot-id { font-size: clamp(11px, 1.5vmin, 12px); }
    .lobby-slot-status { font-size: clamp(11px, 1.5vmin, 13px); }
    .seat-name { font-size: clamp(10px, 1.4vmin, 12px); }
    .seat-card .card-abbrev { font-size: clamp(20px, 5vw, 28px); }
    .game-log-panel { font-size: clamp(11px, 1.6vmin, 13px); }

    /* Rules overlay - bigger on mobile */
    .rules-body { padding: clamp(12px, 3vmin, 20px); }
    .rules-text { font-size: clamp(14px, 3vmin, 17px); }
    .rules-section-title { font-size: clamp(15px, 3vmin, 20px); }
    .rules-char-portrait {
        width: clamp(64px, 14vmin, 90px);
        height: clamp(80px, 18vmin, 115px);
    }
    .rules-char-name { font-size: clamp(14px, 2.5vmin, 18px); }
    .rules-char-ability { font-size: clamp(12px, 2vmin, 15px); }
    .rules-char-blocks { font-size: clamp(11px, 1.8vmin, 13px); }
}

/* ============================================================
   LOG OVERLAY (full-screen scrollable game log)
   ============================================================ */

.log-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(8, 8, 26, 0.97);
    display: flex;
    flex-direction: column;
    animation: screenFadeIn 0.2s ease-out;
}

.log-overlay-header {
    flex: 0 0 auto;
    background: var(--panel-header);
    padding: clamp(6px, 1vmin, 10px) clamp(8px, 1.5vmin, 16px);
    border-bottom: 2px solid var(--accent-green);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-overlay-title {
    font-size: clamp(14px, 2.2vmin, 20px);
    color: var(--text-green);
    letter-spacing: 2px;
    font-weight: bold;
}

.log-overlay-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: clamp(10px, 2vmin, 20px);
    font-size: clamp(13px, 1.8vmin, 16px);
    line-height: 1.7;
}

.log-overlay-body .log-line {
    padding: clamp(4px, 0.6vmin, 6px) 0;
    color: var(--text-gray);
    border-bottom: 1px solid rgba(48, 48, 80, 0.3);
}

.log-overlay-body .log-line:last-child { color: var(--text-white); }
.log-overlay-body .log-line.event-challenge { color: var(--text-red); }
.log-overlay-body .log-line.event-block { color: var(--text-pink); }
.log-overlay-body .log-line.event-action { color: var(--text-yellow); }

/* ============================================================
   UTILITY
   ============================================================ */

.hidden { display: none !important; }
.text-gold { color: var(--text-yellow); }
.text-green { color: var(--text-green); }
.text-red { color: var(--text-red); }
.text-blue { color: var(--text-blue); }
.text-gray { color: var(--text-gray); }
.text-pink { color: var(--text-pink); }
