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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

#game-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
header {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2em;
    color: #667eea;
}

#lang-switch-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

#game-info {
    display: flex;
    gap: 30px;
    font-weight: bold;
    color: #666;
}

/* Main Layout */
main {
    display: grid;
    grid-template-columns: 1fr 150px 380px;
    gap: 20px;
    margin-bottom: 20px;
}

/* Dice Panel */
#dice-panel {
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Panel Styles */
.panel {
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.panel h2 {
    font-size: 1.2em;
    color: #667eea;
    margin-bottom: 12px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapse-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
    line-height: 1;
}

.collapse-btn:hover {
    background: #764ba2;
    transform: scale(1.1);
}

.panel-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.panel.collapsed .panel-content {
    max-height: 0;
    opacity: 0;
}

.panel.collapsed .collapse-btn {
    background: #999;
}

.panel h3 {
    font-size: 1em;
    color: #764ba2;
    margin-top: 12px;
    margin-bottom: 8px;
}

/* Board Section */
#board-section {
    min-height: 500px;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 4px;
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
    aspect-ratio: 1;
    max-width: 700px;
    max-height: 700px;
}

.tile {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.75em;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.tile:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.tile.shop { border-color: #f39c12; background: #fef5e7; }
.tile.combat { border-color: #e74c3c; background: #fadbd8; }
.tile.treasure { border-color: #3498db; background: #d6eaf8; }
.tile.skillTrainer { border-color: #9b59b6; background: #ebdef0; }
.tile.empty { border-color: #95a5a6; background: #f2f3f4; }

.tile-number {
    position: absolute;
    top: 1px;
    left: 2px;
    font-size: 0.5em;
    color: #999;
    font-weight: bold;
}

.tile-emoji {
    font-size: 1.5em;
}

.player-marker {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
    animation: bounce 0.5s ease-in-out;
    z-index: 10;
}

.tile.active {
    background: linear-gradient(135deg, #ffd700, #ffec80) !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
}

.tile.active .tile-emoji {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.8em;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Center Action Panel */
#board-center {
    pointer-events: auto;
    z-index: 5;
}

#center-dice {
    transition: transform 0.1s ease-out;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.tile.active {
    border-width: 3px;
    border-color: #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}

/* Right Panel */
#right-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    padding-right: 5px;
}

/* Scrollbar styling for right panel */
#right-panel::-webkit-scrollbar {
    width: 8px;
}

#right-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#right-panel::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

#right-panel::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Player Stats */
#player-stats {
    flex-shrink: 0;
}

/* Inventory Panel */
#inventory-panel {
    flex-shrink: 0;
}

#inventory-panel h2 {
    font-size: 1.1em;
}

/* Skills Panel */
#skills-panel {
    flex-shrink: 0;
}

#skills-panel h2 {
    font-size: 1.1em;
}

#skills-panel h3 {
    font-size: 0.95em;
    margin-top: 10px;
    margin-bottom: 8px;
}

.stat-bars {
    margin-bottom: 15px;
}

.stat-row {
    margin-bottom: 10px;
}

.stat-row span:first-child {
    display: inline-block;
    width: 30px;
    font-weight: bold;
}

.bar-container {
    display: inline-block;
    width: calc(100% - 40px);
    height: 25px;
    background: #ecf0f1;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.bar {
    height: 100%;
    border-radius: 12px;
    transition: width 0.3s ease;
}

.hp-bar { background: linear-gradient(90deg, #e74c3c, #c0392b); }
.sp-bar { background: linear-gradient(90deg, #3498db, #2980b9); }

.bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85em;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-item {
    background: #f8f9fa;
    padding: 8px;
    border-radius: 5px;
    font-weight: bold;
}

.stat-item span {
    color: #667eea;
}

/* Action Panel */
#action-panel {
    flex-grow: 1;
    display: none; /* Hidden - using center panel instead */
    flex-direction: column;
}

.action-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.2em;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    margin-bottom: 15px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#dice-result {
    text-align: center;
    font-size: 3em;
    margin-bottom: 15px;
    min-height: 60px;
}

#event-log {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    flex-grow: 1;
    overflow-y: auto;
    max-height: 200px;
    font-size: 0.9em;
}

#event-log p {
    margin-bottom: 8px;
    padding: 5px;
    border-left: 3px solid #667eea;
    padding-left: 10px;
}

