:root {
    --bg-dark: #0f0a1a;
    --bg-medium: #1a1030;
    --bg-light: #2a1f45;
    --bg-panel: #1e1535;
    --border: #3d2e6b;
    --border-light: #5a42a0;
    --text-primary: #f5f0ff;
    --text-secondary: #c4b3e6;
    --text-dim: #8a79b0;
    --gold: #ffd700;
    --gold-dark: #b8960f;
    --hp-red: #ff3344;
    --hp-red-dark: #aa1122;
    --energy-blue: #44aaff;
    --energy-blue-dark: #2266aa;
    --player-blue: #5599ff;
    --player-blue-light: #88ccff;
    --goblin-green: #44cc44;
    --archer-orange: #ee8833;
    --slime-purple: #aa44dd;
    --necro-dark: #7722aa;
    --shadow-gray: #555566;
    --boss-red: #ff4466;
    --lava-red: #ff4400;
    --lava-orange: #ff8800;
    --water-blue: #2266cc;
    --water-light: #4488ee;
    --portal-purple: #cc44ff;
    --stone-gray: #555566;
    --destructible-brown: #886644;
    --tile-base: #1a1525;
    --tile-border: #2a2040;
    --tile-hover: rgba(255, 255, 255, 0.1);
    --tile-attack: rgba(255, 68, 68, 0.3);
    --font-pixel: 'Press Start 2P', monospace;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-pixel);
    -webkit-overflow-scrolling: none;
    touch-action: none;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
}

.screen.overlay {
    background: rgba(10, 5, 20, 0.92);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

/* TITLE SCREEN */
#title-screen {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, var(--bg-dark) 0%, #1a0a2e 50%, var(--bg-dark) 100%);
}

.title-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.game-title {
    font-size: 3.5rem;
    color: var(--gold);
    text-shadow: 3px 3px 0 var(--gold-dark), 6px 6px 0 rgba(0,0,0,0.5);
    line-height: 1.4;
    margin-bottom: 1rem;
    animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    letter-spacing: 2px;
}

#class-screen {
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    background: linear-gradient(180deg, var(--bg-dark) 0%, #1a0a2e 50%, var(--bg-dark) 100%);
    padding: 1.5rem 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.class-content {
    text-align: center;
    width: 100%;
    max-width: 900px;
}

.class-title {
    font-size: 1.3rem;
    color: var(--gold);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    margin-bottom: 1.5rem;
    letter-spacing: 2px;
}

.class-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.class-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    padding: 1.2rem;
    width: 100%;
    max-width: 200px;
    height: 260px;
    cursor: pointer;
    transition: all 0.1s;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.class-card:hover {
    border-color: var(--gold);
    transform: translateY(-4px);
    box-shadow: 0 6px 0 rgba(0,0,0,0.3);
}

.class-card.selected {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
}

.class-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.class-name {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.3rem;
    letter-spacing: 1px;
}

.class-desc {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    line-height: 1.4;
}

.class-passive {
    font-size: 0.5rem;
    color: var(--gold);
    line-height: 1.3;
    padding: 0.3rem;
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.2);
    margin-bottom: 0.4rem;
}

.class-stats {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.stat-icon {
    font-size: 0.8rem;
}

.hp-icon {
    color: var(--hp-red);
}

.energy-icon {
    color: var(--energy-blue);
}

.class-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.class-card.disabled::after {
    content: 'SOON';
    display: block;
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
    letter-spacing: 2px;
}

.player-passive {
    font-size: clamp(0.5rem, 1.5vw, 0.65rem);
    color: var(--gold);
    padding: 0.3rem 0.4rem;
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.2);
    margin-bottom: 0.5rem;
    line-height: 1.4;
    cursor: help;
    width: 100%;
    box-sizing: border-box;
}

.pixel-btn {
    font-family: var(--font-pixel);
    font-size: 1rem;
    padding: 1.2rem 2.5rem;
    background: var(--gold);
    color: var(--bg-dark);
    border: none;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 0 4px 0 var(--gold-dark);
    position: relative;
    top: 0;
}

.pixel-btn:hover {
    background: #ffe44d;
    top: -2px;
    box-shadow: 0 6px 0 var(--gold-dark);
}

.pixel-btn:active {
    top: 4px;
    box-shadow: 0 0 0 var(--gold-dark);
}

.pixel-btn.small {
    font-size: 0.6rem;
    padding: 0.6rem 1.2rem;
    margin-top: 1rem;
}

.controls-hint {
    margin-top: 2rem;
    font-size: 0.6rem;
    color: var(--text-dim);
    line-height: 2.2;
}

