:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a2332;
    --bg-zone: #232d3f;
    --bg-zone-opponent: #2a2035;
    --accent-pink: #ff6b9d;
    --accent-blue: #4a9eff;
    --accent-cyan: #00bcd4;
    --accent-gold: #f5c542;
    --accent-green: #4ade80;
    --accent-purple: #a855f7;
    --text: #f0f0f0;
    --text-dim: #6b7a8f;
    --border: #3d4a5c;
    --card-width: 65px;
    --card-height: 91px;
    --card-width-mini: 60px;
    --card-height-mini: 84px;
    --card-width-landscape: 112px;
    --card-height-landscape: 80px;
    --transition-speed: 0.3s;
}

/* Action Pending / Loading State */
body.action-pending {
    cursor: wait;
}

body.action-pending .game-board,
body.action-pending .sidebar-right,
body.action-pending .hand-group {
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.2s;
}

body.action-pending::after {
    content: "Processing...";
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--accent-pink);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    animation: pulse 1.5s infinite;
}

.cost {
    position: absolute;
    top: 2px;
    left: 2px;
    /* MOVED TO LEFT for visibility in overlapped hand */
    background: var(--accent-pink);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 5;
    text-shadow: 1px 1px 0 #000;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

button {
    border: none;
    background: none;
    color: inherit;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

body {
    font-family: 'Noto Sans JP', 'Segoe UI', 'Hiragino Kaku Gothic ProN', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a1a2e 100%);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header */
.header {
    display: flex;
    flex-direction: column;
    /* Stack rows vertically */
    padding: 4px 12px;
    /* Reduced from 6px */
    background: linear-gradient(90deg, var(--bg-secondary), #1e2a3d);
    border-bottom: 2px solid var(--accent-pink);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* New: Main Row for Title, Info, Controls */
.header-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-pink);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin: 0;
    display: flex;
    align-items: center;
}

/* Stats */
.info-bar {
    display: flex;
    gap: 15px;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat {
    font-size: 0.9rem;
    color: #ccc;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-icon {
    font-size: 1.1rem;
    /* Reduced from 1.2rem */
}

.stat-label {
    opacity: 0.8;
}

.info-bar .stat strong {
    color: var(--accent-blue);
    font-weight: 700;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn {
    padding: 3px 10px;
    /* Compressed padding */
    border: none;
    border-radius: 12px;
    /* Slightly squarer */
    background: linear-gradient(135deg, var(--bg-zone), #2a3a4d);
    color: var(--text);
    font-size: 0.75rem;
    /* Smaller font */
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn:hover {
    background: linear-gradient(135deg, var(--accent-blue), #3a7bd5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-pink), #e05080);
    font-weight: bold;
}

.btn-settings {
    border: 1px solid var(--accent-purple);
    color: white;
}

/* Total Hearts Display */
.total-hearts-display {
    display: flex;
    gap: 4px;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-right: 15px;
}

.total-hearts-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-right: 4px;
}

.hearts-stat {
    gap: 0 !important;
    padding: 2px 4px !important;
    margin-right: 0 !important;
    display: flex;
    align-items: center;
}

.header-heart-icon {
    width: clamp(14px, 2vw, 20px);
    height: clamp(14px, 2vw, 20px);
    object-fit: contain;
}

.th-pip {
    font-size: 0.75rem;
    /* Emoji or text size */
    margin: 0 1px;
}

.btn-danger {
    background: linear-gradient(135deg, #ff4444, #cc0000);
    border-color: #ff8888;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-pink);
    border-radius: 12px;
    padding: 20px;
    width: 500px;
    max-width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.modal-title {
    font-size: 1.2rem;
    color: var(--accent-pink);
    font-weight: bold;
}

.modal-body {
    margin-bottom: 20px;
    overflow-y: auto;
    flex: 1;
    padding-right: 5px;
    /* Prevent scrollbar overlap */
}

/* Settings Modal Grid */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-pink);
    font-weight: bold;
    margin-bottom: 5px;
}

.settings-group .btn {
    width: 100%;
    justify-content: center;
    padding: 10px;
}

.close-btn {
    font-size: 1.5rem;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.close-btn:hover {
    opacity: 1;
}

.report-textarea {
    width: 100%;
    height: 150px;
    background: var(--bg-zone);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 10px;
    font-family: inherit;
    resize: vertical;
    margin-top: 10px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Game Board Container */
.game-container {
    display: flex;
    flex-direction: row;
    width: 100vw;
    height: calc(100vh - 52px);
    overflow: hidden;
}

/* Three Pane Layout */
.sidebar-left {
    width: 250px;
    /* Default width */
    min-width: 150px;
    max-width: 50%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 10px;
    overflow: hidden;
    /* Lock entire pane scroll */
}

.game-board {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding: 10px;
    min-width: 300px;
}

.sidebar-right {
    width: 280px;
    /* Default width */
    min-width: 200px;
    max-width: 50%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    overflow-y: auto;
}

/* 2-Column +/* 3-Column -> 2-Column + Bottom Row Layout */
.board-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    /* Allow cards to pop up out of the board-inner boundary if needed */
    overflow: visible;
}

/* Ensure sections don't clip */
.player-section,
.opponent-section {
    overflow: visible !important;
    position: relative;
    z-index: 1;
}

/* Field Row: 3 Columns [Success/Energy | Stage/Live | Decks] */
.field-row {
    display: grid;
    grid-template-columns: minmax(80px, auto) 1fr minmax(120px, auto);
    gap: 10px;
    align-items: center;
    width: 100%;
}

.center-field {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.energy-row {
    height: 48px;
    width: 100%;
    margin-bottom: 2px;
}

.energy-area-container.horizontal {
    height: 100%;
    padding: 2px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.side-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
}

.hand-row {
    width: 100%;
}

.deck-discard-group {
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping if needed */
    justify-content: center;
    gap: 4px;
    width: 100%;
}

/* Groupings */
.live-group,
.stage-group,
.hand-group,
.energy-area-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 2px;
    /* Reduced from 6px */
    border: 1px solid var(--border);
}

.live-group,
.stage-group,
.hand-group,
.energy-area-container {
    padding: 2px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.1);
}

/* Hide Headings to save space */
.live-group h2,
.stage-group h2,
.successful-live-area-container h2,
.deck-area h2,
.waiting-room-area h2,
.area-header h2 {
    display: none;
}

.area-count {
    font-size: 0.65rem;
    color: var(--accent-pink);
    opacity: 0.8;
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 4px;
    border-radius: 3px;
    position: absolute;
    top: 2px;
    right: 2px;
    pointer-events: none;
    z-index: 10;
}

.live-group,
.stage-group,
.hand-group,
.energy-area-container,
.waiting-room-area {
    position: relative;
    /* for absolute area-count */
}

.card-area {
    min-height: 40px;
    border: 1px dashed var(--border);
    border-radius: 4px;
    padding: 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    overflow: hidden;
    position: relative;
    background: rgba(0, 0, 0, 0.1);
}

.card-area.compact {
    min-height: 30px;
    padding: 1px;
}

.card-area.energy {
    /* Horizontal strip style */
    display: flex;
    flex-direction: row;
    /* Horizontal */
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    height: 100%;
    gap: 2px;
    min-height: 0;
    /* Override default */
    padding: 2px;
    border: none;
    background: transparent;
}

.card-area.energy .card {
    width: 30px;
    /* Small overlapping cards */
    height: 42px;
    flex-shrink: 0;
}

.card-area.discard {
    height: 80px;
    /* Fixed height */
    min-height: 80px;
    overflow-y: auto;
    /* Scrollable */
    align-content: flex-start;
    /* Pack to top */
}

.card-area.exclude {
    min-height: 40px;
    background: rgba(50, 0, 0, 0.2);
    /* Red tint for banish */
    border-color: rgba(255, 0, 0, 0.3);
}

.card-area.hand {
    height: 240px;
    min-height: 240px;
    max-height: 240px;
    overflow-x: auto;
    overflow-y: hidden;
    /* Prevent vertical scrollbar */
    flex-wrap: nowrap;
    justify-content: flex-start;
    /* Fix scroll clipping on left */
    padding: 20px 40px;
    /* More horizontal padding to prevent edge clipping */
    background: rgba(255, 255, 255, 0.05);
    align-items: center;
    gap: -40px;
    /* Slightly less aggressive compression */
}

/* New Card Indicator */
.card.new-card {
    /* Ensure the card itself has layering to support the badge */
    position: relative;
}

.card.new-card::after {
    content: "NEW!";
    position: absolute;
    top: -15px;
    /* Lift higher */
    left: 50%;
    transform: translateX(-50%);
    background: #ffeb3b;
    color: #d32f2f;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 2000;
    /* Ensure above everything */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    pointer-events: none;
    border: 1px solid #d32f2f;
}

/* Fix ancestors to prevent clipping of scaled cards */
.hand-row,
.hand-group,
.player-section,
.board-container {
    overflow: visible !important;
}

/* Ensure overlap works with flex gap support or fallback */
/* Ensure Right side is on top */
.card-area.hand .card {
    margin-right: -50px;
    position: relative;
}

/* Explicit positive z-index based on index could be done in JS,
   but for now we rely on DOM order for Right-over-Left.
   If it's reversed, we'd need flex-direction: row-reverse.
*/

.card-area.hand .card:last-child {
    margin-right: 0;
}

.card-area.hand .card,
.card-area.hand .card img {
    height: 100%;
    width: auto;
    max-height: 100%;
    transition: transform 0.2s ease, z-index 0s, box-shadow 0.2s;
}

.card-area.hand .card:hover,
.card-area.hand .card.highlight-source,
.card-area.hand .card.highlight-target {
    transform: scale(1.2);
    /* REMOVED translateY to stay in place vertically */
    z-index: 1000 !important;
    /* Bring to very front */
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    position: relative;
    transition: none !important;
    /* SNAP for instant feedback & correct tooltip pos */
}

/* General pop-up for all other cards/slots */
.card:hover,
.member-slot:hover,
.card.highlight-source,
.card.highlight-target,
.member-slot.highlight-source,
.member-slot.highlight-target {
    transform: scale(1.1);
    z-index: 90;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s;
}

.card-area.stage {
    min-height: 110px;
    display: grid;
    grid-template-columns: var(--card-width) var(--card-width) var(--card-width);
    justify-content: center;
    gap: 15px;
    /* Match live-zone-cards gap */
    overflow: visible;
}

.live-zone-cards {
    min-height: 140px;
    display: grid;
    grid-template-columns: var(--card-width) var(--card-width) var(--card-width);
    justify-content: center;
    align-items: center;
    gap: 15px;
    overflow: visible;
}

/* Unified container for slots to allow on-card buttons */
.board-slot-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: var(--card-width);
}

.slot-action-btn {
    width: 100%;
    padding: 2px 4px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--accent-gold), #d97706);
    color: #111;
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 10;
}

.slot-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    filter: brightness(1.1);
}

.slot-action-btn.btn-perform {
    background: linear-gradient(135deg, #a855f7, #6b21a8);
    color: white;
}

/* REVERTED TO PORTRAIT */
.card.type-live {
    /* Standard portrait sizing */
    width: var(--card-width);
    height: var(--card-height);
    transform: none;
    border: 2px solid var(--accent-pink);
}

.card.type-live img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Cover for portrait */
    border-radius: 6px;
}

/* If the cards are portrait in data, we rotate them */
/* The previous code might have used fixed portrait ratios, let's force landscape feel */


/* Specific hand styling to prevent overlap */
.hand-cards,
.hand {
    max-height: 150px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.1);
}

.card-slots {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.live-slot,
.stage-slot {
    width: var(--card-width);
    height: var(--card-height);
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed var(--border);
    border-radius: 3px;
}

/* Horizontal card support for live zones */
.card.type-live {
    width: var(--card-width-landscape);
    height: var(--card-height-landscape);
}

.card.type-live img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Resizer Handle */
.resizer {
    width: 5px;
    background: var(--bg-primary);
    cursor: col-resize;
    z-index: 10;
    transition: background 0.2s;
    flex-shrink: 0;
}

.resizer:hover,
.resizer.resizing {
    background: var(--accent-blue);
}

/* Player Sections */
.player-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 6px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    margin-bottom: 8px;
}

.player-section.opponent {
    background: linear-gradient(180deg, var(--bg-zone-opponent), var(--bg-secondary));
    border-color: #4a3050;
    padding: 6px;
}

/* Compact cards for opponent section */
.player-section.opponent .card {
    width: 60px;
    height: 84px;
    font-size: 0.5rem;
}

.player-section.opponent .card .name {
    font-size: 0.45rem;
}

.player-section.opponent .member-slot {
    width: 70px;
    height: 95px;
}

.player-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-label .score-badge {
    background: var(--accent-gold);
    color: #000;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: bold;
}

/* Zones Grid */
.zones-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
}

.zone {
    background: var(--bg-zone);
    border-radius: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    min-width: 80px;
}

.zone-title {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

/* Stage - 3 Member Areas */
.stage-zone {
    flex: 1;
    max-width: 400px;
}

.stage-slots {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.member-slot {
    width: var(--card-width);
    height: var(--card-height);
    background: rgba(0, 0, 0, 0.4);
    border: 2px dashed var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s;
}

.member-slot.drag-over {
    background: rgba(74, 158, 255, 0.2);
    border-color: var(--accent-blue);
    border-style: solid;
    transform: scale(1.05);
}



.member-slot.filled {
    border-style: solid;
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(74, 158, 255, 0.3);
}

.member-slot.tapped {
    transform: rotate(90deg);
    opacity: 0.6;
}

.area-label {
    font-size: 0.6rem;
    color: var(--text-dim);
}

.attached-energy {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 80px;
}


/* Hand Zone Styling - Overflow Handling */
.hand-zone {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    /* Try to allow pop-ups */
    white-space: nowrap;
    /* Custom Scrollbar for Hand */
    scrollbar-width: thin;
    scrollbar-color: var(--accent-blue) var(--bg-zone);
    padding-top: 15px;
    /* Space for pop-up */
    min-height: 120px;
    /* Ensure space */
}

.hand-cards {
    display: flex;
    gap: 0;
    /* Remove gap, we use margins */
    padding: 5px 20px;
    /* Side padding for first/last card */
    min-width: 100%;
    width: max-content;
    align-items: center;
}

/* Overlapping Cards Style */
.hand-cards .card {
    /* margin-right is dynamically managed by JS adjustHandLayout() */
    margin-right: -5px;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.3);
    /* Shadow on left side */
    position: relative;
    /* z-index set dynamically via nth-child if needed, but flex order usually handles paint order */
}

.hand-cards .card:last-child {
    margin-right: 0 !important;
}

/* Hover/Focus Effect (Pop Up) */
.hand-cards .card:hover,
.hand-cards .card:focus-within {
    transform: translateY(-15px) scale(1.1);
    z-index: 100;
    margin-right: 15px;
    /* Push neighbor slightly to reveal more */
    margin-left: 10px;
    /* Push self away from left neighbor */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.6);
}

/* Mobile Tweak: More aggressive overlap handled by JS now */
@media (max-width: 768px) {
    /* .hand-cards .card { margin-right: ... } handled by JS */
}

/* Live Zone Styling - Aligned with Stage */
/* .live-zone-cards already defined above with grid and 15px gap */

.energy-mini {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-gold), #d4a800);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 5px var(--accent-gold);
}

