:root {
    --bg-color: #1a1a2e;
    --board-bg: #2d6a4f;
    --text-color: #f1faee;
    --border-color: #f1faee;
    --card-bg: #ffffff;
    --card-back: #0077b6;
    --accent-red: #e63946;
    --accent-black: #1d3557;
    --pixel-border: 4px solid var(--border-color);
    --gold: #ffd700;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    touch-action: manipulation;
}

body {
    font-family: 'Press Start 2P', monospace;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    width: 100%;
    max-width: 1024px;
    height: 100%;
    max-height: 768px;
    position: relative;
    background-color: var(--board-bg);
    border: var(--pixel-border);
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    overflow: hidden;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background-color: rgba(26, 26, 46, 0.95);
    z-index: 10;
    overflow-y: auto;
    padding: 15px;
}

.screen.active {
    display: flex;
}

.screen-content {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 480px;
    padding: 10px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    width: 100%;
    max-width: 340px;
}

.btn-menu-item {
    width: 100% !important;
    margin: 0 !important;
    padding: 10px 18px !important;
    font-size: 0.85rem !important;
}

#screen-game {
    background-color: transparent;
    justify-content: flex-start;
    z-index: 1;
    overflow-y: hidden;
    padding: 0;
}

h1 {
    font-size: 2.6rem;
    color: var(--gold);
    text-shadow: 4px 4px 0 #000;
    margin-bottom: 0.8rem;
}

h2 {
    font-size: 1.8rem;
    color: var(--gold);
    margin-bottom: 1.5rem;
    text-shadow: 2px 2px 0 #000;
}

p {
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

@media (max-height: 700px) {
    h1 {
        font-size: 2rem;
        margin-bottom: 0.4rem;
    }
    h2 {
        font-size: 1.5rem;
        margin-bottom: 0.8rem;
    }
    p {
        font-size: 0.85rem;
        margin-bottom: 0.8rem;
    }
    .stats-bar {
        margin-bottom: 0.8rem;
        font-size: 1rem;
    }
    .btn-menu-item {
        padding: 8px 14px !important;
        font-size: 0.75rem !important;
    }
}

/* Buttons */
.pixel-btn {
    font-family: 'Press Start 2P', monospace;
    background-color: #457b9d;
    color: white;
    border: 4px solid white;
    padding: 15px 30px;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 4px 4px 0 #000;
    transition: transform 0.1s;
    margin: 10px;
}

.pixel-btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #000;
}

.pixel-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pixel-btn:hover {
    background-color: #1d3557;
}

.settings-panel {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 8px 0 12px;
    font-size: 0.65rem;
    color: var(--gold);
}
.settings-panel label {
    display: flex;
    align-items: center;
    gap: 6px;
}
.settings-panel select {
    width: auto;
    padding: 6px;
    color: white;
    background: #1a1a2e;
    border: 2px solid var(--border-color);
    font-family: inherit;
    font-size: 0.65rem;
}

.pixel-btn.small {
    padding: 10px 15px;
    font-size: 0.8rem;
    border-width: 3px;
}

/* HUD */
.hud {
    width: 100%;
    height: auto;
    min-height: 60px;
    background-color: #1a1a2e;
    border-bottom: var(--pixel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 15px;
    overflow: visible;
    position: relative;
    z-index: 100;
}

.hud-stats {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--gold);
    white-space: nowrap;
}
.hud-stats span {
    margin-right: 10px;
    font-size: 0.85rem;
    color: var(--gold);
}
.hud-relics {
    display: flex;
    gap: 8px;
}
.hud-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 auto;
}
.hud-actions .pixel-btn {
    margin: 0;
    padding: 6px 10px;
    font-size: 0.65rem;
    box-shadow: 2px 2px 0 #000;
    border-width: 2px;
}

.relic-icon {
    width: 30px;
    height: 30px;
    background-color: #fff;
    border: 2px solid #000;
    display: inline-block;
}

