/* styles.css — BrutalBall */

/* ===================== 1. Variables & Reset ===================== */
:root {
    --bg-color: #2a2a2a;
    --container-bg: #333;
    --panel-bg: #444;
    --accent-color: #f90;
    --team1-color: #ff6666;
    --team2-color: #6666ff;
    --text-color: #fff;
    --border-radius: 8px;

    /* Card type colors */
    --card-movement: #4CAF50;
    --card-movement-dark: #2E7D32;
    --card-blocking: #F44336;
    --card-blocking-dark: #C62828;
    --card-ballHandling: #2196F3;
    --card-ballHandling-dark: #1565C0;
    --card-activation: #FF9800;
    --card-activation-dark: #E65100;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ===================== 2. Layout ===================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* ===================== 3. Canvas ===================== */
/* Game Wrapper: sized to canvas, everything anchors to it */
/* Default hidden until JS adds .visible class */
#game-wrapper {
    position: relative;
    display: none;
}

#game-wrapper.visible {
    display: inline-block;
}

canvas {
    display: block;
    background-color: #eee;
    border-radius: var(--border-radius);
}

/* ===================== 4. Floating Panels ===================== */
.floating-panel {
    position: absolute;
    z-index: 10;
    background-color: var(--panel-bg);
    border-radius: var(--border-radius);
    padding: 10px;
}

/* Top bar: above canvas */
#panel-top {
    bottom: 100%;
    left: 0;
    width: 100%;
    margin-bottom: 8px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    padding: 8px 12px;
}

/* Right panel: beside canvas */
#panel-right {
    left: 100%;
    top: 0;
    margin-left: 15px;
    width: 180px;
}

/* Status strip: below canvas */
#panel-status {
    top: 100%;
    left: 0;
    width: 100%;
    margin-top: 8px;
    text-align: center;
    font-size: 13px;
    opacity: 0.8;
    padding: 8px 12px;
}

#panel-status.error,
#panel-status.action,
#panel-status.ap,
#panel-status.card-selected,
#panel-status.card-mode { opacity: 1; }

#panel-status.error {
    background-color: rgba(230, 101, 101, 0.7);
}

#panel-status.action {
    background-color: rgba(101, 230, 101, 0.7);
}

#panel-status.ap {
    background-color: rgba(230, 230, 101, 0.7);
}

#panel-status.card-selected {
    background: linear-gradient(135deg, rgba(255, 255, 0, 0.7), rgba(255, 215, 0, 0.5));
    color: #000;
    font-weight: bold;
}

#panel-status.card-mode {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.7), rgba(75, 0, 130, 0.5));
}

/* ===================== 5. Game Overlay ===================== */
#game-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: none;
    border-radius: var(--border-radius);
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
}

#game-overlay.visible {
    display: flex;
}

/* ===================== 6. Game Toast ===================== */
#game-toast {
    position: absolute;
    top: 22%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    padding: 12px 24px;
    border-radius: 10px;
    text-align: center;
    z-index: 45;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    max-width: 80%;
    white-space: pre-wrap;
}
#game-toast.visible { opacity: 1; }

.overlay-title {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.overlay-subtitle {
    font-size: 18px;
    margin-bottom: 24px;
    opacity: 0.85;
}

.overlay-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
}

.overlay-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: filter 0.2s ease;
    font-family: inherit;
}

.overlay-btn:hover {
    filter: brightness(1.15);
}

.overlay-btn-primary {
    background-color: var(--accent-color);
    color: #000;
}

.overlay-btn-secondary {
    background-color: var(--panel-bg);
    color: var(--text-color);
}

/* ===================== 6. Shared Button Base ===================== */
.btn {
    border: none;
    border-radius: var(--border-radius);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn:hover {
    filter: brightness(1.15);
}

/* ===================== 7. Action Points ===================== */
.action-points {
    margin-bottom: 20px;
}

.ap-container {
    display: flex;
    justify-content: center;
    margin: 10px 0;
}

.ap-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 20px;
    margin: 0 5px;
    transition: filter 0.2s ease;
}