/* Card Styling */
.card {
    width: var(--card-width);
    height: var(--card-height);
    background-clip: padding-box;
    background: linear-gradient(135deg, var(--bg-card), var(--bg-dark));
    border: 1px solid var(--border);
    padding: 4px;
    color: var(--text);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.card.landscape {
    width: var(--card-height);
    height: var(--card-width);
}

.card.type-live {
    width: var(--card-height);
    height: var(--card-width);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card .name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    padding: 3px;
    font-size: 0.5rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card .cost {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--accent-pink);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: bold;
}

.card.type-live .cost {
    background: var(--accent-purple);
}

.card.hidden {
    background: linear-gradient(145deg, #404050, #2a2a35);
}

.card.hidden::after {
    content: '🂠';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
}

.card.selected {
    border: 2px solid var(--accent-gold);
    transform: translateY(-8px);
    box-shadow: 0 0 15px var(--accent-gold);
}

.card.card-playable {
    border: 2px solid var(--accent-green);
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.4);
}

.card.card-baton-playable {
    border: 2px solid var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 188, 212, 0.4);
}

.card.card-locked {
    filter: grayscale(0.8);
    opacity: 0.7;
    cursor: not-allowed;
}


.card.selected::before {
    content: 'Selected';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    background: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 2px 10px;
    font-size: 0.7rem;
    font-weight: bold;
    border-radius: 4px;
    z-index: 10;
}

