/* General Styles */
:root {
    --vh: 1vh;
    --primary-color: #ff5722;
    --secondary-color: #ff9800;
    --tertiary-color: #ffc107;
    --dark-bg: #121212;
    --darker-bg: #0a0a0a;
    --card-bg: #2d2d2d;
    --element-bg: #424242;
    --element-hover: #616161;
    --text-color: #e0e0e0;
    --dim-text: #999;
    --health-color: #4caf50;
    --attack-color: #f44336;
    --defense-color: #2196f3;
    --special-color: #9c27b0;
    --corruption-color: #9c27b0;
    --elite-glow: #ff9800;
    --boss-color: #f44336;
    --scrollbar-thumb: #616161;
    --scrollbar-track: #2d2d2d;
    --card-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    --button-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --glow-shadow: 0 0 15px rgba(255, 87, 34, 0.6);
    --button-dim: #333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--dark-bg);
    color: var(--text-color);
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: background-color 1.5s ease;
    font-size: 16px;
    margin: 0;
}

#game-container {
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    max-width: 1024px;
    background-color: #1e1e1e;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transition: background-color 1.5s ease, box-shadow 1.5s ease;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: opacity 0.5s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.hidden {
    display: none !important;
}

.action-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    width: 100%;
    flex-wrap: wrap;
}

/* Scrollable elements */
.scrollable {
    max-height: 35vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

/* Scrollbar styling */
.scrollable::-webkit-scrollbar {
    width: 8px;
}

.scrollable::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 5px;
}

.scrollable::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
}

h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 30px;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(255, 87, 34, 0.6);
    text-align: center;
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 20px;
    color: var(--secondary-color);
    text-align: center;
}

h3 {
    font-size: clamp(1.2rem, 3.5vw, 1.5rem);
    margin-bottom: 10px;
    color: var(--tertiary-color);
}

h4 {
    font-size: clamp(1rem, 3vw, 1.2rem);
    margin-bottom: 5px;
    color: #ffeb3b;
}

p {
    margin-bottom: 10px;
    line-height: 1.5;
}

button {
    background-color: var(--element-bg);
    color: var(--text-color);
    border: none;
    padding: 12px 20px;
    margin: 5px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s;
    min-height: 44px;
    min-width: 44px;
    font-size: 1rem;
    box-shadow: var(--button-shadow);
}

button:hover:not([disabled]) {
    background-color: var(--element-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

button:active:not([disabled]) {
    transform: translateY(1px);
    box-shadow: var(--button-shadow);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--button-dim);
}

.label {
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--dim-text);
    margin-top: 2px;
}

/* Loading Screen */
#loading-screen {
    background-color: #000;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.loading-animation {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 87, 34, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 20px;
}

#loading-screen .quote {
    position: absolute;
    bottom: 40px;
    font-style: italic;
    color: #666;
    width: 80%;
    text-align: center;
}

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

/* Main Menu */
#main-menu {
    background-image: linear-gradient(to bottom, var(--darker-bg), #1a1a1a);
}

.menu-options {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 300px;
}

.menu-options button {
    margin: 8px 0;
    font-size: 1.2em;
    padding: 12px 20px;
}

.game-version {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 0.8em;
    color: #666;
}

/* Class Selection */
#class-selection {
    background-image: linear-gradient(to bottom, var(--darker-bg), #1a1a1a);
    overflow-y: auto;
}

.class-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 15px;
    margin-bottom: 20px;
}

.class-card {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.class-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.class-card.selected {
    border: 2px solid var(--primary-color);
    box-shadow: var(--glow-shadow);
}

.class-icon {
    width: 80px;
    height: 80px;
    margin: 10px auto;
    border-radius: 50%;
}

.survivor-icon {
    background-color: var(--health-color);
    position: relative;
}

.survivor-icon::before {
    content: "";
    position: absolute;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.8);
}