.ap-icon:hover {
    filter: brightness(1.1);
}

.ap-inactive {
    background-color: rgba(255,153,0,0.3);
}

/* ===================== 8. Bonus Cards ===================== */
.bonus-actions {
    margin-bottom: 20px;
}

.card-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
    padding: 8px;
    border-radius: var(--border-radius);
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2));
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.bonus-card {
    width: 80px;
    height: 120px;
    border-radius: var(--border-radius);
    padding: 5px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    border-left: 3px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.bonus-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    filter: brightness(1.1);
}

.bonus-card.selected {
    border: 2px solid #ffff00;
    box-shadow: 0 8px 20px rgba(255, 255, 0, 0.3);
    transform: translateY(-3px);
}

.bonus-card.selected::before {
    content: "\2713";
    position: absolute;
    top: -1px;
    right: -1px;
    background: linear-gradient(135deg, #ffff00, #ffd700);
    color: #000;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.card-movement {
    background: linear-gradient(135deg, var(--card-movement), var(--card-movement-dark));
}

.card-blocking {
    background: linear-gradient(135deg, var(--card-blocking), var(--card-blocking-dark));
}

.card-ballHandling {
    background: linear-gradient(135deg, var(--card-ballHandling), var(--card-ballHandling-dark));
}

.card-activation {
    background: linear-gradient(135deg, var(--card-activation), var(--card-activation-dark));
}

.card-name {
    font-weight: bold;
    font-size: 12px;
    text-align: center;
    margin-bottom: 5px;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.card-description {
    font-size: 10px;
    flex: 1;
    padding: 5px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.8));
    border-radius: 3px;
    color: #333;
    margin-top: 5px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Type indicator dots */
.bonus-card::after {
    content: "";
    position: absolute;
    bottom: 3px;
    left: 3px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.7);
}

.card-movement::after { background: var(--card-movement); }
.card-blocking::after { background: var(--card-blocking); }
.card-ballHandling::after { background: var(--card-ballHandling); }
.card-activation::after { background: var(--card-activation); }

/* Ensure proper click handling */
.bonus-card * { pointer-events: none; }
.bonus-card { pointer-events: all; }

/* Accessibility */
.bonus-card:focus {
    outline: 2px solid #ffff00;
    outline-offset: 1px;
}

/* ===================== 9. End Turn Button ===================== */
.end-turn-btn {
    background-color: var(--accent-color);
    padding: 12px;
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    margin-top: auto;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
    color: #000;
}

.end-turn-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* ===================== 10. Lobby Overlay ===================== */
#lobby-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.lobby-content {
    background-color: var(--container-bg);
    border-radius: var(--border-radius);
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lobby-title {
    color: var(--accent-color);
    font-size: 36px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 4px;
}

.lobby-subtitle {
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 20px;
    font-size: 14px;
}

.lobby-heading {
    color: var(--accent-color);
    font-size: 24px;
    margin-bottom: 16px;
}

.lobby-error-heading {
    color: var(--team1-color);
}

.lobby-text {
    color: var(--text-color);
    margin-bottom: 16px;
    font-size: 14px;
}

.lobby-text-dim {
    opacity: 0.5;
    font-size: 12px;
    margin-top: 16px;
}

.lobby-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Menu sections ────────────────────────────────────── */

/* Play group: Create / Join / Hotseat */
.menu-play-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

/* Team group: Cards & Deck + emoji picker */
.menu-team-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 14px 16px 16px;
    margin-bottom: 14px;
}

.menu-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.45;
    margin-bottom: -2px;
}