/* Stats Overlay */
.card .stats {
    position: absolute;
    bottom: 18px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 4px;
    pointer-events: none;
}



.card.mulligan-selected {
    filter: grayscale(0.8);
    opacity: 0.7;
    /* cursor: not-allowed; We want it clickable to toggle back */
}

.card.new-card::after {
    content: 'NEW';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-blue);
    color: #fff;
    padding: 1px 4px;
    font-size: 0.5rem;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 20;
    pointer-events: none;
}

.card.new-card {
    border-color: var(--accent-blue);
    box-shadow: 0 0 8px rgba(74, 158, 255, 0.4);
}



/* Colored Heart Pips */
.heart-pips {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 95%;
    margin: 0 auto 2px;
}

.heart-pip {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.5);
    font-size: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.heart-pip.color-0 {
    background: #ff88cc;
}

/* PINK */
.heart-pip.color-1 {
    background: #ff4444;
}

/* RED */
.heart-pip.color-2 {
    background: #ffcc00;
}

/* YELLOW */
.heart-pip.color-3 {
    background: #44cc44;
}

/* GREEN */
.heart-pip.color-4 {
    background: #4488ff;
}

/* BLUE */
.heart-pip.color-5 {
    background: #aa44ff;
}

/* ANY */
.heart-pip.color-any {
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid #fff;
    box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.4);
}