/* Board */
.board {
    width: 100%;
    height: auto;
    flex: 1;
    min-height: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.top-row {
    display: flex;
    justify-content: space-between;
    height: 140px;
}

.pile-group {
    display: flex;
    gap: 20px;
}

.bottom-row {
    display: flex;
    justify-content: space-between;
    flex: 1;
}

/* Piles and Cards */
.pile {
    width: 90px;
    height: 130px;
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    position: relative;
}

.tableau-col {
    border: none;
}

.card {
    width: 90px;
    height: 130px;
    background-color: var(--card-bg);
    border: 2px solid #000;
    border-radius: 4px;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3px 4px;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.5);
    cursor: pointer;
    pointer-events: auto;
    font-family: 'Press Start 2P', monospace;
    font-weight: bold;
    font-size: 0.8rem;
    overflow: hidden;
    box-sizing: border-box;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><rect width="10" height="10" fill="white"/><rect width="5" height="5" fill="%23f0f0f0"/><rect x="5" y="5" width="5" height="5" fill="%23f0f0f0"/></svg>');
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s, outline 0.2s;
    will-change: transform;
    touch-action: none;
}

.card:active {
    cursor: grabbing;
}

.card.face-down {
    background-color: var(--card-back);
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,0.1) 10px, rgba(0,0,0,0.1) 20px);
    color: transparent;
}

.card.face-down * {
    display: none;
}

.card.red {
    color: var(--accent-red);
}

.card.black {
    color: var(--accent-black);
}

.card .top-left {
    align-self: flex-start;
    font-size: 1rem;
    line-height: 0.95;
    text-align: center;
    pointer-events: none;
}

.card .center {
    align-self: center;
    font-size: 1.6rem;
    line-height: 1;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.card .bottom-right {
    align-self: flex-end;
    font-size: 1rem;
    line-height: 0.95;
    text-align: center;
    transform: rotate(180deg);
    pointer-events: none;
}

.card.selected {
    outline: 3px solid var(--gold);
    z-index: 100;
}

/* Tienda & Meta-Mejoras */
.stats-bar {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
}

.category-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 95%;
}

.tab-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    padding: 8px 12px;
    background-color: #1a1a2e;
    color: #fff;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
}

.tab-btn:hover {
    background-color: #457b9d;
}

.tab-btn.active {
    background-color: var(--gold);
    color: #000;
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Scroll Panel y Grid Generales de Menú (Tiendas, Cosméticos, Logros) */
.menu-scroll-panel {
    width: 95%;
    max-width: 800px;
    max-height: 56vh;
    overflow-y: auto;
    padding: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    width: 100%;
    margin-bottom: 10px;
}

.relics-container {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

#upgrades-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    max-height: 52vh;
    overflow-y: auto;
    width: 95%;
    max-width: 850px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    margin-bottom: 10px;
}

.upgrade-card {
    background: #1e293b;
    border: 2px solid #334155;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: left;
    transition: transform 0.2s, border-color 0.2s;
}

.upgrade-card:hover {
    transform: translateY(-2px);
    border-color: var(--gold);
}

.upgrade-card.owned {
    border-color: #22c55e;
    background: #0f172a;
}

.upgrade-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.upgrade-icon {
    font-size: 1.4rem;
}

.upgrade-title {
    font-size: 0.75rem;
    color: #fff;
    font-weight: bold;
    flex: 1;
}

.upgrade-card.owned .upgrade-title {
    color: #4ade80;
}

.upgrade-desc {
    font-size: 0.65rem;
    color: #cbd5e1;
    margin-bottom: 12px;
    line-height: 1.4;
}

.upgrade-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.upgrade-cost {
    font-size: 0.7rem;
    color: #f472b6;
    font-weight: bold;
}

.upgrade-card.owned .upgrade-cost {
    color: #4ade80;
}

.upgrade-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    padding: 6px 10px;
    background: #e11d48;
    color: #fff;
    border: 2px solid #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.upgrade-btn:hover:not(:disabled) {
    background: #be123c;
}

.upgrade-btn:disabled {
    background: #475569;
    border-color: #64748b;
    color: #94a3b8;
    cursor: not-allowed;
}