/* Cards & Deck button — blue-tinted to stand apart from orange/gray */
.lobby-btn-cards {
    padding: 14px 24px;
    border: 1px solid rgba(100, 150, 255, 0.2);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    font-family: inherit;
    background-color: #2c3e6b;
    color: var(--text-color);
    transition: filter 0.15s, transform 0.15s;
}
.lobby-btn-cards:hover {
    filter: brightness(1.25);
    transform: translateY(-1px);
}

/* Secondary link row: Instructions + Feedback */
.menu-links {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.lobby-btn-link {
    background: none;
    border: none;
    color: var(--text-color);
    opacity: 0.45;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--border-radius);
    transition: opacity 0.15s;
}

.lobby-btn-link:hover {
    opacity: 0.9;
}

.lobby-btn {
    padding: 14px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.lobby-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.lobby-btn-primary {
    background-color: var(--accent-color);
    color: #000;
}

.lobby-btn-secondary {
    background-color: var(--panel-bg);
    color: var(--text-color);
}

.lobby-btn-small {
    padding: 8px 16px;
    font-size: 13px;
    background-color: var(--panel-bg);
    color: var(--text-color);
    margin-bottom: 8px;
}

.lobby-code {
    font-size: 48px;
    font-weight: bold;
    letter-spacing: 12px;
    color: var(--accent-color);
    background-color: var(--panel-bg);
    border-radius: var(--border-radius);
    padding: 16px 24px;
    margin: 16px 0;
    font-family: monospace;
    user-select: all;
}

.lobby-input {
    width: 200px;
    padding: 14px;
    font-size: 32px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 8px;
    background-color: var(--panel-bg);
    border: 2px solid var(--accent-color);
    border-radius: var(--border-radius);
    color: var(--text-color);
    font-family: monospace;
    outline: none;
    margin-bottom: 16px;
}

.lobby-input:focus {
    border-color: #fff;
    box-shadow: 0 0 8px rgba(255, 153, 0, 0.4);
}

.lobby-inline-error {
    color: var(--team1-color);
    font-size: 12px;
    margin-bottom: 8px;
}

/* Instructions screen */
.lobby-content-instructions {
    text-align: left;
    max-height: 80vh;
    overflow-y: auto;
}

.instructions-heading {
    font-size: 16px;
    font-weight: bold;
    color: var(--accent-color);
    margin: 20px 0 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.instructions-list {
    margin: 0 0 8px 0;
    padding-left: 20px;
    line-height: 1.7;
}

.instructions-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 14px;
}

.instructions-table td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.instructions-table td:last-child {
    text-align: right;
    white-space: nowrap;
    color: var(--accent-color);
    font-weight: bold;
}

.emoji-picker { margin-top: 20px; text-align: center; }
.menu-team-section .emoji-picker { margin-top: 0; }
.emoji-picker-label { font-size: 14px; opacity: 0.7; margin-bottom: 8px; }
.emoji-picker-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.emoji-option {
    font-size: 28px;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius);
    border: 2px solid transparent;
    transition: border-color 0.15s;
    line-height: 1;
}
.emoji-option:hover { border-color: rgba(255,255,255,0.3); }
.emoji-option.selected { border-color: var(--accent-color); }

/* Formation picker */
.formation-options {
    display: flex;
    flex-direction: row;
    gap: 16px;
    justify-content: center;
    margin: 16px 0;
}
.formation-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.formation-option:hover { border-color: rgba(255,255,255,0.4); background: rgba(255,255,255,0.05); }
.formation-option.selected { border-color: var(--accent-color); background: rgba(255,255,255,0.1); }
.formation-mini-grid {
    position: relative;
    width: 56px;
    height: 104px;
    background: rgba(255,255,255,0.04);
    border-radius: 4px;
    flex-shrink: 0;
}
.formation-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-color);
    transform: translate(-50%, -50%);
}
.formation-label {
    font-size: 12px;
    opacity: 0.8;
    text-align: center;
}

.lobby-dice {
    font-size: 64px;
    margin-bottom: 16px;
    animation: dice-bounce 0.6s ease-out;
}

