html, body {
    background: #0a0e1a !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure game container is visible */
#game-container {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* === CSS Variables - Extended from Minecraft CSS === */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

:root {
    /* Game-specific colors */
    --bg-dark: #0a0e1a;
    --bg-card: var(--primary-color);
    --bg-panel: var(--background-color);
    --bg-secondary: #0f1419;
    --border: var(--secondary-color);
    --border-color: var(--secondary-color);

    /* Player Colors */
    --player-blue: #3b82f6;
    --player-blue-light: #60a5fa;
    --player-blue-spawn: rgba(59, 130, 246, 0.25);
    --player-blue-glow: rgba(59, 130, 246, 0.4);
    --player-red: #ef4444;
    --player-red-light: #f87171;
    --player-red-spawn: rgba(239, 68, 68, 0.25);
    --player-red-glow: rgba(239, 68, 68, 0.4);

    /* Tile Colors */
    --tile-light: #1e2433;
    --tile-dark: #151a26;

    /* Highlight Colors */
    --highlight-move: rgba(34, 197, 94, 0.4);
    --highlight-attack: rgba(239, 68, 68, 0.4);
    --highlight-ability: rgba(168, 85, 247, 0.4);
    --highlight-selected: rgba(250, 204, 21, 0.8);

    /* Mana */
    --mana-color: #8b5cf6;
    --mana-empty: #2d3142;

    /* Text */
    --text-primary: var(--text-color);
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Sizing - Responsive defaults */
    --tile-size: 56px;
    --card-width: 75px;
    --card-height: 90px;

    /* Animation */
    --transition-fast: 0.15s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Base Styles === */
body {
    font-family: MinecraftRegular, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif !important;
    background: var(--bg-dark) !important;
    min-height: 100vh;
    color: var(--text-primary) !important;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--player-blue);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--player-blue-light);
}

/* === Game Container === */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(8px, 2vw, 16px);
    gap: clamp(8px, 2vw, 12px);
    min-height: 100vh;
    width: 100%;
    max-height: 100vh;
    overflow: hidden;
}

/* === Start Screen (Non-Modal) === */
.start-screen-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    padding: 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.start-screen-content {
    background: var(--background-color);
    border: 3px solid var(--secondary-color);
    padding: 40px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
}

.start-screen-title {
    font-family: MinecraftTen, sans-serif !important;
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 800;
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: 8px;
}

.start-screen-subtitle {
    font-family: MinecraftRegular, sans-serif;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 40px;
    font-size: 1.1rem;
}

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

.start-screen-buttons .action-btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 1.1rem;
}

.start-screen-footer {
    margin-top: 32px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: MinecraftRegular, sans-serif;
}

.start-screen-footer a {
    color: var(--player-blue);
    text-decoration: underline;
}

.start-screen-footer a:hover {
    color: var(--player-blue-light);
}

/* Preloader spinner for loading states */
.preloader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--secondary-color);
    border-top-color: var(--mana-color);
    border-radius: 0px;
    animation: spin 1s linear infinite;
}

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

/* === Header === */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    padding: clamp(8px, 2vw, 12px) clamp(12px, 3vw, 20px);
    background: var(--background-color);
    border: 3px solid var(--secondary-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    gap: 12px;
}

.game-title {
    font-family: MinecraftTen, sans-serif !important;
    font-size: clamp(1rem, 3vw, 1.4rem);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 3px;
}

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

.btn-compact {
    padding: 8px 16px !important;
    font-size: 0.9rem !important;
    padding-bottom: 12px !important;
}

.btn-compact.secondary {
    padding-bottom: 10px !important;
}

/* Make End Turn button more prominent - fixed position bottom right */
#btn-end-turn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 28px !important;
    font-size: 1.1rem !important;
    padding-bottom: 16px !important;
    min-width: 140px;
    max-width: 200px;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.turn-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 0px;
    font-family: MinecraftRegular, sans-serif;
    font-weight: 600;
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    transition: all var(--transition-smooth);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.turn-indicator.blue {
    background: linear-gradient(135deg, var(--player-blue-spawn), rgba(59, 130, 246, 0.15));
    border: 2px solid var(--player-blue);
    color: var(--player-blue-light);
}