.heart-pip.color-any::after {
    content: '★';
    font-size: 8px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1;
}

/* Blade Hearts (Yell) */
.blade-hearts {
    position: absolute;
    top: 20px;
    left: 2px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* Heart Pip Styles - Filled/Empty */
.heart-pip.empty {
    background: transparent !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.heart-pip.filled.color-0 {
    background: #ff88cc !important;
    border-color: #ff88cc;
    box-shadow: 0 0 3px #ff88cc;
}

.heart-pip.filled.color-1 {
    background: #ff4444 !important;
    border-color: #ff4444;
    box-shadow: 0 0 3px #ff4444;
}

.heart-pip.filled.color-2 {
    background: #ffcc00 !important;
    border-color: #ffcc00;
    box-shadow: 0 0 3px #ffcc00;
}

.heart-pip.filled.color-3 {
    background: #44cc44 !important;
    border-color: #44cc44;
    box-shadow: 0 0 3px #44cc44;
}

.heart-pip.filled.color-4 {
    background: #4488ff !important;
    border-color: #4488ff;
    box-shadow: 0 0 3px #4488ff;
}

.heart-pip.filled.color-5 {
    background: #aa44ff !important;
    border-color: #aa44ff;
    box-shadow: 0 0 3px #aa44ff;
}

.heart-pip.filled.color-any {
    background: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3) !important;
    border-color: #fff;
    box-shadow: 0 0 8px #fff, 0 0 15px rgba(255, 255, 255, 0.8), inset 0 0 5px rgba(255, 255, 255, 0.5);
    animation: rainbow-glow 3s linear infinite;
}

@keyframes rainbow-glow {
    0% {
        filter: hue-rotate(0deg);
    }

    100% {
        filter: hue-rotate(360deg);
    }
}

.blade-pip {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    border: 1px solid #fff;
    opacity: 0.9;
}

.blade-pip.color-0 {
    background: #ff88cc;
}

.blade-pip.color-1 {
    background: #ff4444;
}

.blade-pip.color-2 {
    background: #ffcc00;
}

.blade-pip.color-3 {
    background: #44cc44;
}

.blade-pip.color-4 {
    background: #4488ff;
}

.blade-pip.color-5 {
    background: #aa44ff;
}

/* Card ID Styling - Hidden by default, shown on hover */
.card-id {
    position: absolute;
    top: 2px;
    left: 2px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--accent-gold);
    font-size: 0.6rem;
    font-weight: bold;
    padding: 1px 3px;
    border-radius: 2px;
    z-index: 30;
    cursor: copy;
    pointer-events: auto;
    border: 1px solid var(--accent-gold);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.game-card:hover .card-id,
.member-slot:hover .card-id {
    opacity: 1;
}

.card-id:hover {
    background: var(--accent-gold);
    color: #000;
}

/* Stats Overlay */



/* Position heart-pips on member slots */
.member-slot .heart-pips {
    position: absolute;
    bottom: 32px;
    left: 0;
    width: 100%;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
    margin: 0;
}

/* Tooltip for Ability */
/* Tooltip for Ability (Disabled CSS tooltip to use JS) */
/* .card:hover::after { content: attr(data-text); ... } */



.card-desc-panel {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    border-left: 4px solid var(--accent-pink);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    max-height: 60%;
    /* Increased from 40% to allow more text */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent bleed out */
}

.card-desc-panel h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.card-desc-content {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-pink) transparent;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #eee;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    /* Preserve newlines from translator */
}