@keyframes dice-bounce {
    0% { transform: scale(0.3) rotate(-180deg); opacity: 0; }
    60% { transform: scale(1.2) rotate(10deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); }
}

.lobby-team-label {
    font-size: 16px;
    font-weight: bold;
    margin-top: 8px;
    opacity: 0.8;
}

/* ===================== 11. Loading Screen ===================== */
#loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
}

.loading-title {
    font-size: 48px;
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 24px;
    letter-spacing: 4px;
    text-align: center;
}

.loading-title-portrait { display: none; }

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== 12. Portrait Layout ===================== */

/* Desktop: hide portrait-only elements */
#portrait-hud { display: none; }
#panel-bottom { display: none; }

@media (max-width: 520px) {
    body { padding: 0; }

    /* Override .visible display value so canvas centers properly */
    #game-wrapper.visible {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    canvas { border-radius: 0; }

    .loading-title-desktop { display: none; }
    .loading-title-portrait { display: block; line-height: 1.3; }

    #panel-top { display: none; }
    #panel-right { display: none !important; }

    /* Portrait HUD above canvas */
    #portrait-hud {
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        padding: 6px 12px;
        box-sizing: border-box;
    }

    .portrait-ap .ap-icon { width: 28px; height: 28px; font-size: 14px; margin: 0 2px; }
    .portrait-end-turn { padding: 8px 16px; font-size: 13px; }

    /* Status below canvas */
    #panel-status {
        position: relative;
        top: auto;
        left: auto;
        width: 100%;
        margin-top: 2px;
        font-size: 11px;
        border-radius: 0;
    }

    #game-toast { font-size: 15px; padding: 10px 18px; }

    /* Card strip below status */
    #panel-bottom {
        display: flex;
        width: 100%;
        height: 90px;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 4px 8px;
        background-color: var(--panel-bg);
    }

    #panel-bottom .bonus-card { width: 110px; height: 75px; padding: 4px; }
    #panel-bottom .card-name { font-size: 10px; margin-bottom: 2px; }
    #panel-bottom .card-description { font-size: 8px; padding: 3px; }

    /* Lobby: top-align card so it's not floating mid-screen */
    #lobby-overlay {
        align-items: flex-start;
        padding-top: 40px;
    }

    /* Lobby content: reduce padding to fit portrait */
    .lobby-content {
        padding: 28px 20px;
    }

    /* Join form: stack input and button vertically */
    .lobby-input {
        display: block;
        width: 100%;
        font-size: 24px;
        letter-spacing: 4px;
        margin-bottom: 8px;
    }

    /* Lobby code: smaller for portrait */
    .lobby-code {
        font-size: 36px;
        letter-spacing: 6px;
        padding: 12px;
    }
}

/* ===================== 13. Deck Builder ===================== */

/* Wider, flex-column layout that lets the card pool scroll */
.lobby-content-deck-builder {
    padding: 24px 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 640px;
    max-height: 88vh;
    overflow: hidden;
    text-align: left;
}

/* Budget / card-count progress rows */
.deck-budget-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--border-radius);
    padding: 8px 12px;
}

.deck-budget-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.deck-budget-label {
    width: 36px;
    text-align: right;
    opacity: 0.7;
    flex-shrink: 0;
}

.deck-budget-track {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.12);
    border-radius: 3px;
    overflow: hidden;
}

.deck-budget-fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: 3px;
    transition: width 0.15s ease;
}

.deck-budget-fill-over { background: var(--team1-color); }

.deck-budget-num {
    width: 44px;
    text-align: right;
    font-weight: bold;
    font-size: 12px;
    flex-shrink: 0;
}

.deck-budget-over { color: var(--team1-color); }

/* Scrollable 5-column card grid */
.deck-card-pool {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    flex: 1;
    min-height: 0;    /* needed for flex overflow to work */
    overflow-y: auto;
    padding: 2px;    /* room for selection border */
}