.turn-indicator.red {
    background: linear-gradient(135deg, var(--player-red-spawn), rgba(239, 68, 68, 0.15));
    border: 2px solid var(--player-red);
    color: var(--player-red-light);
}

.turn-indicator .player-dot {
    width: 10px;
    height: 10px;
    border-radius: 0px;
    animation: pulse-dot 2s infinite;
}

.turn-indicator.blue .player-dot {
    background: var(--player-blue);
    box-shadow: 0 0 8px var(--player-blue-glow);
}

.turn-indicator.red .player-dot {
    background: var(--player-red);
    box-shadow: 0 0 8px var(--player-red-glow);
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

.turn-number {
    color: var(--text-secondary);
    font-size: clamp(0.7rem, 1.5vw, 0.85rem);
    font-weight: 600;
}

/* === Main Game Area === */
.game-main {
    display: flex;
    gap: clamp(8px, 2vw, 16px);
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    justify-content: center;
    flex: 1;
    min-height: 0;
}

/* === Player Panels === */
.player-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: clamp(140px, 15vw, 180px);
    padding: 16px;
    background: var(--background-color);
    border: 3px solid var(--secondary-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    transition: all var(--transition-smooth);
}

.player-panel.active {
    border-color: var(--player-blue);
    box-shadow: 0 0 20px var(--player-blue-glow);
}

.player-panel.active.red {
    border-color: var(--player-red);
    box-shadow: 0 0 20px var(--player-red-glow);
}

.player-name {
    font-family: MinecraftRegular, sans-serif;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-name.blue { color: var(--player-blue-light); }
.player-name.red { color: var(--player-red-light); }

.player-name::before {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 0px;
    box-shadow: 0 0 8px currentColor;
}

.player-name.blue::before { background: var(--player-blue); }
.player-name.red::before { background: var(--player-red); }

/* === Mana Bar === */
.mana-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mana-label {
    font-family: MinecraftRegular, sans-serif;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.mana-display {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.mana-orb {
    width: 20px;
    height: 20px;
    border-radius: 0px;
    background: var(--mana-empty);
    border: 2px solid var(--border);
    transition: all var(--transition-smooth);
}

.mana-orb.filled {
    background: linear-gradient(135deg, var(--mana-color), #a78bfa);
    border-color: var(--mana-color);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.6);
    animation: mana-glow 2s infinite;
}

.mana-orb.bonus {
    background: linear-gradient(135deg, #a855f7, #c084fc);
    border-color: #a855f7;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.6);
}

@keyframes mana-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(139, 92, 246, 0.4); }
    50% { box-shadow: 0 0 16px rgba(139, 92, 246, 0.8); }
}

.mana-text {
    font-family: MinecraftRegular, sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--mana-color);
    text-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
}

/* === Deck Info === */
.deck-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0px;
    border: 1px solid var(--border);
}

.deck-icon {
    width: 32px;
    height: 40px;
    background: linear-gradient(135deg, var(--bg-card), var(--bg-dark));
    border-radius: 0px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.deck-count {
    font-family: MinecraftRegular, sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
}

.deck-label {
    font-family: MinecraftRegular, sans-serif;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Board Wrapper === */
.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 100%;
    min-height: 0;
    justify-content: center;
}

/* === Game Board === */
.board-container {
    padding: clamp(6px, 1.5vw, 12px);
    background: var(--background-color);
    border: 3px solid var(--secondary-color);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.board {
    display: grid;
    grid-template-columns: repeat(8, var(--tile-size));
    grid-template-rows: repeat(10, var(--tile-size));
    gap: 1px;
    border-radius: 0px;
    overflow: hidden;
    background: var(--bg-dark);
}

.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tile.light { background: var(--tile-light); }
.tile.dark { background: var(--tile-dark); }

.tile::before {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 4px;
    height: 4px;
    border-radius: 0px;
    background: rgba(255, 255, 255, 0.1);
    transition: opacity var(--transition-fast);
}

.tile.dark::before { background: rgba(0, 0, 0, 0.4); }
.tile.blue-spawn { box-shadow: inset 0 0 0 999px var(--player-blue-spawn); }
.tile.red-spawn { box-shadow: inset 0 0 0 999px var(--player-red-spawn); }

.tile:hover {
    filter: brightness(1.15);
    transform: scale(1.02);
}

/* Tile Highlights */
.tile.highlight-attack-preview {
    background-color: rgba(239, 68, 68, 0.2);
    border: 2px dashed rgba(239, 68, 68, 0.7);
}

.tile.highlight-move {
    box-shadow: inset 0 0 0 999px var(--highlight-move) !important;
    animation: pulse-move 2s infinite ease-in-out;
}

.tile.highlight-attack {
    box-shadow: inset 0 0 0 999px var(--highlight-attack) !important;
    animation: pulse-attack 1.5s infinite ease-in-out;
}

.tile.highlight-ability {
    box-shadow: inset 0 0 0 999px var(--highlight-ability) !important;
    animation: pulse-ability 2s infinite ease-in-out;
}

.tile.highlight-selected {
    outline: 3px solid var(--highlight-selected);
    outline-offset: -3px;
    z-index: 10;
    box-shadow: 0 0 16px rgba(250, 204, 21, 0.5);
}

@keyframes pulse-move {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes pulse-attack {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes pulse-ability {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; filter: hue-rotate(15deg); }
}

/* === Minion Display === */
.minion {
    position: relative;
    width: calc(var(--tile-size) - 6px);
    height: calc(var(--tile-size) - 6px);
    border-radius: 0px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    transition: transform var(--transition-smooth);
    background: var(--bg-card);
    border: 2px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.minion.blue {
    border-color: var(--player-blue);
    box-shadow: 0 0 12px var(--player-blue-glow), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.minion.red {
    border-color: var(--player-red);
    box-shadow: 0 0 12px var(--player-red-glow), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.minion-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    z-index: 1;
    border-radius: 0px;
    overflow: hidden;
}

.minion-content img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.minion:hover .minion-name-tag { opacity: 1; }

.minion.can-act { animation: active-glow 2s infinite; }

@keyframes active-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 255, 255, 0.2); }
    50% { box-shadow: 0 0 16px rgba(255, 255, 255, 0.4); }
}

.minion img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0px;
}

.minion-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    font-family: MinecraftRegular, sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
}

.minion.can-act::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 0px;
    box-shadow: 0 0 6px #22c55e;
    animation: pulse-ready 2s infinite;
}