.pile.stock.has-peek::after {
    content: "Próx: " attr(data-peek);
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--gold);
    background: rgba(0, 0, 0, 0.85);
    padding: 2px 4px;
    border: 1px solid var(--gold);
    border-radius: 3px;
    white-space: nowrap;
    z-index: 1000;
}

.card.face-down-xray {
    opacity: 0.75;
    border-style: dashed;
}
.card.face-down-xray::before {
    content: "👁️";
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
}

.relic-item {
    width: 100%;
    max-width: 240px;
    background: #2d6a4f;
    border: 4px solid var(--gold);
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.relic-item:hover {
    background: #40916c;
}
.relic-item h3 {
    font-size: 1rem;
    color: #fff;
    margin-bottom: 5px;
}
.relic-item p {
    font-size: 0.7rem;
    margin: 0;
}
.relic-price {
    color: var(--gold);
    font-weight: bold;
}

/* User & Login */
.pixel-input {
    font-family: 'Press Start 2P', monospace;
    padding: 15px;
    font-size: 1rem;
    border: 4px solid var(--border-color);
    background: #000;
    color: var(--gold);
    outline: none;
    width: 250px;
}
.user-item {
    padding: 10px;
    border: 2px dashed var(--gold);
    cursor: pointer;
    background: #1a1a2e;
    transition: background 0.2s;
}
.user-item:hover {
    background: #457b9d;
}

/* Game Juice */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px) rotate(-5deg); }
    50% { transform: translateX(5px) rotate(5deg); }
    75% { transform: translateX(-5px) rotate(-5deg); }
    100% { transform: translateX(0); }
}
.shake {
    animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes hint-pulse {
    0% { outline: 4px solid #fca311; box-shadow: 0 0 10px #fca311; }
    50% { outline: 6px solid #fca311; box-shadow: 0 0 20px #fca311; }
    100% { outline: 4px solid #fca311; box-shadow: 0 0 10px #fca311; }
}
.hint-highlight {
    animation: hint-pulse 1s infinite;
    z-index: 999 !important;
}

/* Cursed Cards */
.card.cursed {
    background-color: #3a0ca3;
    border-color: #f72585;
    color: #f72585;
    background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5) 5px, rgba(247,37,133,0.2) 5px, rgba(247,37,133,0.2) 10px);
}
.card.cursed .center {
    color: #f72585;
}
.card.cursed::after {
    content: "MALDITA";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 0.6rem;
    color: #fff;
    background: #f72585;
    padding: 2px;
    border: 1px solid #fff;
}

/* Temas Dinámicos */
#game-container.theme-classic {
    --board-bg: #2d6a4f;
    --card-back: #0077b6;
}

#game-container.theme-synthwave {
    --board-bg: #16003b;
    --border-color: #ff007f;
    --card-back: #7209b7;
    --gold: #00f5d4;
    --accent-red: #ff007f;
    --accent-black: #4cc9f0;
}

#game-container.theme-dungeon {
    --board-bg: #0f0f1b;
    --border-color: #8b0000;
    --card-back: #3a0007;
    --gold: #ffb703;
    --accent-red: #d90429;
    --accent-black: #adb5bd;
}

/* Boss Modifiers */
.card.frozen {
    border-color: #4cc9f0 !important;
    box-shadow: 0 0 10px #4cc9f0;
}
.card.frozen::after {
    content: "❄️ HIELO";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.65rem;
    color: #00f5d4;
    background: rgba(0, 0, 0, 0.85);
    padding: 3px 5px;
    border: 1px solid #4cc9f0;
    border-radius: 3px;
    z-index: 10;
}

.card.fogged {
    filter: blur(4px) grayscale(80%);
    opacity: 0.5;
}

/* Dragging state */
.card.dragging {
    transition: none !important;
    z-index: 9999 !important;
    opacity: 0.92;
    box-shadow: 4px 8px 16px rgba(0,0,0,0.6) !important;
    pointer-events: none !important;
}