.shadow-walker-icon {
    background-color: var(--special-color);
    position: relative;
}

.shadow-walker-icon::before {
    content: "";
    position: absolute;
    top: 15px;
    left: 25px;
    width: 30px;
    height: 50px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50% 50% 0 0;
}

.decay-specialist-icon {
    background-color: #673ab7;
    position: relative;
}

.decay-specialist-icon::before {
    content: "";
    position: absolute;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    background: 
        linear-gradient(45deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 43%, #fff 45%, #fff 55%, rgba(0,0,0,0) 57%, rgba(0,0,0,0) 100%),
        linear-gradient(135deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 43%, #fff 45%, #fff 55%, rgba(0,0,0,0) 57%, rgba(0,0,0,0) 100%);
}

.class-stats {
    margin: 15px 0;
    text-align: left;
    padding: 0 10px;
}

.stat-high {
    color: var(--health-color);
}

.stat-med {
    color: var(--tertiary-color);
}

.stat-low {
    color: var(--attack-color);
}

.class-desc {
    font-size: 0.9em;
    text-align: left;
    padding: 0 10px;
    color: #ccc;
}

/* Difficulty Selection */
#difficulty-selection {
    background-image: linear-gradient(to bottom, var(--darker-bg), #1a1a1a);
    overflow-y: auto;
}

.difficulty-options {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 15px;
    margin-bottom: 20px;
}

.difficulty-card {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    text-align: center;
    box-shadow: var(--card-shadow);
}

.difficulty-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.difficulty-card.selected {
    border: 2px solid var(--primary-color);
    box-shadow: var(--glow-shadow);
}

.difficulty-rating {
    display: flex;
    justify-content: center;
    margin: 10px 0 15px;
}

.rating-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #444;
    margin: 0 3px;
}

.rating-dot.filled {
    background-color: var(--primary-color);
}

.difficulty-card p {
    text-align: left;
    font-size: 0.9em;
    margin: 5px 0;
    color: #ccc;
}

/* Game HUD */
.game-hud {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    gap: 10px;
}

.hud-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 10px;
}

.hud-middle {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 5px 0;
}

.hud-bottom {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.hud-stats {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 5px;
}

.health-container, .corruption-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 300px;
}

.health-bar, .corruption-bar {
    background-color: #333;
    height: 20px;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.health-bar div {
    background-color: var(--health-color);
    height: 100%;
    width: 100%;
    transition: width 0.3s;
}

.corruption-bar div {
    background-color: var(--corruption-color);
    height: 100%;
    width: 0%;
    transition: width 0.3s;
}

.health-bar span, .corruption-bar span {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    color: white;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}

.level-indicator {
    background-color: #333;
    padding: 8px 15px;
    border-radius: 5px;
    text-align: center;
}

.level-indicator .label {
    margin-bottom: 5px;
}

#current-level {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--secondary-color);
}

.mini-map {
    background-color: #333;
    width: 150px;
    height: 150px;
    border-radius: 5px;
    padding: 5px;
}

.map-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    width: 100%;
    height: 100%;
    gap: 2px;
}

.map-cell {
    background-color: #555;
    border-radius: 2px;
}

.map-cell.visited {
    background-color: #aaa;
}

.map-cell.current {
    background-color: var(--primary-color);
}

.player-stats {
    background-color: #333;
    padding: 8px;
    border-radius: 5px;
    font-size: 0.9em;
    display: flex;
    justify-content: space-around;
    width: 100%;
    max-width: 300px;
}

/* Level Indicator */
.boss-indicator {
    background-color: var(--boss-color);
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
    letter-spacing: 1px;
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.6);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 10px rgba(244, 67, 54, 0.6); }
    50% { box-shadow: 0 0 20px rgba(244, 67, 54, 0.8); }
    100% { box-shadow: 0 0 10px rgba(244, 67, 54, 0.6); }
}

