/* ===== CSS Variables ===== */
:root {
    --p1-color: #3498db;
    --p1-glow: #5dade2;
    --p1-bg-1: #1a2a4a;
    --p1-bg-2: #0d1525;
    --p1-border: rgba(52, 152, 219, 0.25);

    --p2-color: #e74c3c;
    --p2-glow: #ec7063;
    --p2-bg-1: #4a1a1a;
    --p2-bg-2: #250d0d;
    --p2-border: rgba(231, 76, 60, 0.25);

    --gold: #ffd700;
    --gold-glow: rgba(255, 215, 0, 0.45);
    --over-max: #bb33ff;
    --over-max-glow: rgba(187, 51, 255, 0.5);

    --hp-color: #e74c3c;
    --hp-glow: rgba(231, 76, 60, 0.4);
    --hp-heal: #2ecc71;
    --hp-heal-glow: rgba(46, 204, 113, 0.4);

    --next-ball: #00bfff;
    --next-ball-glow: rgba(0, 191, 255, 0.4);

    --pending-color: #f39c12;
    --pending-glow: rgba(243, 156, 18, 0.3);

    --text: #ecf0f1;
    --text-muted: #7f8c8d;
    --bg-dark: #0a0a14;
}

/* ===== Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    touch-action: manipulation;
}

/* ===== Setup Screen ===== */
.setup-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, var(--bg-dark) 100%);
    z-index: 50;
    padding: 20px;
}

.setup-screen.hidden { display: none; }

.setup-content {
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.setup-title {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 30px var(--gold-glow);
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.setup-subtitle {
    color: var(--text-muted);
    font-size: clamp(0.8rem, 3vw, 1rem);
    margin-bottom: 30px;
}

.setup-players {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.setup-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    flex: 1;
    max-width: 160px;
}

.setup-p1 {
    border-color: var(--p1-border);
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.08), transparent);
}

.setup-p2 {
    border-color: var(--p2-border);
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.08), transparent);
}

.setup-badge {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
}