@keyframes pulse-ready {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

.minion.just-spawned::after {
    background: #fbbf24;
    box-shadow: 0 0 6px #fbbf24;
}

.minion:hover {
    transform: scale(1.08);
    z-index: 10;
}

.minion.villager::before {
    content: '';
    position: absolute;
    top: -8px;
    font-size: 14px;
}

/* === Hand Area === */
.hand-section {
    width: 100%;
    max-width: 600px;
}

.hand-label {
    font-family: MinecraftRegular, sans-serif;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
}

.hand {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 100px;
    max-height: 130px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    background: var(--background-color);
    border: 3px solid var(--secondary-color);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.card {
    width: var(--card-width);
    height: var(--card-height);
    background: var(--primary-color);
    border: 3px solid var(--secondary-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all var(--transition-smooth);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.card:hover {
    border-color: var(--mana-color);
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}

.card.selected {
    border-color: var(--highlight-selected);
    background: var(--primary-color);
    transform: translateY(-6px);
    box-shadow: 0 8px 20px rgba(250, 204, 21, 0.5);
}

.card.cannot-afford {
    opacity: 0.4;
    cursor: not-allowed;
}

.card.cannot-afford:hover {
    transform: none;
    border-color: var(--secondary-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.card-image {
    width: 50px;
    height: 50px;
    border-radius: 0px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: MinecraftRegular, sans-serif;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 6px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-name {
    font-family: MinecraftRegular, sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-cost {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 0px;
    background: linear-gradient(135deg, var(--mana-color), #a78bfa);
    border: 2px solid var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: MinecraftRegular, sans-serif;
    font-size: 0.75rem;
    font-weight: 800;
    color: white;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.6);
}

/* === Action Buttons - Minecraft Style === */
.action-bar {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 500px;
}

.action-btn {
    font-family: MinecraftTen, sans-serif !important;
    align-items: center;
    display: flex;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    user-select: none;
    cursor: pointer;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-shadow: 2.5px 2.5px 0 rgba(0,0,0,.343);
    white-space: nowrap;
    border: none;
}

.action-btn.primary {
    background: var(--btn-primary-inner-color) !important;
    background-color: var(--btn-primary-inner-color) !important;
    border: 3px solid var(--btn-primary-border-color) !important;
    box-shadow: inset 0 -6px 0 0 var(--btn-primary-inner-shadow-color), 
                inset 3px 3px 0 var(--btn-primary-inner-border-lt-color), 
                inset -3px -9px 0 var(--btn-primary-inner-border-br-color) !important;
    color: var(--btn-primary-text-color) !important;
    padding-bottom: 15px !important;
    padding-top: 5px !important;
}

.action-btn.primary:hover {
    background-color: var(--btn-primary-inner-hover-color) !important;
}

.action-btn.primary:active {
    box-shadow: inset 0 0 0 0 var(--btn-primary-inner-shadow-color), 
                inset 3px 3px 0 var(--btn-primary-inner-border-lt-color), 
                inset -3px -3px 0 var(--btn-primary-inner-border-br-color) !important;
    position: relative;
    top: 2px;
}

.action-btn.secondary {
    background: var(--btn-tertiary-inner-color) !important;
    background-color: var(--btn-tertiary-inner-color) !important;
    border: 3px solid var(--btn-tertiary-border-color) !important;
    box-shadow: inset 0 -6px 0 0 var(--btn-tertiary-inner-shadow-color), 
                inset 3px 3px 0 var(--btn-tertiary-inner-border-lt-color), 
                inset -3px -9px 0 var(--btn-tertiary-inner-border-br-color) !important;
    color: var(--btn-tertiary-text-color) !important;
    padding-bottom: 12px !important;
    font-family: MinecraftRegular, sans-serif !important;
    letter-spacing: 0.5px !important;
    text-shadow: none !important;
}

.action-btn.secondary:hover {
    background-color: var(--btn-tertiary-inner-hover-color) !important;
}

.action-btn.secondary:active {
    box-shadow: inset 0 0 0 0 var(--btn-tertiary-inner-shadow-color), 
                inset 3px 3px 0 var(--btn-tertiary-inner-border-lt-color), 
                inset -3px -3px 0 var(--btn-tertiary-inner-border-br-color) !important;
    position: relative;
    top: 2px;
}

.action-btn.danger {
    background: #dc3545 !important;
    background-color: #dc3545 !important;
    border: 3px solid var(--btn-primary-border-color) !important;
    box-shadow: inset 0 -6px 0 0 #a02834, 
                inset 3px 3px 0 rgba(220, 53, 69, 0.75), 
                inset -3px -9px 0 #8b1f2e !important;
    color: white !important;
    padding-bottom: 15px !important;
    padding-top: 5px !important;
}

.action-btn.danger:hover {
    background-color: #c82333 !important;
}

.action-btn.danger:active {
    box-shadow: inset 0 0 0 0 #a02834, 
                inset 3px 3px 0 rgba(220, 53, 69, 0.75), 
                inset -3px -3px 0 #8b1f2e !important;
    position: relative;
    top: 2px;
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.btn-success {
    background: #28a745 !important;
    background-color: #28a745 !important;
    border: 3px solid var(--btn-primary-border-color) !important;
    box-shadow: inset 0 -6px 0 0 #1e7e34, 
                inset 3px 3px 0 rgba(40, 167, 69, 0.75), 
                inset -3px -9px 0 #155724 !important;
    color: white !important;
    padding-bottom: 15px !important;
    padding-top: 5px !important;
}

.btn-success:hover {
    background-color: #218838 !important;
}

.btn-success:active {
    box-shadow: inset 0 0 0 0 #1e7e34, 
                inset 3px 3px 0 rgba(40, 167, 69, 0.75), 
                inset -3px -3px 0 #155724 !important;
    position: relative;
    top: 2px;
}

.btn-small {
    padding: 6px 12px !important;
    font-size: 0.8rem !important;
}

/* === Modal Overlay === */
.modal-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(4px);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 100 !important;
    padding: 16px;
}

.modal-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Only apply to game modals inside modal-overlay, not admin panel modals */
.modal-overlay > .modal {
    font-family: MinecraftRegular, sans-serif !important;
    background: var(--background-color) !important;
    border: 3px solid var(--secondary-color) !important;
    padding: 24px !important;
    max-width: 800px;
    width: auto !important;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5) !important;
    display: block !important;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Only apply to game modals */
.modal-overlay .modal-title {
    font-family: MinecraftTen, sans-serif !important;
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    font-weight: 800;
    margin-bottom: 20px;
    text-align: center;
    color: var(--text-primary);
}

/* === Deck Builder === */
.deck-builder {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
}

.minion-pool-section {
    display: flex;
    flex-direction: column;
}

.minion-pool {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
    max-height: 500px;
    overflow-y: auto;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0px;
}

.deck-preview {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0px;
    padding: 16px;
}

/* Make deck builder modal larger */
.modal-overlay .modal:has(.deck-builder) {
    max-width: 1200px !important;
    width: 95vw !important;
    max-height: 90vh !important;
}

.deck-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.deck-slot {
    width: 42px;
    height: 42px;
    border-radius: 0px;
    background: var(--bg-dark);
    border: 1px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
}

.deck-slot.filled {
    border-style: solid;
    border-color: var(--mana-color);
}

.deck-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* === Game Over Screen === */
.game-over {
    text-align: center;
}

.game-over-title {
    font-family: MinecraftTen, sans-serif;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 16px;
}

.game-over-title.blue { color: var(--player-blue); }
.game-over-title.red { color: var(--player-red); }

.game-over-subtitle {
    font-family: MinecraftRegular, sans-serif;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* === Tooltip === */
.tooltip {
    font-family: MinecraftRegular, sans-serif;
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0px;
    padding: 10px 12px;
    z-index: 200;
    pointer-events: none;
    max-width: 220px;
}

.tooltip-title {
    font-weight: 700;
    margin-bottom: 3px;
}

.tooltip-cost {
    color: var(--mana-color);
    font-size: 0.8rem;
}

.tooltip-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* === Animations === */
@keyframes spawn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.minion-spawn { animation: spawn 0.2s ease-out; }

@keyframes attack {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.minion-attack { animation: attack 0.15s ease-out; }

@keyframes death {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

.minion-death { animation: death 0.2s ease-out forwards; }

/* === Dash Indicator === */
.minion.dash-mode::before {
    content: '';
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background-color: #fbbf24;
    background-image: url('../assets/lightning.png');
    background-size: cover;
    background-position: center;
    border-radius: 0px;
    border: 2px solid var(--bg-panel);
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.minion.villager::before {
    left: 50%;
    transform: translateX(-50%);
    top: -10px;
    right: auto;
}

/* === Grid Labels === */
.board-grid-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.board-labels-top {
    display: grid;
    grid-template-columns: 20px repeat(8, var(--tile-size));
    gap: 1px;
    padding-left: 1px;
}

.board-center-section {
    display: flex;
    gap: 4px;
}

.board-labels-left {
    display: grid;
    grid-template-rows: repeat(10, var(--tile-size));
    gap: 1px;
    width: 20px;
    padding-top: 1px;
}

.label-cell {
    font-family: MinecraftRegular, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
}

/* === Board Flipping === */
.board-grid-wrapper.flipped { transform: rotate(180deg); }
.board-grid-wrapper.flipped .minion { transform: rotate(180deg); }
.board-grid-wrapper.flipped .label-cell { transform: rotate(180deg); }

.board-grid-wrapper.flipped .damage-text,
.board-grid-wrapper.flipped .heal-text {
    transform: translate(-50%, -50%) rotate(180deg);
}

/* === Action Hint === */
.action-hint {
    font-family: MinecraftRegular, sans-serif;
    color: var(--text-secondary);
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    min-height: 24px;
    margin-bottom: 8px;
    text-align: center;
    font-style: italic;
    font-weight: 500;
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0px;
    border: 1px solid var(--border);
}

/* === Page-specific styles === */
.back-btn {
    font-family: MinecraftRegular, sans-serif !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 10px 20px;
    background: var(--btn-tertiary-inner-color) !important;
    border: 3px solid var(--btn-tertiary-border-color) !important;
    box-shadow: inset 0 -6px 0 0 var(--btn-tertiary-inner-shadow-color), 
                inset 3px 3px 0 var(--btn-tertiary-inner-border-lt-color), 
                inset -3px -9px 0 var(--btn-tertiary-inner-border-br-color) !important;
    color: var(--btn-tertiary-text-color) !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}

.back-btn:hover {
    background-color: var(--btn-tertiary-inner-hover-color) !important;
}

.back-btn:active {
    box-shadow: inset 0 0 0 0 var(--btn-tertiary-inner-shadow-color), 
                inset 3px 3px 0 var(--btn-tertiary-inner-border-lt-color), 
                inset -3px -3px 0 var(--btn-tertiary-inner-border-br-color) !important;
    position: relative;
    top: 2px;
}

.search-box, input[type="text"], input[type="number"], input[type="password"], select {
    font-family: MinecraftRegular, sans-serif !important;
    background-color: var(--primary-color) !important;
    border: 3px solid var(--btn-primary-border-color) !important;
    box-shadow: inset 0 6px var(--secondary-color) !important;
    color: var(--text-color) !important;
    font-size: 1rem;
    padding: 12px 20px !important;
    transition: none !important;
}

.search-box:focus, input[type="text"]:focus, input[type="number"]:focus, input[type="password"]:focus, select:focus {
    outline: none !important;
    border-color: var(--btn-primary-border-color) !important;
}

.search-box::placeholder, input::placeholder {
    color: var(--text-muted) !important;
}

.stat-card {
    background: var(--background-color);
    border: 3px solid var(--secondary-color);
    padding: 20px;
    text-align: center;
    transition: all var(--transition-smooth);
}

.stat-card:hover {
    border-color: var(--mana-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.stat-value {
    font-family: MinecraftTen, sans-serif;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    color: var(--mana-color);
    font-weight: 800;
}

.stat-label {
    font-family: MinecraftRegular, sans-serif;
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.loading {
    font-family: MinecraftRegular, sans-serif;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.error {
    font-family: MinecraftRegular, sans-serif;
    text-align: center;
    padding: 40px;
    color: var(--player-red);
    font-size: 1.1rem;
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #4ade80);
    color: white;
    border: none;
}

.btn-success:hover {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* === Responsive === */
@media (max-width: 1200px) {
    :root { --tile-size: 50px; }
    .player-panel { width: 140px; padding: 12px; }
}

@media (max-width: 900px) {
    :root { --tile-size: 44px; }
    
    .game-main {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .player-panel {
        width: 100%;
        max-width: 500px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .player-panel > * {
        flex: 1 1 auto;
        min-width: 140px;
    }
    
    .game-header {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    
    .header-actions {
        width: 100%;
        justify-content: center;
        order: 4;
    }
    
    .turn-indicator {
        order: 3;
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 600px) {
    :root {
        --tile-size: 38px;
        --card-width: 65px;
        --card-height: 80px;
    }
    
    .game-container { padding: 4px; gap: 6px; }
    .game-header { padding: 8px 12px; border-radius: 0px; }
    .game-title { font-size: 1.1rem; letter-spacing: 2px; }
    .turn-number { font-size: 0.7rem; }
    .board-container { padding: 4px; }
    .player-panel { padding: 10px; gap: 8px; }
    .hand { gap: 4px; padding: 6px; min-height: 90px; }
    
    .action-bar {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .action-btn {
        padding: 8px 14px;
        font-size: 0.75rem;
        flex: 1;
        min-width: 100px;
    }
    
    .modal-overlay .modal {
        padding: 16px;
        max-width: 95vw;
        max-height: 90vh;
    }
    
    .deck-builder {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .deck-preview { order: -1; }
    .minion-pool { max-height: 300px; }
}

@media (max-width: 400px) {
    :root { --tile-size: 32px; }
    .game-title { font-size: 1rem; }
    .turn-indicator { padding: 6px 12px; font-size: 0.7rem; }
    .card { width: 56px; height: 72px; }
    .card-image { width: 36px; height: 36px; }
    .card-name { font-size: 0.5rem; }
}

/* Mobile-specific fixes */
@media (max-width: 500px) {
    /* Make board scrollable horizontally on very small screens */
    .board-wrapper {
        overflow-x: auto;
        overflow-y: auto;
        max-width: 100vw;
        justify-content: flex-start;
        padding: 0 4px;
    }
    
    .board-container {
        flex-shrink: 0;
    }
    
    /* Move End Turn button to avoid overlap */
    #btn-end-turn {
        bottom: 16px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        width: auto;
        max-width: 180px;
        padding: 10px 20px !important;
        font-size: 1rem !important;
    }
    
    /* Adjust hand for small screens */
    .hand {
        min-height: 80px;
        max-height: 100px;
    }
    
    .hand-section {
        max-width: 100%;
        padding: 0 4px;
    }
    
    /* Reduce header padding */
    .game-header {
        padding: 8px !important;
        gap: 6px;
    }
    
    .game-container {
        padding: 4px !important;
        gap: 4px !important;
    }
    
    /* Make player panels more compact */
    .player-panel {
        padding: 8px !important;
        gap: 6px !important;
    }
    
    .mana-orb {
        width: 16px !important;
        height: 16px !important;
    }
    
    .deck-icon {
        width: 24px !important;
        height: 30px !important;
    }
    
    /* Adjust action bar */
    .action-bar {
        padding: 0 4px;
        gap: 4px;
    }
    
    .action-btn {
        padding: 8px 10px !important;
        font-size: 0.7rem !important;
        min-width: 70px;
    }
    
    /* Hide grid labels on very small screens to save space */
    .board-labels-top,
    .board-labels-left {
        display: none;
    }
    
    .board-center-section {
        gap: 2px;
    }
    
    .board-labels-top {
        grid-template-columns: 0 repeat(8, var(--tile-size));
    }
    
    .board-labels-left {
        width: 0;
    }
}

/* iPhone notch / Dynamic Island safe area */
@supports (padding: env(safe-area-inset-bottom)) {
    .game-container {
        padding-bottom: calc(4px + env(safe-area-inset-bottom)) !important;
    }
    
    #btn-end-turn {
        bottom: calc(24px + env(safe-area-inset-bottom)) !important;
    }
    
    .modal-overlay {
        padding-bottom: env(safe-area-inset-bottom) !important;
    }
}

/* Landscape mobile optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    .game-container {
        flex-direction: row;
        flex-wrap: wrap;
        align-content: flex-start;
    }
    
    .game-header {
        width: 100%;
        order: 1;
        padding: 4px 8px !important;
    }
    
    .game-title {
        font-size: 0.9rem !important;
    }
    
    .player-panel {
        width: 120px !important;
        order: 2;
        flex-direction: column;
        gap: 4px;
        padding: 6px !important;
    }
    
    .board-wrapper {
        order: 3;
        flex: 1;
        min-width: 0;
    }
    
    .hand-section {
        width: 100%;
        order: 4;
        max-height: 80px;
    }
    
    .hand {
        min-height: 60px;
        max-height: 70px;
    }
    
    #btn-end-turn {
        position: fixed;
        bottom: 8px;
        right: 8px;
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
        min-width: 80px;
    }
}

/* Mobile sandbox panel */
@media (max-width: 500px) {
    #sandbox-panel {
        position: fixed !important;
        left: 10px !important;
        right: 10px !important;
        top: auto !important;
        bottom: 10px !important;
        width: auto !important;
        max-height: 40vh !important;
        z-index: 200 !important;
    }
    
    #sandbox-panel .modal-title {
        font-size: 1rem !important;
    }
    
    #minion-list {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
    }
    
    #minion-list .action-btn {
        min-height: 50px !important;
        padding: 6px !important;
    }
    
    #minion-list img {
        width: 24px !important;
        height: 24px !important;
    }
    
    #minion-list div:last-child {
        font-size: 0.5rem !important;
    }
}

/* Prevent pull-to-refresh on mobile */
html, body {
    overscroll-behavior: none;
    touch-action: manipulation;
}

/* Improve touch scrolling */
.hand {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.hand::-webkit-scrollbar {
    display: none;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .tile:hover { filter: none; transform: none; }
    .tile:active { filter: brightness(1.2); transform: scale(0.98); }
    .minion:hover { transform: none; }
    .minion:active { transform: scale(1.05); }
    .action-btn:hover { background: inherit; }
    .action-btn:active { transform: scale(0.95); }
    .card:hover { border-color: var(--border); }
    .card:active { border-color: var(--mana-color); transform: scale(0.95); }
}