/* Bottom Panel - Not used, panels moved to right sidebar */
#bottom-panel {
    display: none;
}

/* Inventory */
#equipped-items {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
}

.equipped-slot {
    flex: 1;
    text-align: center;
}

.equipped-slot span {
    display: block;
    font-size: 0.75em;
    color: #666;
    margin-bottom: 3px;
}

.item-slot {
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 6px;
    padding: 6px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
}

.item {
    background: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    font-size: 1.3em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.item:hover {
    transform: scale(1.1);
    border-color: #667eea;
}

.item.weapon { border-color: #e74c3c; }
.item.armor { border-color: #3498db; }
.item.potion { border-color: #2ecc71; }
.item.ring { border-color: #f39c12; }

/* Skills */
.skills-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skill-item {
    background: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.skill-item:hover {
    border-color: #667eea;
    transform: translateX(5px);
}

.skill-emoji {
    font-size: 1.3em;
}

.skill-info {
    flex-grow: 1;
}

.skill-name {
    font-weight: bold;
    color: #333;
    font-size: 0.9em;
}

.skill-desc {
    font-size: 0.75em;
    color: #666;
}

.empty-text {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 10px;
    font-size: 0.85em;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

/* Combat modal full width */
.modal-content.combat-modal {
    width: 100%;
    max-width: 95vw;
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.modal-btn.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.modal-btn.secondary {
    background: #ecf0f1;
    color: #333;
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Combat Arena Styles */
.combat-arena {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    min-height: 300px;
    background: linear-gradient(to bottom, #87ceeb 0%, #f0e68c 100%);
    border-radius: 10px;
    padding: 30px;
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}

.combat-arena::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: #8b7355;
    border-top: 3px solid #654321;
}

.combatant {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    position: relative;
}

.combatant-left {
    align-items: flex-start;
}

.combatant-right {
    align-items: flex-end;
}

.combatant-emoji {
    font-size: 6em;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.combatant-left .combatant-emoji {
    animation: idle-left 2s ease-in-out infinite;
}

.combatant-right .combatant-emoji {
    animation: idle-right 2s ease-in-out infinite;
}

.combatant.attacking-left .combatant-emoji {
    animation: attack-left 0.5s ease-out;
}

.combatant.attacking-right .combatant-emoji {
    animation: attack-right 0.5s ease-out;
}

.combatant.hurt .combatant-emoji {
    animation: hurt 0.5s ease-out;
}

.combatant-name {
    font-weight: bold;
    font-size: 1.2em;
    margin-bottom: 5px;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.combatant-hp-container {
    width: 200px;
    background: #333;
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.combatant-hp-bar {
    height: 20px;
    background: linear-gradient(90deg, #e74c3c, #c0392b);
    border-radius: 5px;
    transition: width 0.5s ease;
    position: relative;
}

.combatant-hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 0.9em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* Combat Animations */
@keyframes idle-left {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px) scale(1.02); }
}

@keyframes idle-right {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px) scale(1.02); }
}

@keyframes attack-left {
    0% { transform: translateX(0); }
    50% { transform: translateX(50px) scale(1.1); }
    100% { transform: translateX(0); }
}

@keyframes attack-right {
    0% { transform: translateX(0); }
    50% { transform: translateX(-50px) scale(1.1); }
    100% { transform: translateX(0); }
}

@keyframes hurt {
    0%, 100% { transform: translateX(0); filter: brightness(1); }
    25% { transform: translateX(-10px); filter: brightness(1.5); }
    50% { transform: translateX(10px); filter: brightness(1.5); }
    75% { transform: translateX(-5px); filter: brightness(1.5); }
}

/* Other Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

.shake {
    animation: shake 0.5s;
}

.pulse {
    animation: pulse 0.5s;
}

/* Responsive */
@media (max-width: 1200px) {
    main {
        grid-template-columns: 1fr 140px 320px;
    }

    #right-panel {
        gap: 10px;
    }
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }

    #dice-panel {
        flex-direction: row;
        justify-content: center;
        padding: 10px;
        gap: 15px;
    }
}

    #right-panel {
        max-height: none;
    }

    #game-board {
        max-width: 500px;
        max-height: 500px;
        margin: 0 auto;
    }

    .combat-arena {
        min-height: 250px;
        padding: 20px;
    }

    .combatant-emoji {
        font-size: 4em;
    }

    .combatant-hp-container {
        width: 150px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    #game-board {
        max-width: 100%;
        max-height: none;
        padding: 8px;
        gap: 2px;
    }

    .tile {
        font-size: 0.55em;
    }

    .tile-emoji {
        font-size: 2em;
    }

    .tile-number {
        font-size: 0.4em;
    }

    .player-marker {
        font-size: 2.5em;
    }

    /* Center panel mobile fixes */
    #board-center {
        padding: 8px !important;
    }

    #center-dice {
        font-size: 2em !important;
        margin-top: -5px !important;
    }

    #center-dice-number {
        font-size: 2em !important;
        min-height: 1em !important;
    }

    #center-roll-btn {
        padding: 10px !important;
        font-size: 0.9em !important;
        max-width: 150px !important;
        margin-bottom: 8px !important;
    }

    #center-event-log {
        padding: 6px !important;
        max-height: 80px !important;
        font-size: 0.7em !important;
    }

    .combat-arena {
        min-height: 220px !important;
        padding: 20px 10px !important;
        flex-direction: row !important;
        gap: 15px !important;
        justify-content: space-around !important;
        align-items: flex-end !important;
        width: 100% !important;
    }

    .combatant {
        flex: 1;
        max-width: 48%;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    .combatant-emoji {
        font-size: 5em !important;
        margin-bottom: 10px !important;
    }

    .combatant-name {
        font-size: 1.1em !important;
        margin-bottom: 8px !important;
    }

    .combatant-hp-container {
        width: 100% !important;
        max-width: 140px !important;
        padding: 4px !important;
    }

    .combatant-hp-bar {
        height: 22px !important;
    }

    .combatant-hp-text {
        font-size: 0.85em !important;
    }

    .modal-content {
        max-width: 100%;
        width: calc(100% - 16px);
        margin: 8px;
        padding: 12px;
        border-radius: 10px;
    }

    header {
        padding: 12px;
    }

    header h1 {
        font-size: 1.3em;
    }

    #game-info {
        flex-wrap: wrap;
        gap: 10px;
        font-size: 0.85em;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    #game-board {
        padding: 4px;
        gap: 1px;
    }

    .tile {
        font-size: 0.45em;
        border-width: 1px;
        border-radius: 3px;
    }

    .tile-emoji {
        font-size: 1.8em;
    }

    .player-marker {
        font-size: 2.2em;
    }

    .tile-number {
        display: none;
    }

    #center-dice {
        font-size: 1.5em !important;
    }

    #center-dice-number {
        font-size: 1.5em !important;
    }

    #center-roll-btn {
        padding: 8px !important;
        font-size: 0.8em !important;
        max-width: 120px !important;
    }

    #center-event-log {
        max-height: 60px !important;
        font-size: 0.65em !important;
    }

    .panel {
        padding: 10px;
    }

    .panel h2 {
        font-size: 1em;
    }
}

/* Item Buffs Display */
.item-buffs {
    font-size: 0.8em;
    color: #666;
    margin-top: 3px;
}