/* Exploration */
#exploration {
    background-color: #1a1a1a;
    justify-content: space-between;
    padding-top: 10px;
}

.game-content {
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 20px;
    flex-grow: 1;
}

#room-description {
    background-color: rgba(45, 45, 45, 0.8);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 600px;
    box-shadow: var(--card-shadow);
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 500px;
}

.action-buttons button {
    flex-grow: 1;
    padding: 12px 15px;
    font-size: 1.1em;
    min-width: calc(50% - 20px);
}

#level-up-btn {
    background-color: var(--secondary-color);
    color: #212121;
    font-weight: bold;
    animation: pulse 1.5s infinite;
    width: 100%;
}

/* Combat Screen */
#combat, #boss-combat {
    background-color: #1a1a1a;
    background-image: radial-gradient(circle at center, #2d2d2d 0%, #1a1a1a 70%);
    justify-content: space-between;
    padding-top: 10px;
}

.enemy-container, .boss-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0;
    width: 100%;
}

#enemy-image, #boss-image {
    width: 150px;
    height: 150px;
    background-color: #333;
    border-radius: 8px;
    margin-bottom: 15px;
    transition: transform 0.3s;
}

.boss-info {
    text-align: center;
}

#boss-image {
    width: 180px;
    height: 180px;
}

.enemy-shadow-beast {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="150" height="150" viewBox="0 0 150 150"><rect width="150" height="150" fill="%23333"/><path d="M75,30 L100,60 L90,90 L60,90 L50,60 Z" fill="%23222"/><circle cx="65" cy="60" r="5" fill="%23f00"/><circle cx="85" cy="60" r="5" fill="%23f00"/></svg>');
    background-size: contain;
}

.enemy-boss {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200"><rect width="200" height="200" fill="%23333"/><path d="M100,20 L150,60 L160,100 L150,140 L100,180 L50,140 L40,100 L50,60 Z" fill="%23222"/><circle cx="70" cy="70" r="10" fill="%23f00"/><circle cx="130" cy="70" r="10" fill="%23f00"/><path d="M70,120 L130,120" stroke="%23f00" stroke-width="5"/></svg>');
    background-size: contain;
}

.enemy-health-container, #boss-health-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 250px;
}

#enemy-health-bar, #boss-health-bar {
    width: 100%;
    height: 15px;
    background-color: #333;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    margin-bottom: 10px;
}

#enemy-health-fill, #boss-health-fill {
    background-color: var(--attack-color);
    height: 100%;
    width: 100%;
    transition: width 0.3s;
}

#enemy-health-text, #boss-health-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    color: white;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}

#boss-description {
    text-align: center;
    margin-top: 10px;
    font-style: italic;
    max-width: 500px;
    color: #ccc;
}

.dice-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.dice {
    width: 60px;
    height: 60px;
    background-color: #e0e0e0;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    font-weight: bold;
    color: #333;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s;
    position: relative;
}

.dice.rolling {
    animation: roll 0.5s ease-in-out;
}

@keyframes roll {
    0% { transform: rotateZ(0deg) scale(1); }
    25% { transform: rotateZ(90deg) scale(1.2); }
    50% { transform: rotateZ(180deg) scale(1); }
    75% { transform: rotateZ(270deg) scale(1.2); }
    100% { transform: rotateZ(360deg) scale(1); }
}

.attack-dice {
    background-color: var(--attack-color);
    color: white;
}

.defense-dice {
    background-color: var(--defense-color);
    color: white;
}

.special-dice {
    background-color: var(--special-color);
    color: white;
}

.dice.critical {
    box-shadow: 0 0 15px #ffeb3b, 0 0 30px rgba(255, 235, 59, 0.5);
    animation: criticalPulse 1.5s infinite;
}