/* Consumables HUD */
.consumable-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    padding: 6px 10px;
    background-color: #3a0ca3;
    color: #fff;
    border: 2px solid var(--gold);
    cursor: pointer;
    box-shadow: 2px 2px 0 #000;
    transition: transform 0.1s, background-color 0.2s;
}
.consumable-btn:hover {
    background-color: #4361ee;
}
.consumable-btn:active {
    transform: translate(2px, 2px);
}
.consumable-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Tooltip de Reliquias */
.relic-badge {
    width: 32px;
    height: 32px;
    background: #1a1a2e;
    border: 2px solid var(--gold);
    color: var(--gold);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    position: relative;
    cursor: help;
}
.relic-badge:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 38px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    border: 2px solid white;
    color: #fff;
    padding: 6px;
    font-size: 0.6rem;
    white-space: nowrap;
    z-index: 99999;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.8);
}

/* Item de Logros */
.achievement-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1a1a2e;
    border: 2px solid var(--border-color);
    padding: 10px;
    width: 100%;
    text-align: left;
}
.achievement-item.unlocked {
    border-color: var(--gold);
    background: #2d6a4f;
}

/* Floating Popups UX */
@keyframes float-up {
    0% { transform: translate(-50%, 0) scale(0.8); opacity: 1; }
    50% { transform: translate(-50%, -25px) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -55px) scale(1); opacity: 0; }
}

.floating-text {
    position: absolute;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--gold);
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    z-index: 9999;
    animation: float-up 0.9s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.upgrade-req {
    font-size: 0.6rem;
    color: #ef4444;
    font-weight: bold;
    margin-top: 4px;
}

/* Particles */
.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--gold);
    border: 1px solid #fff;
    border-radius: 50%;
    pointer-events: none;
}

/* --- RogueTaire v4.0 Estilos Adicionales --- */

/* Mapa de Nodos */
.map-node {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #1a1a2e;
    border: 3px solid #6c757d;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    z-index: 5;
}

.map-node.node-available {
    border-color: var(--gold);
    box-shadow: 0 0 15px var(--gold);
    animation: pulse-node 1.5s infinite;
}

.map-node.node-visited {
    border-color: #2a9d8f;
    background: #2a9d8f;
    opacity: 0.7;
    cursor: default;
}

.map-node.node-locked {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none !important;
    border-color: #495057;
}

.map-node.node-current {
    border-color: #4cc9f0 !important;
    box-shadow: 0 0 20px #4cc9f0 !important;
}

.map-node.node-boss {
    width: 60px;
    height: 60px;
    border-color: #f72585;
    background: #7209b7;
    font-size: 1.6rem;
}

@keyframes pulse-node {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.12); box-shadow: 0 0 20px var(--gold); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

/* Cartas Elementales */
.card.element-crystal {
    border: 3px solid #4cc9f0 !important;
    box-shadow: 0 0 10px #4cc9f0;
}
.card.element-crystal::after {
    content: "💎";
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.65rem;
}

.card.element-volcanic {
    border: 3px solid #f72585 !important;
    box-shadow: 0 0 12px #f72585;
}
.card.element-volcanic::after {
    content: attr(data-volcanic-turns);
    position: absolute;
    top: 2px;
    right: 2px;
    background: #f72585;
    color: white;
    font-size: 0.55rem;
    padding: 1px 3px;
    border-radius: 3px;
}

.card.element-frozen {
    border: 3px solid #90e0ef !important;
    background-color: #e0f7fa !important;
    box-shadow: 0 0 8px #90e0ef;
}
.card.element-frozen::after {
    content: "🧊" attr(data-freeze-count);
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
}