.card-desc-content img {
    height: 1.1em;
    width: auto;
    max-width: 100%;
    min-width: 1.1em;
    vertical-align: middle;
    margin: 0 2px;
    display: inline-block;
}

.card-desc-content br {
    display: block;
    content: "";
    margin-top: 4px;
}



.card-desc-content .icon-wrapper {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin: 0 2px;
}

/* Live Cards (Landscape) */
.card.type-live {
    width: var(--card-height);
    height: var(--card-width);
    background: linear-gradient(135deg, #2a203d, #1a1525);
}

.card.type-live .name {
    font-size: 0.6rem;
}

.member-slot.locked {
    cursor: not-allowed;
    /* No grayscale, just disabled cursor */
}

.member-slot.locked::after {
    /* Removed distracting border overlay */
    display: none;
}

.lock-overlay {
    position: absolute;
    bottom: 2px;
    right: 2px;
    top: auto;
    left: auto;
    width: 16px;
    height: 16px;
    font-size: 0.7rem;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    pointer-events: none;
    z-index: 10;
}

.card-mini {
    width: 60px;
    height: 84px;
}

.card-mini.type-live {
    width: 84px;
    height: 60px;
}

/* Deck Zones */
.deck-zone {
    text-align: center;
}

.deck-stack {
    width: var(--card-width);
    height: var(--card-height);
    margin: 5px auto;
    background: linear-gradient(145deg, #4a5568, #2d3748);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 3px 3px 0 #1a1a2e, 5px 5px 0 #0f0f1a;
}

.deck-count {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-pink);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: bold;
}

.deck-stack.energy-deck {
    background: linear-gradient(145deg, #5a4a20, #3a3010);
}

.deck-stack.energy-deck .deck-count {
    background: var(--accent-gold);
    color: #000;
}

/* Energy Zone */
.energy-zone-cards {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 5px;
}

.energy-pip {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--accent-gold), #d4a800);
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: bold;
    color: #000;
    cursor: pointer;
    transition: all 0.2s;
}

.energy-pip:hover {
    transform: scale(1.1);
}

/* Fix for Stage Member Name Layout */
.member-slot .card-id {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 0.55rem;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 1px 3px;
    border-radius: 3px;
    cursor: copy;
    z-index: 5;
}

.member-slot .name {
    position: absolute;
    bottom: 0px;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 2px 4px;
    font-size: 0.55rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 5;
    box-sizing: border-box;
}

.member-slot .cost {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--accent-pink);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: bold;
    z-index: 5;
}

/* Hover Highlights (UI Feedback) */
.highlight-target {
    border-color: var(--accent-green) !important;
    box-shadow: 0 0 25px var(--accent-green), 0 0 15px var(--accent-green) inset !important;
    transform: scale(1.08) !important;
    z-index: 1000 !important;
    border-width: 3px !important;
}

.highlight-source {
    border-color: var(--accent-pink) !important;
    box-shadow: 0 0 25px var(--accent-pink), 0 0 15px var(--accent-pink) inset !important;
    transform: translateY(-15px) scale(1.05) !important;
    z-index: 1000 !important;
    border-width: 3px !important;
}

/* Actions Panel */
.actions-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    /* Reduced 10->8 */
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Reduced 5->4 */
    flex-shrink: 1;
}

.action-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 8px;
    /* Room for sidebar scrollbar */
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    scrollbar-width: thin;
    min-height: 0;
}

.action-btn {
    padding: 8px 10px;
    background: linear-gradient(135deg, var(--bg-zone), #2a3a4d);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    height: auto;
    min-height: 36px;
    flex-shrink: 0;
}

.action-btn:hover {
    background: linear-gradient(135deg, var(--accent-blue), #3a7bd5);
    transform: translateX(2px);
}

.action-title {
    font-weight: bold;
    white-space: normal;
    word-break: break-word;
    /* Ensure full text is always visible */
    display: block;
    overflow: visible;
}

.action-btn.pass {
    background: linear-gradient(135deg, rgba(48, 160, 96, 0.2), rgba(48, 160, 96, 0.4));
    border-color: var(--accent-green);
    color: #afffd1;
}

.action-btn.confirm {
    background: linear-gradient(135deg, rgba(255, 85, 170, 0.2), rgba(255, 85, 170, 0.4));
    border-color: var(--accent-pink);
    text-align: center;
    justify-content: center;
}

.action-btn.golden {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.5), rgba(217, 119, 6, 0.8));
    border-color: #fbbf24;
    color: #fff;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
    border-width: 2px;
}

.action-btn.golden:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.6);
    transform: scale(1.02) translateX(2px);
}

.mulligan-indicator {
    background: rgba(255, 85, 170, 0.1);
    border: 1px solid var(--accent-pink);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
    text-align: center;
}

.mulligan-indicator h4 {
    color: var(--accent-pink);
    margin: 0 0 5px 0;
    font-size: 0.9rem;
}

.mulligan-indicator p {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin: 0;
}

.action-group-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
    border-bottom: 1px solid rgba(74, 158, 255, 0.2);
    padding-bottom: 2px;
}

.energy-pip.tapped {
    opacity: 0.35;
    filter: grayscale(0.5);
}

.action-source-img {
    width: 30px;
    height: 42px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
    flex-shrink: 0;
}

/* Card Stacks (Discard, Success Lives, etc) */
.card-stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 150px;
    overflow-y: auto;
    padding: 5px;
}

.card-stack-horizontal {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    padding: 5px;
    justify-content: center;
}

/* Hand Zone */
.hand-zone {
    flex: 1;
    min-width: 300px;
}