@keyframes criticalPulse {
    0% { box-shadow: 0 0 15px #ffeb3b, 0 0 30px rgba(255, 235, 59, 0.5); }
    50% { box-shadow: 0 0 25px #ffeb3b, 0 0 40px rgba(255, 235, 59, 0.7); }
    100% { box-shadow: 0 0 15px #ffeb3b, 0 0 30px rgba(255, 235, 59, 0.5); }
}

.combat-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 500px;
}

.combat-actions button {
    flex-grow: 1;
    padding: 12px 15px;
    font-size: 1rem;
    min-width: calc(33% - 10px);
    white-space: nowrap;
}

#combat-log, #boss-combat-log {
    background-color: rgba(45, 45, 45, 0.8);
    padding: 15px;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    height: 80px;
    overflow-y: auto;
    margin-bottom: 10px;
    box-shadow: var(--card-shadow);
}

#combat-log p, #boss-combat-log p {
    margin-bottom: 5px;
    font-size: 0.9em;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

#combat-effects {
    background-color: rgba(33, 150, 243, 0.2);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    width: 100%;
    max-width: 500px;
}

.enemy-defeated {
    animation: defeatFade 1s forwards;
}

@keyframes defeatFade {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.5) rotate(10deg); }
}

/* Combat Summary Screen */
#combat-summary {
    background-color: #1a1a1a;
}

.summary-container {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    margin: 20px 0;
    text-align: center;
    box-shadow: var(--card-shadow);
}

#enemy-defeated {
    margin-bottom: 20px;
}

#defeated-enemy-image {
    width: 100px;
    height: 100px;
    margin: 15px auto;
    border-radius: 8px;
}

.summary-stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    text-align: left;
    padding: 0 20px;
}

/* Level Up Screen */
#level-up-screen {
    background-color: #1a1a1a;
    background-image: radial-gradient(circle at center, #2d2d2d 0%, #1a1a1a 70%);
}

.upgrade-options {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 15px;
    margin: 20px 0;
}

.upgrade-card {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    width: 100%;
    max-width: 350px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    text-align: center;
    box-shadow: var(--card-shadow);
}

.upgrade-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.upgrade-card.selected {
    border: 2px solid var(--health-color);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.6);
}

.upgrade-icon {
    width: 60px;
    height: 60px;
    margin: 15px auto;
    border-radius: 50%;
}

.health-icon {
    background-color: var(--health-color);
    position: relative;
}

.health-icon::before {
    content: "+";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30px;
    color: white;
}

.attack-icon {
    background-color: var(--attack-color);
    position: relative;
}

.attack-icon::before {
    content: "↗";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30px;
    color: white;
}

.defense-icon {
    background-color: var(--defense-color);
    position: relative;
}

.defense-icon::before {
    content: "🛡️";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30px;
    color: white;
}

/* Level Transition Screen */
#level-transition {
    background-color: #1a1a1a;
    background-image: radial-gradient(circle at center, #2d2d2d 0%, #1a1a1a 70%);
}

.transition-container {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    margin: 20px 0;
    box-shadow: var(--card-shadow);
}

.level-info {
    text-align: center;
    margin-bottom: 20px;
}

.level-rewards, .level-stats {
    text-align: left;
    margin: 15px 0;
}

.level-rewards ul {
    list-style-type: none;
    padding-left: 20px;
}

.level-rewards li {
    margin: 8px 0;
    position: relative;
}

.level-rewards li:before {
    content: "✓";
    color: var(--health-color);
    position: absolute;
    left: -20px;
}

.level-stats div {
    margin: 8px 0;
}

#continue-to-next-level-btn {
    padding: 15px 30px;
    font-size: 1.2em;
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
    margin-top: 20px;
}

/* Narrative Events */
#narrative {
    background-color: rgba(10, 10, 10, 0.8);
}

.dialog-box {
    background-color: rgba(45, 45, 45, 0.9);
    padding: 30px 25px 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: var(--card-shadow);
}