/* Override fixed card dimensions; let grid size them.
   isolation: isolate creates a self-contained stacking context per card —
   z-indices of children (tier strip, content, overlay) are scoped to that
   card only and cannot bleed into sibling cards. */
/* Flex column layout. % padding on card-name (always relative to width,
   never aspect-ratio-derived height) centres the title in the tier block
   without needing a definite container height. */
.deck-card-pool .bonus-card {
    width: auto;
    height: auto;
    aspect-ratio: 2 / 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    border-left: none;
    isolation: isolate;
}

/* All content sits above the tier gradient (z-index 1).
   Absolute-positioned children (cost badge, count badge, overlay) manage
   their own position but share the same z-index level. */
.deck-card-pool .card-name,
.deck-card-pool .card-description {
    position: relative;
    z-index: 2;
}

/* Type-indicator dot: explicit z-index so every element inside the card
   has a declared stack level (no implicit auto ordering). */
.deck-card-pool .bonus-card::after {
    z-index: 2;
}

/* Title centred in the tier block zone.
   padding-top/bottom use % of card WIDTH (guaranteed definite from grid column).
   For aspect-ratio 2/3: tier height = 38% * 1.5W = 57% of W.
   To centre a ~16px text line in that zone:
     pad = (57%W - 16px) / 2  →  calc(28.5% - 8px) */
.deck-card-pool .card-name {
    font-size: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 0;
    /* Calibrated for aspect-ratio: 2/3 + tier 28%:
       tier_height = 28% × 1.5W = 42% of card width
       pad = (42%W − 16px) / 2  →  calc(21% − 8px) */
    padding-top: calc(21% - 8px);
    padding-bottom: calc(21% - 8px);
}

/* Description box: solid white, fills remaining space via flex. */
.deck-card-pool .card-description {
    font-size: 10px;
    padding: 4px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #fff;
}

/* Selectable state */
.deck-card-selectable { cursor: pointer; }

.deck-card-selectable.deck-card-selected {
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 0 10px rgba(255,255,255,0.5);
}

/* Disabled: unselected card that can't be added right now */
.deck-card-selectable.deck-card-disabled {
    cursor: not-allowed;
    pointer-events: none;
}

/* Dark overlay for disabled cards — no transparency on the card itself */
.deck-card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    border-radius: inherit;
    z-index: 4;
    pointer-events: none;
}

/* Tier header block — inset to match the description box width and top margin.
   28% keeps the header compact at all column widths (38% was too large on desktop). */
.deck-card-pool .card-tier-strong::before,
.deck-card-pool .card-tier-epic::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    height: 28%;
    border-radius: 3px;
    z-index: 1;
    pointer-events: none;
}

/* Silver sheen: dark → mid → bright highlight → mid → dark */
.deck-card-pool .card-tier-strong::before {
    background: linear-gradient(
        135deg,
        #4a5a66 0%,
        #8aa0b0 25%,
        #ddeeff 48%,
        #8aa0b0 55%,
        #4a5a66 100%
    );
}

/* Gold sheen: dark → mid → bright highlight → mid → dark */
.deck-card-pool .card-tier-epic::before {
    background: linear-gradient(
        135deg,
        #6b4a00 0%,
        #c89820 28%,
        #fff0a0 48%,
        #c89820 55%,
        #6b4a00 100%
    );
}