.hand-cards {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    min-height: 110px;
}

/* Resolution Zone (shared) */
.resolution-zone {
    background: linear-gradient(90deg, var(--bg-zone), #2a3545, var(--bg-zone));
    border: 1px dashed var(--accent-purple);
    text-align: center;
}

.resolution-cards {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 10px;
    min-height: 50px;
}

/* Old sidebar class kept for compatibility if needed, but aliased to sidebar-right in HTML */
.sidebar {
    /* Base styles shared */
    background: var(--bg-secondary);
    /* border-radius: 12px; Remove radius for full height pane */
    /* padding: 12px; */
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.sidebar-section h3 {
    font-size: 0.8rem;
    color: var(--accent-blue);
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
}

/* Sidebar internal list spacing */
.sidebar-action-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-icon {
    font-size: 1rem;
}

.action-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Log Styles */
.log-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.log-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.log-btn:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

/* Yell Count */
.yell-badge {
    font-size: 0.8rem;
    background: linear-gradient(135deg, #e67300, #ff8c00);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Rule Log Styling */
.rule-log-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
    /* Take available space */
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px;
    border-radius: 6px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.65rem;
}

.rule-entry {
    border-left: 2px solid var(--accent-blue);
    padding-left: 8px;
    margin-bottom: 4px;
    color: #ccc;
}

.rule-id {
    color: var(--accent-pink);
    font-weight: bold;
    display: block;
    margin-bottom: 2px;
}

/* God Mode */
.god-mode {
    background: linear-gradient(135deg, #2a1540, var(--bg-secondary));
    border: 1px solid #6b3fa0;
    border-radius: 8px;
    padding: 10px;
}

.god-mode h3 {
    color: #b87aff;
}

.god-mode input,
.god-mode textarea {
    width: 100%;
    padding: 8px;
    margin-bottom: 6px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #6b3fa0;
    border-radius: 5px;
    color: var(--text);
    font-family: monospace;
    font-size: 0.75rem;
}

.god-mode .btn {
    width: 100%;
    margin-bottom: 4px;
    background: linear-gradient(135deg, #6b3fa0, #5030a0);
}

/* Log */
.log-section {
    /* Remove flex:1 to let it shrink if needed, or fixed height */
    flex: 0 0 auto;
    min-height: 100px;
    margin-bottom: 10px;
}

.log-list {
    flex: 1;
    overflow-y: auto;
    font-size: 0.85rem;
    padding-right: 5px;
    color: var(--text-dim);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    padding: 8px;
    border: 1px solid var(--border);
}

.turn-navigator {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding: 5px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    scrollbar-width: thin;
}

.turn-nav-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.turn-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.turn-nav-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(0, 191, 255, 0.3);
}

.log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.action-desc {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* Highlighting (Moved to consolidated section) */

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

.perf-success {
    background: rgba(80, 200, 80, 0.2);
    color: #4f4;
    border: 1px solid #4f4;
    animation: pulse 2s infinite;
}

.perf-failure {
    background: rgba(200, 80, 80, 0.2);
    color: #f44;
    border: 1px solid #f44;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

/* --- Mobile Responsiveness --- */

/* Mobile styles moved to end of file */

/* Mobile Action Toggle Button (Hidden on Desktop) */
#mobile-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent-pink);
    color: white;
    font-size: 1.5rem;
    z-index: 1100;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}



/* --- UI Polish --- */

/* Smoother transitions */
.card,
.member-slot,
.action-btn {
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Card Hover Glow */
.card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 10px rgba(74, 158, 255, 0.3);
    border-color: var(--accent-blue);
    z-index: 10;
}

/* New Card Animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card.new-card {
    animation: slideIn 0.5s ease-out;
}

.action-btn:hover {
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.2), rgba(74, 158, 255, 0.1));
    border-color: var(--accent-blue);
}

/* Header Polish */
.header {
    background: rgba(26, 35, 50, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* Zone Titles */
.zone-title {
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    font-weight: 600;
}

/* Scrollbar Polish */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

@media (max-width: 768px) {
    :root {
        /* Mobile Scaling - significantly smaller */
        --card-width: 50px;
        --card-height: 70px;
        --card-width-mini: 45px;
        --card-height-mini: 63px;
        --card-width-landscape: 80px;
        --card-height-landscape: 57px;
    }

    .header h1 {
        display: none;
    }

    /* Mobile Header Optimization: Hide button text */
    .header .controls .btn {
        padding: 3px 6px;
        /* Tighter padding */
    }

    /* Specifically hide text for Update and Settings which have icons */
    button[onclick="fetchState()"] .btn-text,
    button[onclick="openSettingsModal()"] .btn-text {
        display: none;
    }

    /* For Reset, it feels dangerous to be just text or hidden. Let's make it icon only? */
    /* Injecting content via CSS is tricky for localization. Let's assume we can just shorten it or hide it if not critical? */
    /* Actually let's just make the text smaller or hide specific classes we added */

    /* Standardize: Hide text inside buttons in header controls on mobile */
    .controls .btn {
        font-size: 0.9rem;
        /* Make icons larger if text is gone */
    }

    .controls .btn span {
        display: none;
    }

    /* But we need to ensure Reset button has an icon then! */

    /* Further Mobile: Condense Info Bar */
    .info-bar .stat .stat-label {
        display: none;
        /* Hide "Turn", "Phase", "Score" labels */
    }

    .info-bar .stat {
        padding: 2px 5px;
        /* Even tighter */
        gap: 2px;
    }

    .header-main-row {
        gap: 5px;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        /* Ensure alignment */
    }


    .controls {
        width: auto;
        order: 3;
    }



    body {
        overflow-x: hidden;
        /* Prevent horizontal scroll on body */
    }

    /* Header Adjustments */
    .header {
        padding: 4px 8px;
        /* Reduced horizontal padding too */
        flex-direction: column;
        /* Stack vertically for better control */
        align-items: stretch;
    }

    .header h1 {
        font-size: 0.9rem;
        text-align: center;
        /* Center title */
        width: 100%;
        margin-bottom: 2px;
    }

    .stat-label {
        display: none;
        /* Hide Labels on mobile */
    }

    /* Grid Layout for Info Bar - Middle */
    .info-bar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 2px;
        width: 100%;
        margin: 0;
        order: 2;
        /* Middle */
        border-top: none;
        padding-top: 0;
        background: transparent;
        border-bottom: none;
    }

    .info-bar .stat {
        padding: 2px 0;
        font-size: 0.8rem;
        width: 100%;
        justify-content: flex-start;
        /* Align text left */
        white-space: nowrap;
    }

    .stat-label {
        display: inline !important;
        /* Show Text Titles */
        margin-right: 4px;
        color: #aaa;
        font-size: 0.75rem;
    }

    .stat-icon {
        display: none !important;
        /* Hide Emojis */
    }

    .stat strong {
        font-size: 0.85rem;
        color: white;
    }

    /* Enforce single line if possible, or clean wrapping */
    .header-main-row {
        gap: 4px;
        /* Reduced gap */
    }

    /* Controls - Bottom */
    .controls {
        width: 100%;
        order: 3;
        /* Bottom */
        gap: 5px;
        display: flex;
        justify-content: center;
        /* Center buttons */
        margin-top: 4px;
        padding-top: 4px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .btn-text {
        display: none;
        /* Hide button text on small mobile */
    }

    .controls .btn {
        padding: 6px;
        border-radius: 8px;
        /* Slightly less rounded than 50% for text-icons */
        width: auto;
        height: 34px;
        justify-content: center;
    }

    .deck-discard-group {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .card-area.deck,
    .card-area.energy-deck {
        margin: 0 auto;
    }

    .btn-primary .btn-text {
        display: inline;
        /* Allow text for Bug Report if it fits */
    }

    .btn-primary {
        border-radius: 20px !important;
        width: auto !important;
        padding: 4px 10px !important;
        height: auto !important;
    }

    /* Game Container Stack */
    .game-container {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        padding: 5px;
        padding-bottom: 200px;
        /* Increased for Mobile Action Bar + Hand */
        width: 100%;
        overflow-x: hidden;
        transition: padding-bottom 0.3s;
    }

    body.sidebar-open .game-container {
        padding-bottom: 50vh;
        /* Push content up if needed, or just let overlay happen */
    }

    .game-board {
        width: 100%;
        overflow: visible;
        padding: 0;
        gap: 15px;
        /* Increase gap between sections */
    }

    /* Mobile: Hide Left Sidebar and Resizers */
    .sidebar-left,
    .resizer {
        display: none;
    }

    /* Sidebar - Bottom Sheet Style */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 45vh;
        /* Occupy bottom 45% */
        background: rgba(15, 20, 30, 0.98);
        z-index: 2000;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.5);
        padding: 10px;
        padding-top: 40px;
        /* Space for close button if keeping it, or just handle */
        overflow-y: auto;
        border-top: 1px solid var(--border);
        border-radius: 12px 12px 0 0;
        border-left: none;
        border-bottom: none;
        top: auto;
    }

    .sidebar.active {
        transform: translateY(0);
    }

    .sidebar.visible {
        transform: translateY(0);
    }

    /* Sidebar Toggle - Float Bottom Right */
    #mobile-sidebar-toggle {
        display: flex;
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: var(--accent-pink);
        color: white;
        font-size: 1.5rem;
        z-index: 2100;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
        align-items: center;
        justify-content: center;
        border: 2px solid white;
        transition: bottom 0.3s;
    }

    /* Move toggle up when sidebar open */
    body.sidebar-open #mobile-sidebar-toggle {
        bottom: calc(45vh + 10px);
    }

    /* Player Sections */
    .player-section {
        padding: 8px;
        width: 100%;
        background: rgba(26, 35, 50, 0.8);
        overflow: hidden;
        /* Prevent background bleeding */
    }

    .board-inner {
        overflow-x: auto;
        /* Allow horizontal scroll for the board itself if it gets too narrow */
        width: 100%;
    }

    .field-row {
        display: grid;
        grid-template-columns: minmax(50px, auto) 1fr minmax(60px, auto) !important;
        gap: 6px;
        width: 100%;
        align-items: flex-start;
    }

    /* Zone Layouts - Horizontal Scroll */
    .zones-row {
        gap: 8px;
        width: 100%;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
        min-height: min-content;
        /* Fix flex collapse */
    }

    .zone {
        min-width: 75px;
        /* Sufficient for card width */
        padding: 6px;
        flex-shrink: 0;
    }

    /* Stage Slots */
    .stage-slots {
        gap: 10px;
        flex-wrap: nowrap;
        min-width: min-content;
    }

    .member-slot {
        width: var(--card-width);
        height: var(--card-height);
        flex-shrink: 0;
    }

    .card {
        flex-shrink: 0;
    }

    /* Hand Zone Specifics - Full Width on Mobile */
    .hand-zone {
        min-width: 100%;
        margin-left: -8px;
        /* Counteract player-section padding */
        margin-right: -8px;
        /* Counteract player-section padding */
        width: calc(100% + 16px);
        border-right: none;
        border-left: none;
        border-radius: 0;
    }

    .hand-cards {
        gap: 5px;
        /* Use smaller gap on mobile? No we use negative margin now */
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding: 10px 15px;
        /* Comfortable touch padding */
    }

    /* Modal Adjustments */
    .modal-content {
        width: 95%;
        max-height: 85vh;
        padding: 15px;
        margin-bottom: 50px;
        /* Avoid bottom area overlap */
    }

    /* Mobile Action Bar - quick access for primary actions */
    #mobile-action-bar {
        display: flex !important;
        /* Force show */
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: rgba(15, 20, 30, 0.98);
        border-top: 2px solid var(--accent-pink);
        z-index: 9999;
        /* Max z-index */
        padding: 5px 10px;
        gap: 10px;
        align-items: center;
        justify-content: flex-start;
        /* Changed from space-around to allow scrolling */
        overflow-x: auto;
        /* Enable horizontal scroll */
        white-space: nowrap;
        /* Prevent buttons from wrapping */
        box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.8);
        scrollbar-width: none;
        /* Hide scrollbar for cleaner look on mobile */
    }

    #mobile-action-bar::-webkit-scrollbar {
        display: none;
        /* Hide scrollbar for Chrome/Safari */
    }

    #mobile-action-bar .action-btn {
        flex: 1;
        max-width: 150px;
        height: 44px;
        font-size: 0.85rem;
        background: var(--accent-pink);
        color: white;
        border: none;
        border-radius: 8px;
        font-weight: bold;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    }

    #mobile-action-bar .action-btn.pass {
        background: #444 !important;
    }

    #mobile-action-bar .action-btn.confirm {
        background: var(--accent-blue) !important;
    }
}