#npc-portrait {
    width: 80px;
    height: 80px;
    background-color: #555;
    border-radius: 50%;
    position: absolute;
    top: -40px;
    left: 30px;
    border: 4px solid var(--card-bg);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

#dialog-text {
    margin: 20px 0;
    line-height: 1.6;
    font-size: 1.1em;
}

#dialog-choices {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-top: 20px;
}

.dialog-choice {
    text-align: left;
    margin: 5px 0;
    padding: 12px 15px;
    background-color: var(--element-bg);
    border-radius: 5px;
    transition: background-color 0.3s;
}

.dialog-choice:hover {
    background-color: var(--element-hover);
}

/* Shop Screen */
#shop {
    background-color: #1a1a1a;
    justify-content: flex-start;
    overflow-y: auto;
}

.shop-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 20px;
    margin: 20px 0;
}

.shop-inventory, .player-inventory {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    width: 100%;
    box-shadow: var(--card-shadow);
}

.shop-items {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.shop-item {
    background-color: #3d3d3d;
    padding: 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.shop-item:hover {
    background-color: #4d4d4d;
    transform: translateY(-2px);
}

/* Item rarity styles */
.rarity-common {
    border-left: 3px solid #aaa;
}

.rarity-uncommon {
    border-left: 3px solid var(--health-color);
}

.rarity-rare {
    border-left: 3px solid var(--defense-color);
}

.rarity-epic {
    border-left: 3px solid var(--special-color);
    box-shadow: 0 0 8px rgba(156, 39, 176, 0.3);
}

.price {
    font-weight: bold;
    color: var(--tertiary-color);
    margin-top: 8px;
}

.soul-shards {
    margin-top: 20px;
    font-weight: bold;
    color: var(--tertiary-color);
    font-size: 1.2em;
}

/* Player item styling */
.player-item {
    background-color: #3d3d3d;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
}

.player-item h4 {
    margin-bottom: 5px;
}

.player-item p {
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #ccc;
}

.player-item .use-item-btn {
    align-self: flex-end;
    padding: 5px 10px;
    font-size: 0.9em;
}

/* Game Over Screen */
#game-over {
    background-color: #1a1a1a;
    background-image: radial-gradient(circle at center, #2d2d2d 0%, #1a1a1a 70%);
}

.stats-summary {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    margin: 20px 0 30px;
    box-shadow: var(--card-shadow);
}

#final-stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 15px;
}

.game-over-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 300px;
}

.game-over-actions button {
    padding: 12px 25px;
    font-size: 1.1em;
}

/* Settings Screen */
#settings {
    background-color: #1a1a1a;
    justify-content: flex-start;
    overflow-y: auto;
}

.settings-container {
    width: 100%;
    max-width: 500px;
    margin: 20px 0;
}

.settings-group {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0;
    flex-wrap: wrap;
}

.setting-item label {
    font-size: 1em;
    flex: 1;
    min-width: 120px;
}

.setting-item input[type="range"] {
    width: 50%;
    min-width: 120px;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.setting-item select {
    padding: 5px;
    border-radius: 3px;
    background-color: var(--element-bg);
    color: var(--text-color);
    border: none;
}

.setting-value {
    width: 50px;
    text-align: right;
}

.settings-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Credits Screen */
#credits {
    background-color: #1a1a1a;
}

.credits-container {
    width: 100%;
    max-width: 500px;
    margin: 20px 0 30px;
}

.credits-group {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: var(--card-shadow);
}

.credits-group p {
    margin: 10px 0;
    color: #ccc;
}

/* Pause Menu Styles */
#pause-menu {
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
}

.pause-header {
    margin-bottom: 20px;
}

.pause-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 500px;
    gap: 20px;
    margin-bottom: 30px;
}

.pause-stats, .pause-inventory {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    width: 100%;
}

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

.inventory-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
    max-height: 30vh;
    overflow-y: auto;
}