/* Deck-cost badge — top-left corner of each pool card */
.deck-cost-badge {
    position: absolute;
    top: 3px;
    left: 3px;
    z-index: 2;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* Copy-count badge — top-right corner when copies > 0 (mirrors cost at top-left) */
.deck-card-count {
    position: absolute;
    top: 3px;
    right: 3px;
    z-index: 2;
    background: var(--accent-color);
    color: #000;
    font-size: 10px;
    font-weight: bold;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Footer: two rows — action buttons + back */
.deck-builder-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.deck-builder-actions {
    display: flex;
    gap: 8px;
}

.deck-builder-actions .lobby-btn,
.deck-builder-footer > .lobby-btn {
    flex: 1;
    padding: 10px 8px;
    font-size: 13px;
}

/* Centred heading in deck builder */
.lobby-content-deck-builder .lobby-heading {
    text-align: center;
}

/* Disabled button */
.lobby-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Narrow desktop / large portrait: 3 columns, capped card height.
   aspect-ratio: 2/3 on ~180px-wide columns produces ~270px-tall cards;
   explicit height keeps proportions similar to the mobile layout. */
@media (max-width: 620px) {
    .lobby-content-deck-builder .deck-card-pool {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Cap height; remove aspect-ratio so it doesn't fight the fixed value */
    .lobby-content-deck-builder .deck-card-pool .bonus-card {
        height: 150px;
        aspect-ratio: auto;
    }

    /* Fixed-pixel padding centres the title in the tier block (28% × 150px = 42px) */
    .lobby-content-deck-builder .deck-card-pool .card-name {
        padding-top: 13px;
        padding-bottom: 13px;
    }

    .deck-card-pool .card-description { font-size: 9px; }
}

/* Portrait phone: 3 columns, explicit card height */
@media (max-width: 520px) {
    .lobby-content-deck-builder {
        max-width: 100%;
        max-height: 90vh;
        padding: 16px 12px 14px;
        gap: 10px;
    }

    .lobby-content-deck-builder .deck-card-pool {
        grid-template-columns: repeat(3, 1fr);
        row-gap: 14px;
    }

    /* Explicit height in vw so the flex container has a known size —
       aspect-ratio alone doesn't reliably give flex children a height in
       Chrome mobile, causing flex:1 on the description to collapse to zero. */
    .lobby-content-deck-builder .deck-card-pool .bonus-card {
        height: 34vw;
        padding: 4px;
        gap: 2px;
    }

    /* Shorter tier block on smaller cards; inset matches 4px mobile padding */
    .lobby-content-deck-builder .deck-card-pool .card-tier-strong::before,
    .lobby-content-deck-builder .deck-card-pool .card-tier-epic::before {
        top: 4px;
        left: 4px;
        right: 4px;
        height: 30%;
    }

    /* Mobile tier = 30% of 34vw ≈ 10.2vw; card width ≈ 33vw.
       Centre padding: (10.2/33)/2 ≈ 15% of card width, minus half text height. */
    .lobby-content-deck-builder .deck-card-pool .card-name        { font-size: 9px; padding-top: calc(15% - 8px); padding-bottom: calc(15% - 8px); }
    .lobby-content-deck-builder .deck-card-pool .card-description { font-size: 8px; padding: 3px; }
}

/* ===================== 15. Accessibility & Reduced Motion ===================== */
@media (prefers-reduced-motion: reduce) {
    .bonus-card,
    .bonus-card:hover,
    .bonus-card.selected,
    .ap-icon,
    .end-turn-btn,
    .overlay-btn,
    .lobby-btn,
    .lobby-btn:hover {
        transition: none;
        animation: none;
        transform: none;
    }

    .loading-spinner {
        animation: none;
    }
}

/* ===================== Tutorial ===================== */

/* Full-screen fade overlay for scene transitions */
#tutorial-transition {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}
#tutorial-transition.active {
    opacity: 1;
    pointer-events: all;
}

/* Persistent Skip / Main Menu buttons */
#tutorial-controls {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 150;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Hide end-turn buttons during tutorial; push controls below portrait HUD on mobile */
body.tutorial-active .end-turn-btn { display: none !important; }


.tutorial-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: var(--accent-color);
    color: #000;
    opacity: 0.9;
    transition: opacity 0.15s;
}
.tutorial-btn:hover { opacity: 1; }

.tutorial-btn-secondary {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.tutorial-btn-secondary:hover { background: rgba(255,255,255,0.25); }