/* TOP BAR */
#top-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 0.8rem;
    background: var(--bg-panel);
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
}

.top-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.top-stat .label {
    font-size: 0.55rem;
    color: var(--text-dim);
}

.top-stat .value {
    font-size: 0.9rem;
    color: var(--gold);
}

/* GAME AREA */
#game-screen {
    flex-direction: column;
}

#game-area {
    display: flex;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

#canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    padding: 1rem;
    overflow: hidden;
}

#game-canvas {
    background: var(--tile-base);
    border: 2px solid var(--border);
    image-rendering: pixelated;
    max-width: 100%;
    max-height: 100%;
}

.obstacle-tooltip {
    display: none;
    position: absolute;
    background: var(--bg-dark);
    color: var(--text-primary);
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--gold);
    font-size: 0.4rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.6);
    cursor: pointer;
}

/* SIDEBAR */
#sidebar {
    flex: 0 0 320px;
    width: 320px;
    min-width: 320px;
    max-width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.6rem;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-panel);
    border-left: 2px solid var(--border);
    height: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
}

.panel {
    background: var(--bg-medium);
    border: 1px solid var(--border);
    padding: 0.7rem;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    box-sizing: border-box;
    flex-shrink: 0;
}

.panel-title {
    font-size: 0.7rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

.panel-toggle {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-toggle::after {
    content: '\25BC';
    font-size: 0.5rem;
    transition: transform 0.15s;
}

.panel-toggle.collapsed::after {
    transform: rotate(-90deg);
}

.panel-content {
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.panel-content.collapsed {
    display: none;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
    font-size: 0.6rem;
}

.stat-label {
    width: 20px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    cursor: help;
}

.stat-bar-container {
    flex: 1;
    height: 18px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
}

.stat-bar {
    height: 100%;
    transition: width 0.3s;
}

.stat-bar-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    color: #fff;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.7);
    pointer-events: none;
    z-index: 1;
}

.hp-bar {
    background: linear-gradient(180deg, var(--hp-red), var(--hp-red-dark));
}

.energy-bar {
    background: linear-gradient(180deg, var(--energy-blue), var(--energy-blue-dark));
}

.stat-value {
    min-width: 50px;
    text-align: right;
    font-size: 0.6rem;
    color: var(--text-primary);
}

.empty-text {
    font-size: 0.55rem;
    color: var(--text-dim);
    font-style: italic;
}

.synergy-item {
    font-size: 0.6rem;
    color: var(--gold);
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
    cursor: help;
    position: relative;
    z-index: 1;
}

.synergy-item:hover {
    background: var(--bg-light);
}

.synergy-item::after {
    content: none;
}

.synergy-item:hover::after {
    content: none;
}

#game-tooltip {
    display: none;
}

.js-tooltip {
    position: fixed;
    background: var(--bg-dark);
    color: var(--text-primary);
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--gold);
    font-size: 0.5rem;
    white-space: pre-line;
    pointer-events: none;
    z-index: 99999;
    max-width: 300px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.6;
    text-align: left;
}

@media (hover: none) and (pointer: coarse) {
    .js-tooltip {
        position: fixed;
        left: 0 !important;
        right: 0;
        bottom: 0 !important;
        top: auto !important;
        max-width: 100%;
        width: 100%;
        border-radius: 8px 8px 0 0;
        border: 1px solid var(--gold);
        border-bottom: none;
        padding: 0.8rem 1rem;
        font-size: 0.5rem;
        text-align: center;
        pointer-events: auto;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
    }

    #controls-hint {
        display: none;
    }
}

.enemy-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
}

.item-entry {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0;
    cursor: help;
}

.item-icon {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 9px;
    color: #fff;
    text-shadow: 0 0 3px rgba(0,0,0,0.5);
}

.item-name {
    font-size: 0.5rem;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-stack {
    font-size: 0.4rem;
    color: var(--text-dim);
    min-width: 12px;
    text-align: right;
}

#items-list {
    max-height: 150px;
    overflow-y: auto;
}

.enemy-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

#enemy-list {
    max-height: 130px;
    overflow-y: auto;
    overflow-x: hidden;
}

.enemy-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.enemy-name {
    font-size: 0.55rem;
    color: var(--text-secondary);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.enemy-hp-bar {
    height: 7px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    margin-top: 2px;
    overflow: hidden;
}

.enemy-hp-fill {
    height: 100%;
    background: linear-gradient(180deg, var(--hp-red), var(--hp-red-dark));
    transition: width 0.3s;
}

.enemy-hp-text {
    font-size: 0.5rem;
    color: var(--text-dim);
}

#combat-log {
    height: 130px;
    min-height: 100px;
    max-height: 130px;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 0.5rem;
    line-height: 1.6;
    word-break: break-word;
    overflow-wrap: break-word;
    flex-shrink: 0;
}