.inventory-item {
    background-color: #3d3d3d;
    padding: 15px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.item-icon {
    width: 40px;
    height: 40px;
    background-color: #555;
    border-radius: 5px;
    flex-shrink: 0;
}

.item-details {
    flex: 1;
}

.use-item-btn {
    padding: 8px 12px;
    font-size: 0.9em;
    white-space: nowrap;
}

.pause-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 300px;
}

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

.modal-content {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.boss-warning-content {
    border: 3px solid var(--boss-color);
    animation: warningPulse 2s infinite;
}

@keyframes warningPulse {
    0% { box-shadow: 0 0 15px rgba(244, 67, 54, 0.6); }
    50% { box-shadow: 0 0 30px rgba(244, 67, 54, 0.8); }
    100% { box-shadow: 0 0 15px rgba(244, 67, 54, 0.6); }
}

.combat-items-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 20px 0;
    max-height: 50vh;
    overflow-y: auto;
}

.combat-item {
    background-color: #3d3d3d;
    padding: 12px;
    border-radius: 5px;
    cursor: pointer;
    text-align: left;
}

.combat-item:hover {
    background-color: #4d4d4d;
}

/* Notification System */
.notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: #333;
    color: #fff;
    padding: 15px 20px;
    border-radius: 5px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    z-index: 1200;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    max-width: 80%;
    text-align: center;
}

.notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.notification.info {
    border-left: 4px solid var(--defense-color);
}

.notification.success {
    border-left: 4px solid var(--health-color);
}

.notification.warning {
    border-left: 4px solid var(--secondary-color);
}

.notification.error {
    border-left: 4px solid var(--attack-color);
}

/* Elite Enemy Styles */
.elite-enemy {
    box-shadow: 0 0 15px var(--elite-glow);
    border: 2px solid var(--elite-glow);
}

/* Level-specific Theme Styles */
body.level-2 {
    background-color: #0d0d20;
}

#game-container.level-2 {
    background-color: #252530;
    border-color: #555;
}

.level-2 .map-cell.visited { 
    background-color: #667; 
}

.level-2 .map-cell.current { 
    background-color: #33c; 
}

/* Level 3 Theme (Final Boss) */
body.level-3 {
    background-color: #200;
}

#game-container.level-3 {
    background-color: #300;
    animation: pulseRed 2s infinite;
}

@keyframes pulseRed {
    0% { box-shadow: 0 0 10px 2px #922; }
    50% { box-shadow: 0 0 20px 4px #e33; }
    100% { box-shadow: 0 0 10px 2px #922; }
}

.final-boss #game-container {
    background-color: #300;
    animation: pulseRed 2s infinite;
}

/* Empty Inventory Placeholder */
.empty-inventory {
    text-align: center;
    color: #888;
    font-style: italic;
    padding: 20px;
}

/* Damage Number Animations */
.damage-number {
    position: absolute;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    animation: floatUp 1.5s forwards;
    z-index: 100;
    font-size: 1.2rem;
}

.damage-number.player-damage {
    color: var(--attack-color);
}

.damage-number.enemy-damage {
    color: var(--health-color);
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px);
    }
}

/* Screen Shake Animation */
.screen-shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
    40%, 60% { transform: translate3d(3px, 0, 0); }
}

/* Scroll indicator */
#scroll-indicator {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: bounce 1s infinite;
    z-index: 1000;
}

#scroll-indicator::after {
    content: "";
    width: 10px;
    height: 10px;
    border-right: 2px solid white;
    border-bottom: 2px solid white;
    transform: rotate(45deg) translateY(-2px);
}

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

/* High Contrast Mode */
body.high-contrast {
    background-color: #000;
    color: #fff;
}

body.high-contrast #game-container {
    background-color: #000;
    border-color: #fff;
}

body.high-contrast button {
    background-color: #fff;
    color: #000;
    border: 2px solid #000;
}

body.high-contrast .health-bar div {
    background-color: #0f0;
}