/* Dorsos de Cartas Personalizables */
.card.face-down.back-classic {
    background-color: #0077b6;
    background-image: repeating-linear-gradient(45deg, #023e8a 0, #023e8a 10px, #0077b6 10px, #0077b6 20px);
}

.card.face-down.back-gold {
    background-color: #d4af37;
    background-image: radial-gradient(#fff 15%, transparent 16%), radial-gradient(#fff 15%, transparent 16%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
    border-color: #ffd700;
}

.card.face-down.back-cyberpunk {
    background-color: #111;
    background-image: linear-gradient(0deg, transparent 24%, rgba(247, 37, 133, .8) 25%, rgba(247, 37, 133, .8) 26%, transparent 27%, transparent 74%, rgba(247, 37, 133, .8) 75%, rgba(247, 37, 133, .8) 76%, transparent 77%), linear-gradient(90deg, transparent 24%, rgba(76, 201, 240, .8) 25%, rgba(76, 201, 240, .8) 26%, transparent 27%, transparent 74%, rgba(76, 201, 240, .8) 75%, rgba(76, 201, 240, .8) 76%, transparent 77%);
    background-size: 20px 20px;
    border-color: #f72585;
}

.card.face-down.back-dragon {
    background-color: #581845;
    background-image: repeating-radial-gradient(circle at 0 0, transparent 0, #900c3f 10px), repeating-linear-gradient(#c70039, #581845);
    border-color: #ff5733;
}

.card.face-down.back-holo {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #a1c4fd 100%);
    border-color: #ffffff;
    box-shadow: 0 0 8px rgba(255,255,255,0.8);
}

/* Árbol de Habilidades Gráfico */
.tree-node {
    position: absolute;
    width: 38px;
    height: 38px;
    border-radius: 6px;
    background: #1a1a2e;
    border: 2px solid #555;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: transform 0.15s, border-color 0.2s;
    z-index: 2;
}

.tree-node.node-purchased {
    border-color: var(--gold);
    background: #2a9d8f;
    box-shadow: 0 0 10px var(--gold);
}

.tree-node.node-affordable {
    border-color: #4cc9f0;
    animation: pulse-node 1.5s infinite;
}

.tree-node:hover {
    transform: translate(-50%, -50%) scale(1.15);
}

/* Controles Globales (Mute, Music, Fullscreen) */
#global-top-controls {
    transition: opacity 0.2s ease;
}

#global-top-controls button {
    margin: 0;
    padding: 6px 10px !important;
    box-shadow: 2px 2px 0 #000;
    font-size: 0.65rem;
}

#global-top-controls button:hover {
    transform: translateY(-2px);
    filter: brightness(1.15);
}

@media (max-width: 960px) {
    #game-container {
        border-width: 2px;
    }
    .board {
        padding: 10px;
        gap: 12px;
    }
    .top-row {
        height: 112px;
    }
    .pile-group {
        gap: 8px;
    }
    .pile, .card {
        width: 72px;
        height: 104px;
        padding: 2px 3px;
    }
    .card .center {
        font-size: 1.3rem;
    }
    .card .top-left, .card .bottom-right {
        font-size: 0.6rem;
        line-height: 0.9;
    }
    .hud {
        min-height: 52px;
        padding: 0 10px;
    }
    .hud-stats {
        font-size: 0.85rem;
        gap: 10px;
    }
    #global-top-controls {
        top: 5px;
        right: 5px;
        gap: 4px;
    }
    #global-top-controls button {
        padding: 5px 8px !important;
        font-size: 0.6rem !important;
    }
}

@media (max-width: 640px) {
    .hud {
        height: auto;
        min-height: 52px;
        padding: 4px 8px;
        flex-wrap: wrap;
        gap: 4px;
    }
    .board {
        padding: 5px;
        gap: 8px;
    }
    .top-row {
        height: 86px;
    }
    .pile-group {
        gap: 4px;
    }
    .pile, .card {
        width: 54px;
        height: 78px;
        border-width: 1px;
        padding: 1px 2px;
    }
    .card .center {
        font-size: 0.95rem;
    }
    .card .top-left, .card .bottom-right {
        font-size: 0.62rem;
        line-height: 0.85;
    }
    .hud-stats {
        font-size: 0.75rem;
    }
    .hud-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 3px;
        flex-basis: 100%;
    }
    .hud-actions .pixel-btn {
        padding: 4px 6px;
        font-size: 0.55rem;
    }
    .board {
        overflow-x: auto;
    }
    .bottom-row {
        justify-content: flex-start;
        gap: 8px;
        min-width: max-content;
    }
    .bottom-row .pile {
        flex: 0 0 54px;
    }
}