.card.card-locked::after {
    /* No lightning emoji, maybe a subtle indicator if needed, but darkening cost is primary */
    display: none;
}

.card.card-locked .cost {
    background: #222 !important;
    /* Darken energy circle */
    color: #777 !important;
    border: 1px solid #444 !important;
    box-shadow: none !important;
}

.card.card-baton-playable .cost {
    background: linear-gradient(135deg, #FFD700, #FFA500) !important;
    color: #000 !important;
    border: 1px solid #fff !important;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.6) !important;
}

.card.card-playable .cost {
    /* Standard look, but maybe a subtle glow to signal it is ready */
    box-shadow: 0 0 5px var(--accent-pink);
}

.card.card-playable {
    box-shadow: 0 0 10px var(--accent-blue);
    border: 2px solid var(--accent-blue) !important;
    cursor: pointer;
}

/* Loader for Turn Banner */
.loader {
    width: 16px;
    height: 16px;
    border: 2px solid #ef5350;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Card Modifiers */
.modifiers-container {
    position: absolute;
    bottom: 13px;
    /* Just above Name bar (approx 13px height) */
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    z-index: 8;
    background: rgba(0, 0, 0, 0.6);
    pointer-events: none;
    max-height: 45px;
    overflow-y: auto;
}

.modifier-line {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 1px 2px;
    font-size: 0.55rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 2px solid var(--accent-gold);
    background: rgba(245, 197, 66, 0.15);
}

.mod-icon {
    font-size: 0.6rem;
    flex-shrink: 0;
}

.mod-desc {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Enhanced Log Styles */
.log-entry {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.85rem;
    line-height: 1.4;
    animation: slideInLeft 0.3s ease-out;
}

.log-entry.action {
    border-left: 3px solid var(--accent-blue);
    background: rgba(74, 158, 255, 0.05);
}

.log-entry.effect {
    border-left: 3px solid var(--accent-purple);
    background: rgba(168, 85, 247, 0.05);
}

.log-entry.turn {
    background: rgba(245, 197, 66, 0.1);
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid var(--accent-gold);
    color: var(--accent-gold);
}

.log-entry.score {
    color: var(--accent-green);
    font-weight: bold;
}

.log-entry.ability {
    border-left: 3px solid var(--accent-gold);
    background: rgba(255, 215, 0, 0.08);
    color: #ffd54f;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Game Feed (Human Readable) */
.game-feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.feed-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    padding: 4px 0;
}

.feed-icon {
    font-size: 1.2rem;
}

/* Highlight Source/Target for Actions (Moved to consolidated section) */

/* --- Tablet Responsiveness (769px - 1100px) --- */
@media (min-width: 769px) and (max-width: 1100px) {

    .sidebar-left,
    .sidebar-right {
        width: 220px !important;
        font-size: 0.9rem;
    }

    .field-row {
        grid-template-columns: minmax(70px, auto) 1fr minmax(110px, auto) !important;
        gap: 8px;
    }

    :root {
        --card-width: 62px;
        --card-height: 87px;
    }
}

/* Board Spacing Improvements for all widths */
.game-board {
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 15px;
    /* Increased gap between opponent/player sections */
    max-width: 1400px;
    /* Prevent over-stretching on ultrawide */
    margin: 0 auto;
    /* Center board */
}

.player-section {
    width: 100%;
    margin-bottom: 20px;
}

/* Enable text selection for log areas */
#log,
.log-list,
#rule-log,
.rule-log-list,
#diag-content,
.card-desc-content {
    user-select: text !important;
    cursor: text;
}