.setup-p1 .setup-badge {
    background: linear-gradient(135deg, var(--p1-color), #1a5276);
    box-shadow: 0 0 16px rgba(52, 152, 219, 0.4);
}

.setup-p2 .setup-badge {
    background: linear-gradient(135deg, var(--p2-color), #922b21);
    box-shadow: 0 0 16px rgba(231, 76, 60, 0.4);
}

.setup-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.setup-player input[type="number"] {
    width: 80px;
    padding: 10px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    outline: none;
    -webkit-user-select: text;
    user-select: text;
}

.setup-player input[type="number"]:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

.setup-player input::-webkit-outer-spin-button,
.setup-player input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.setup-vs {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-muted);
}

.setup-hint {
    color: var(--text-muted);
    font-size: clamp(0.7rem, 2.5vw, 0.78rem);
    margin-bottom: 24px;
    line-height: 1.5;
}

.start-btn {
    padding: 14px 48px;
    border-radius: 30px;
    border: none;
    background: linear-gradient(135deg, var(--gold), #e6b800);
    color: #000;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--gold-glow);
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 0.05em;
}

.start-btn:active { transform: scale(0.96); }

/* ===== Layout ===== */
#game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

#game-container.hidden { display: none; }

.player-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    min-height: 0;
    transition: opacity 0.3s, filter 0.3s;
}

/* Mobile: P2 rotated 180° */
.player-2 {
    transform: rotate(180deg);
    background: radial-gradient(ellipse at center, var(--p2-bg-1) 0%, var(--p2-bg-2) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.player-1 {
    background: radial-gradient(ellipse at center, var(--p1-bg-1) 0%, var(--p1-bg-2) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Inactive player dimmed */
.player-side.inactive {
    opacity: 0.45;
    filter: saturate(0.6);
}

/* ===== Tap Zone ===== */
.tap-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(3px, 0.8vh, 8px);
    padding: clamp(6px, 1.5vh, 12px);
    cursor: pointer;
    position: relative;
    transition: background 0.3s;
}

.tap-zone:active {
    background: rgba(255, 255, 255, 0.03);
}

.player-side.inactive .tap-zone {
    cursor: default;
}

/* Active player glow */
.player-1 .tap-zone.active::before,
.player-2 .tap-zone.active::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-radius: 12px;
    animation: readyPulse 2s ease-in-out infinite;
    pointer-events: none;
}

.player-1 .tap-zone.active::before {
    border-color: var(--p1-glow);
    box-shadow: inset 0 0 30px rgba(93, 173, 226, 0.15);
}

.player-2 .tap-zone.active::before {
    border-color: var(--p2-glow);
    box-shadow: inset 0 0 30px rgba(236, 112, 99, 0.15);
}

@keyframes readyPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ===== Player Header ===== */
.player-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: clamp(0.7rem, 2.2vw, 0.85rem);
    width: 100%;
    justify-content: space-between;
    padding: 0 4px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.75rem;
    color: #fff;
    position: relative;
    flex-shrink: 0;
}

.p1-badge {
    background: linear-gradient(135deg, var(--p1-color), #1a5276);
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.4);
}

.p2-badge {
    background: linear-gradient(135deg, var(--p2-color), #922b21);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.4);
}

.player-badge.first::after {
    content: '★';
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 0.85rem;
    color: var(--gold);
    text-shadow: 0 0 6px var(--gold-glow);
}

.player-name {
    font-weight: 700;
    font-size: clamp(0.85rem, 3vw, 1.1rem);
    letter-spacing: 0.05em;
}

.round-badge {
    background: rgba(255, 255, 255, 0.08);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: clamp(0.7rem, 2.2vw, 0.85rem);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-weight: 600;
    flex-shrink: 0;
}

/* ===== HP Bar (prominent) ===== */
.hp-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: center;
    padding: 4px 0;
}

.hp-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hp-btn:active { transform: scale(0.9); }

.hp-minus {
    border-color: rgba(231, 76, 60, 0.25);
    color: var(--p2-glow);
    background: rgba(231, 76, 60, 0.08);
}

.hp-minus:active { background: rgba(231, 76, 60, 0.25); }

.hp-plus {
    border-color: rgba(46, 204, 113, 0.25);
    color: var(--hp-heal);
    background: rgba(46, 204, 113, 0.08);
}

.hp-plus:active { background: rgba(46, 204, 113, 0.25); }

.hp-display {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 4px 16px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(231, 76, 60, 0.2);
    min-width: 120px;
    justify-content: center;
}

.hp-icon {
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: var(--hp-color);
    text-shadow: 0 0 8px var(--hp-glow);
    line-height: 1;
}

.hp-number {
    font-size: clamp(2rem, 7vw, 2.8rem);
    font-weight: 900;
    line-height: 1;
    color: var(--hp-color);
    text-shadow: 0 0 10px var(--hp-glow);
    font-variant-numeric: tabular-nums;
    transition: color 0.3s;
}

.hp-number.damaged {
    animation: hpShake 0.4s ease-out;
}

.hp-number.healed {
    animation: hpPulse 0.4s ease-out;
    color: var(--hp-heal);
    text-shadow: 0 0 10px var(--hp-heal-glow);
}

.hp-number.zero {
    color: #555;
    text-shadow: none;
    animation: hpDeath 0.6s ease-out;
}

@keyframes hpShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes hpPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

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

.hp-max {
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    color: var(--text-muted);
    font-weight: 600;
}

/* ===== Cost Row ===== */
.cost-row {
    display: flex;
    align-items: center;
    gap: clamp(8px, 3vw, 16px);
}

.cost-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.cost-number {
    font-size: clamp(3rem, 13vh, 6.5rem);
    font-weight: 900;
    line-height: 1;
    color: var(--gold);
    text-shadow:
        0 0 20px var(--gold-glow),
        0 0 40px var(--gold-glow),
        0 2px 4px rgba(0, 0, 0, 0.5);
    transition: color 0.3s, text-shadow 0.3s;
    font-variant-numeric: tabular-nums;
}

.cost-number.over-max {
    color: var(--over-max);
    text-shadow:
        0 0 20px var(--over-max-glow),
        0 0 40px var(--over-max-glow),
        0 2px 4px rgba(0, 0, 0, 0.5);
}

.cost-number.changing {
    animation: costPulse 0.5s ease-out;
}

@keyframes costPulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

.cost-label {
    font-size: clamp(0.6rem, 1.8vw, 0.75rem);
    color: var(--text-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* ===== Next Round Ball ===== */
.next-ball {
    width: clamp(44px, 11vw, 60px);
    height: clamp(44px, 11vw, 60px);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 30%, rgba(0, 191, 255, 0.2), rgba(0, 191, 255, 0.05));
    border: 2px solid var(--next-ball);
    box-shadow: 0 0 16px var(--next-ball-glow), inset 0 0 10px rgba(0, 191, 255, 0.1);
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
}

.next-ball.at-max {
    border-color: var(--over-max);
    background: radial-gradient(circle at 30% 30%, rgba(187, 51, 255, 0.2), rgba(187, 51, 255, 0.05));
    box-shadow: 0 0 16px var(--over-max-glow), inset 0 0 10px rgba(187, 51, 255, 0.1);
}

.next-ball-num {
    font-size: clamp(0.9rem, 3.5vw, 1.3rem);
    font-weight: 900;
    color: var(--next-ball);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.next-ball.at-max .next-ball-num { color: var(--over-max); }

.next-ball-label {
    font-size: clamp(0.45rem, 1.5vw, 0.58rem);
    color: var(--text-muted);
    margin-top: 1px;
}

/* ===== Cost Detail ===== */
.cost-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: clamp(0.65rem, 2vw, 0.8rem);
    color: var(--text-muted);
    flex-wrap: wrap;
    justify-content: center;
}

.detail-item strong {
    color: var(--text);
    font-weight: 700;
    margin-left: 3px;
}

.detail-item.pending strong {
    color: var(--pending-color);
}

.detail-item.pending.has-pending {
    background: rgba(243, 156, 18, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid rgba(243, 156, 18, 0.2);
}

.detail-item.pending:not(.has-pending) {
    opacity: 0.4;
}

.detail-divider {
    width: 1px;
    height: 12px;
    background: rgba(255, 255, 255, 0.15);
}

.cost-cap {
    color: var(--over-max) !important;
    font-weight: 700;
}

.cost-cap:empty { display: none; }

/* ===== Sequence Bar ===== */
.sequence-bar {
    display: flex;
    gap: clamp(2px, 0.6vw, 4px);
    justify-content: center;
    flex-wrap: nowrap;
    padding: 2px 0;
    max-width: 100%;
}

.seq-step {
    width: clamp(18px, 4.5vw, 26px);
    height: clamp(18px, 4.5vw, 26px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.5rem, 1.6vw, 0.65rem);
    font-weight: 700;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.seq-step.done {
    background: rgba(255, 215, 0, 0.12);
    color: rgba(255, 215, 0, 0.5);
    border-color: rgba(255, 215, 0, 0.15);
}

.seq-step.active {
    background: var(--gold);
    color: #000;
    border-color: var(--gold);
    box-shadow: 0 0 10px var(--gold-glow);
    transform: scale(1.25);
}

.seq-step.max-active {
    background: var(--over-max);
    color: #fff;
    border-color: var(--over-max);
    box-shadow: 0 0 10px var(--over-max-glow);
    transform: scale(1.25);
}

/* ===== Turn Indicator ===== */
.turn-indicator {
    margin-top: 2px;
    padding: 6px 18px;
    border-radius: 24px;
    font-size: clamp(0.7rem, 2.2vw, 0.85rem);
    font-weight: 600;
    letter-spacing: 0.05em;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.player-1 .turn-indicator.active {
    background: rgba(52, 152, 219, 0.15);
    border-color: var(--p1-color);
    color: var(--p1-glow);
    box-shadow: 0 0 12px rgba(52, 152, 219, 0.2);
}

.player-2 .turn-indicator.active {
    background: rgba(231, 76, 60, 0.15);
    border-color: var(--p2-color);
    color: var(--p2-glow);
    box-shadow: 0 0 12px rgba(231, 76, 60, 0.2);
}

.turn-indicator.waiting {
    background: rgba(39, 174, 96, 0.08);
    border-color: rgba(39, 174, 96, 0.2);
    color: #27ae60;
}

/* ===== Input Section ===== */
.input-section {
    display: flex;
    gap: 6px;
    padding: clamp(6px, 1.5vh, 12px) clamp(8px, 2.5vw, 16px);
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    align-items: center;
    transition: opacity 0.3s;
}

.input-section.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.cost-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-user-select: text;
    user-select: text;
}

.cost-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.cost-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

.cost-input:disabled {
    background: rgba(255, 255, 255, 0.02);
}

.cost-input::-webkit-outer-spin-button,
.cost-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cost-input[type=number] { -moz-appearance: textfield; }

.add-btn {
    padding: 8px 16px;
    border-radius: 10px;
    border: none;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.2s;
    white-space: nowrap;
}

.add-btn:active { transform: scale(0.95); }
.add-btn:disabled { opacity: 0.4; cursor: default; }

.p1-add {
    background: linear-gradient(135deg, var(--p1-color), #1a5276);
    box-shadow: 0 2px 10px rgba(52, 152, 219, 0.3);
}

.p2-add {
    background: linear-gradient(135deg, var(--p2-color), #922b21);
    box-shadow: 0 2px 10px rgba(231, 76, 60, 0.3);
}

/* ===== Center Divider ===== */
.center-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 4px 12px;
    background: var(--bg-dark);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 10;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    max-width: 60px;
}

.center-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.center-turn {
    font-size: clamp(0.75rem, 2.5vw, 0.9rem);
    font-weight: 800;
    color: var(--gold);
    letter-spacing: 0.05em;
    text-shadow: 0 0 8px var(--gold-glow);
}

.center-round {
    font-size: clamp(0.65rem, 2vw, 0.78rem);
    font-weight: 600;
    color: var(--text-muted);
}

.center-buttons {
    display: flex;
    gap: 5px;
    margin-top: 2px;
}

.center-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-size: clamp(0.6rem, 1.8vw, 0.72rem);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

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

.log-btn:hover {
    background: rgba(0, 191, 255, 0.12);
    border-color: var(--next-ball);
    color: var(--next-ball);
}

.restart-btn:hover {
    background: rgba(255, 215, 0, 0.12);
    border-color: var(--gold);
    color: var(--gold);
}

.reset-btn:hover {
    background: rgba(231, 76, 60, 0.15);
    border-color: var(--p2-color);
    color: var(--p2-glow);
}

/* ===== Round Overlay ===== */
.round-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: overlayFadeIn 0.3s ease-out;
}

.round-overlay.hidden { display: none; }

.round-overlay.fade-out {
    animation: overlayFadeOut 0.4s ease-out forwards;
}

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

@keyframes overlayFadeOut {
    to { opacity: 0; }
}

.round-overlay-content {
    text-align: center;
    animation: overlayContentIn 0.4s ease-out;
}

@keyframes overlayContentIn {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.overlay-label {
    font-size: 1rem;
    color: var(--text-muted);
    letter-spacing: 0.3em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.overlay-round {
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 30px var(--gold-glow);
    margin-bottom: 8px;
}

.overlay-cost {
    font-size: 1.2rem;
    color: var(--text);
    font-weight: 600;
    margin-bottom: 4px;
}

.overlay-cost span {
    color: var(--gold);
    font-size: 1.5rem;
    font-weight: 800;
}

.overlay-turn {
    font-size: 0.9rem;
    color: var(--next-ball);
    font-weight: 600;
}

/* ===== Log Panel ===== */
.log-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 400px;
    height: 100%;
    background: linear-gradient(180deg, #12121f 0%, var(--bg-dark) 100%);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 150;
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.3s ease-out;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
}

.log-panel.hidden { display: none; }

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.log-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.log-panel-header h2 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--gold);
}

.log-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.log-close:hover {
    background: rgba(231, 76, 60, 0.15);
    color: var(--p2-glow);
}

.log-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    -webkit-overflow-scrolling: touch;
}

.log-panel-body::-webkit-scrollbar { width: 4px; }
.log-panel-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.log-entry {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid transparent;
    font-size: 0.8rem;
    line-height: 1.4;
}

.log-entry.p1 { border-left-color: var(--p1-color); }
.log-entry.p2 { border-left-color: var(--p2-color); }
.log-entry.system {
    border-left-color: var(--gold);
    background: rgba(255, 215, 0, 0.04);
}

.log-entry-round {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 700;
    min-width: 28px;
    padding-top: 1px;
    flex-shrink: 0;
}

.log-entry-text { flex: 1; color: var(--text); }
.log-entry-text .player-tag { font-weight: 700; }
.log-entry-text .p1-tag { color: var(--p1-glow); }
.log-entry-text .p2-tag { color: var(--p2-glow); }

.log-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.85rem;
}

.log-panel-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.log-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.log-stats strong {
    color: var(--gold);
    font-weight: 700;
    margin-left: 4px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 24px;
    border-radius: 24px;
    background: rgba(0, 0, 0, 0.85);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    white-space: nowrap;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

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

/* ===== Desktop: side by side, both upright ===== */
@media (min-width: 768px) and (orientation: landscape) {
    #game-container {
        flex-direction: row;
    }

    /* Desktop: P2 NOT rotated */
    .player-2 {
        transform: none;
        border-bottom: none;
        border-right: 1px solid rgba(255, 255, 255, 0.08);
    }

    .player-1 {
        border-top: none;
        border-left: 1px solid rgba(255, 255, 255, 0.08);
    }

    .center-divider {
        flex-direction: column;
        padding: 12px 4px;
        border-top: none;
        border-bottom: none;
        border-left: 1px solid rgba(255, 255, 255, 0.05);
        border-right: 1px solid rgba(255, 255, 255, 0.05);
    }

    .divider-line {
        width: 1px;
        height: 60px;
        max-height: 60px;
        background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    }

    .center-info { flex-direction: column; }
    .center-buttons { flex-direction: column; }
}