#log-panel {
    flex: 0 0 auto;
    max-width: 100%;
}

.log-entry {
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.log-player { color: #5599ff; }
.log-enemy { color: #ee8833; }
.log-boss { color: #ff4466; }
.log-kill { color: #44cc44; }
.log-damage { color: #ff6644; }
.log-action { color: #ccddff; }
.log-telegraph { color: #ffff44; }
.log-dot { color: #aa44dd; }
.log-info { color: var(--text-dim); }

.death-stats {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    text-align: left;
}

.stat-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.5rem;
    padding: 0.3rem 0;
    color: var(--text-secondary);
}

.stat-line span:last-child {
    color: var(--gold);
}

.death-items-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.death-item-badge {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.5rem;
    background: var(--bg-light);
    border: 1px solid var(--border);
}

.death-item-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
    text-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.death-item-name {
    font-size: 0.4rem;
    color: var(--text-primary);
}

.death-item-stack {
    font-size: 0.35rem;
    color: var(--text-dim);
}

.item-badge {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.4rem;
    background: var(--bg-light);
    border: 1px solid var(--border);
    margin-bottom: 0.2rem;
}

.item-badge-icon {
    font-size: 0.6rem;
    flex-shrink: 0;
    text-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.item-badge-name {
    font-size: 0.35rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.stat-divider {
    border-top: 1px solid var(--border);
    margin: 0.5rem 0;
}

/* SKILL BAR */
#skill-bar {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem;
    background: var(--bg-panel);
    border-top: 2px solid var(--border);
    flex-shrink: 0;
}

.skill-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.6rem;
    background: var(--bg-medium);
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.1s;
    min-width: 90px;
    position: relative;
}

.skill-slot:hover {
    border-color: var(--border-light);
    background: var(--bg-light);
}

.skill-slot.active {
    border-color: var(--gold);
    background: var(--bg-light);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.skill-slot.empty {
    opacity: 0.4;
    cursor: default;
}

.skill-slot::after {
    content: none;
}

.skill-slot:hover::after {
    content: none;
}

.skill-key {
    font-size: 0.45rem;
    color: var(--text-dim);
}

.skill-icon {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
}

.slash-icon { background: linear-gradient(135deg, #fff 50%, var(--text-dim) 50%); }
.move-icon { 
    background: var(--energy-blue);
    color: var(--bg-dark);
    font-size: 0.5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
}
.empty-icon { background: var(--bg-dark); }
.guard-icon {
    background: linear-gradient(135deg, #446688, #6688aa);
    position: relative;
}
.guard-icon::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    border: 2px solid #aaccee;
    border-radius: 2px;
}

.skill-name {
    font-size: 0.45rem;
    color: var(--text-primary);
}

.skill-cost {
    font-size: 0.45rem;
    color: var(--energy-blue);
}

.end-turn-btn {
    font-size: 0.6rem;
    padding: 0.6rem 1.2rem;
    background: var(--bg-medium);
    color: var(--text-secondary);
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: none;
    position: static;
    top: auto;
    margin-left: 0.5rem;
}

.end-turn-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--bg-light);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
    top: auto;
}

.end-turn-btn:active {
    top: auto;
    box-shadow: none;
}

.key-hint {
    display: block;
    font-size: 0.4rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
}

#controls-hint {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.5rem;
    background: var(--bg-dark);
    border-top: 1px solid var(--border);
    font-size: 0.45rem;
    color: var(--text-dim);
    flex-shrink: 0;
}

/* MODALS */
.modal {
    background: var(--bg-medium);
    border: 3px solid var(--gold);
    padding: 2rem;
    text-align: center;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-title {
    font-size: 1.4rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.modal-subtitle {
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.choices-grid {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.skill-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: center;
}

.skill-actions .pixel-btn {
    flex: 1;
}

.pixel-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.choice-card {
    background: var(--bg-dark);
    border: 2px solid var(--border);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.choice-card:hover {
    border-color: var(--gold);
    background: var(--bg-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 0 var(--gold-dark);
}

.choice-card:active {
    transform: translateY(2px);
    box-shadow: none;
}

.item-rarity-boss {
    border-color: #ffaa00;
}

.item-rarity-boss:hover {
    border-color: #ffdd44;
    box-shadow: 0 4px 0 #cc8800;
}

/* Item Choice Cards - Larger with Icons */
.item-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    min-height: 80px;
}

.item-card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: #fff;
    border: 2px solid rgba(255,255,255,0.3);
    flex-shrink: 0;
    text-shadow: 0 0 6px rgba(0,0,0,0.6);
}

.item-card-info {
    flex: 1;
    min-width: 0;
}

.item-card-name {
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}

.item-card-desc {
    font-size: 0.5rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.3rem;
}

.item-card-rarity {
    font-size: 0.4rem;
    font-style: italic;
}

.choice-title {
    font-size: 0.7rem;
    color: var(--gold);
    margin-bottom: 0.3rem;
}

.choice-desc {
    font-size: 0.5rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.choice-stat {
    font-size: 0.45rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
}

.death-modal {
    border-color: var(--hp-red);
}

.death-title {
    color: var(--hp-red) !important;
    font-size: 2.5rem !important;
    margin-bottom: 1rem !important;
}

.death-stage, .death-turns {
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.boss-warning-content {
    text-align: center;
    animation: bossFlash 0.5s ease-in-out 3;
}

@keyframes bossFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.boss-warning-text {
    font-size: 2.5rem;
    color: var(--boss-red);
    text-shadow: 0 0 20px var(--boss-red);
    margin-bottom: 1rem;
}

.boss-name {
    font-size: 1.2rem;
    color: var(--gold);
}

@keyframes dialogueFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* RESPONSIVE */
@media (max-width: 1024px) {
    #sidebar {
        flex: 0 0 260px;
        width: 260px;
        min-width: 260px;
        max-width: 260px;
    }
    
    .skill-slot {
        min-width: 65px;
        padding: 0.4rem;
    }
    
    .game-title {
        font-size: 2rem;
    }
}

@media (min-width: 600px) {
    .class-grid {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    #game-area {
        flex-direction: column;
        overflow: hidden;
    }
    
    #sidebar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        flex: 0 0 auto;
        flex-direction: row;
        flex-wrap: wrap;
        border-left: none;
        border-top: 2px solid var(--border);
        max-height: 140px;
        overflow-x: hidden;
        overflow-y: auto;
        height: auto;
    }
    
    .panel {
        min-width: 0;
        flex: 1 1 auto;
    }
    
    #enemy-panel {
        display: none;
    }
    
    #skill-bar {
        flex-wrap: wrap;
        gap: 0.3rem;
        overflow: hidden;
    }
    
    .skill-slot {
        min-width: 60px;
        padding: 0.3rem;
    }
    
    .skill-name {
        display: none;
    }
    
    .end-turn-btn {
        font-size: 0.5rem;
        padding: 0.4rem 0.8rem;
    }
    
    .key-hint {
        display: none;
    }
}

#buff-bar {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-panel);
    border-top: 2px solid var(--border);
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    min-height: 36px;
}

.buff-icon {
    position: relative;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid var(--border);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.45rem;
    color: #fff;
    cursor: help;
    flex-shrink: 0;
    flex-grow: 0;
}

.buff-icon .buff-turns {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    font-size: 0.35rem;
    padding: 1px 2px;
    line-height: 1;
    color: var(--text-primary);
    font-family: 'Press Start 2P', monospace;
}

@media (max-width: 600px) {
    #controls-hint {
        display: none;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    #top-bar {
        gap: 1rem;
        padding: 0.5rem;
    }
    
    .top-stat .value {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.5rem;
    }
    
    .pixel-btn {
        font-size: 0.8rem;
        padding: 1rem 2rem;
    }
    
    .modal {
        padding: 1rem;
    }
    
    .modal-title {
        font-size: 1rem;
    }
}

.game-subtitle {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

.game-version {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.4rem;
    color: #555;
    margin-bottom: 2rem;
    letter-spacing: 1px;
}

.settings-modal {
    min-width: 320px;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
}

.settings-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    color: #ccc;
    min-width: 100px;
}

.settings-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #333;
    border-radius: 3px;
    outline: none;
}

.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #ff8800;
    border-radius: 50%;
    cursor: pointer;
}

.settings-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #ff8800;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.settings-value {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    color: #ff8800;
    min-width: 40px;
    text-align: right;
}

.settings-ingame-btn {
    position: fixed;
    top: 8px;
    right: 8px;
    z-index: 100;
    padding: 0.4rem 0.6rem;
    font-size: 1rem;
    background: var(--bg-panel);
    border: 2px solid var(--border);
    color: #ccc;
    cursor: pointer;
}

.settings-ingame-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