body.high-contrast .corruption-bar div {
    background-color: #f0f;
}

/* Text Size Adjustments */
body.text-size-small {
    font-size: 0.9em;
}

body.text-size-medium {
    font-size: 1em;
}

body.text-size-large {
    font-size: 1.2em;
}

/* Media Queries for Responsive Design */
@media screen and (min-width: 768px) {
    /* Tablet and desktop adjustments */
    .class-container,
    .difficulty-options,
    .upgrade-options {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .class-card,
    .difficulty-card,
    .upgrade-card {
        width: calc(33.333% - 20px);
        min-width: 220px;
    }
    
    .shop-container,
    .pause-container {
        flex-direction: row;
    }
    
    .shop-inventory, 
    .player-inventory,
    .pause-stats, 
    .pause-inventory {
        width: 48%;
    }
    
    #final-stats {
        grid-template-columns: 1fr 1fr;
    }
    
    .game-hud {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .hud-top {
        flex-direction: row;
        width: auto;
    }
    
    .hud-middle {
        width: auto;
    }
    
    .hud-bottom {
        flex-direction: row;
        width: auto;
    }
    
    .game-over-actions,
    .pause-actions {
        flex-direction: row;
    }
    
    .combat-items-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    #room-description {
        margin-bottom: 50px;
    }
}

@media screen and (min-width: 1024px) {
    body {
        background-color: var(--dark-bg);
    }
    
    #game-container {
        width: 90%;
        height: 90vh;
        border-radius: 8px;
        border: 2px solid #444;
    }
}

/* Portrait mode for mobile */
@media screen and (max-width: 767px) and (orientation: portrait) {
    .dice {
        width: 50px;
        height: 50px;
        font-size: 1.5em;
    }
    
    #enemy-image, #boss-image {
        width: 120px;
        height: 120px;
    }
    
    #boss-image {
        width: 140px;
        height: 140px;
    }
    
    .action-buttons button,
    .combat-actions button {
        padding: 10px;
        font-size: 0.95rem;
    }
    
    #combat-log, #boss-combat-log {
        max-height: 70px;
    }
    
    .health-bar, .corruption-bar {
        height: 18px;
    }
}

/* Landscape mode for mobile */
@media screen and (max-width: 915px) and (orientation: landscape) {
    #game-container {
        height: 100vh;
    }
    
    .screen {
        justify-content: flex-start;
        padding-top: 10px;
    }
    
    h1 {
        margin-bottom: 15px;
    }
    
    h2 {
        margin-bottom: 10px;
    }
    
    .class-container,
    .difficulty-options,
    .upgrade-options {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        margin-bottom: 10px;
    }
    
    .class-card,
    .difficulty-card,
    .upgrade-card {
        width: calc(33.333% - 20px);
        min-width: 200px;
        max-width: 250px;
        padding: 10px;
    }
    
    .game-hud {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .hud-top {
        flex-direction: row;
        width: auto;
    }
    
    .hud-stats {
        position: absolute;
        top: 10px;
        right: 10px;
    }
    
    .health-container, .corruption-container {
        max-width: 180px;
    }
    
    .enemy-container, .boss-container {
        margin: 5px 0;
    }
    
    #enemy-image, #boss-image {
        width: 100px;
        height: 100px;
        margin-bottom: 10px;
    }
    
    #boss-image {
        width: 120px;
        height: 120px;
    }
    
    .dice-container {
        margin: 10px 0;
    }
    
    .dice {
        width: 50px;
        height: 50px;
        font-size: 1.5em;
    }
    
    #combat-log, #boss-combat-log {
        height: 60px;
        margin-bottom: 5px;
    }
    
    .mini-map {
        width: 120px;
        height: 120px;
    }
}

/* Fix for iOS Safari 100vh issue - applied via JS */
@supports (-webkit-touch-callout: none) {
    .screen {
        height: -webkit-fill-available;
    }
}