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

html, body {
    height: 100%;
    overflow: hidden;
    background-color: #000;
}

body {
    font-family: 'Press Start 2P', cursive;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    image-rendering: pixelated;
}

#game-container {
    width: 100%;
    max-width: 800px;
    aspect-ratio: 4 / 3;
    background-color: #000;
    display: flex;
    flex-direction: column;
    border: 4px solid #333;
    position: relative;
}

#monster-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 20px;
    position: relative;
    background: radial-gradient(circle, #2a2a4a 0%, #00001a 100%);
    gap: 10px;
}

#monster-hud {
    position: absolute;
    top: 10px;
    left: 10px;
    border-width: 4px;
    padding: 5px 10px;
    font-size: 0.8rem;
    width: 250px;
}
.hud-top-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}


#monster-sprite-container {
    position: relative;
}

#monster-sprite {
    max-width: 200px;
    max-height: 200px;
    filter: drop-shadow(0 5px 5px rgba(0,0,0,0.7));
    image-rendering: pixelated;
}

#bottom-ui-container {
    height: 40%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 10px;
    z-index: 10;
}

.jrpg-box {
    border-style: solid;
    border-width: 16px;
    padding: 15px;
    border-image-source: url('https://r2.flowith.net/files/o/1757505148939-16_bit_jrpg_ui_assets_index_1@1024x1024.png');
    border-image-slice: 8;
    border-image-repeat: repeat;
    background-color: rgba(0, 0, 50, 0.7);
    background-clip: padding-box;
    position: relative;
}

#player-hud {
    height: 100px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 15px;
}
#player-sprite-container {
    width: 70px;
    height: 70px;
    background: rgba(255,255,255,0.1);
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
#player-sprite {
    max-width: 60px;
    max-height: 60px;
}
.hud-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hud-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 8px;
    height: 100%;
    font-size: 0.8rem;
    padding-bottom: 8px;
}

.hp-bar-container {
    width: 100%;
    height: 10px;
    background-color: #333;
    border: 1px solid #fff;
}
.hp-bar {
    height: 100%;
    background-color: #33ff33;
    transition: width 0.5s ease-out;
}
.exp-bar-container {
    width: 100%;
    height: 8px;
    background-color: #2c2c2c;
    border: 1px solid #aaa;
    margin-top: 4px;
}
.exp-bar {
    width: 0%;
    height: 100%;
    background-color: #33ccff;
    transition: width 0.5s ease-out;
}


#ui-area {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#message-box, #problem-box, #action-menu, #inventory-screen {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#message-text {
    line-height: 1.5;
}

#problem-box {
    gap: 15px;
}

#timer-bar-container {
    width: 100%;
    height: 8px;
    background-color: #333;
    border: 2px solid #fff;
}

#timer-bar {
    width: 100%;
    height: 100%;
    background-color: #66ff33;
    transition: width 1s linear;
}

#problem-text {
    font-size: 1.5rem;
    text-align: center;
}

#input-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

#answer-input {
    background: #000;
    border: 2px solid #fff;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    padding: 10px;
    width: 120px;
    text-align: center;
    font-size: 1.2rem;
    -moz-appearance: textfield;
}
#answer-input::-webkit-outer-spin-button,
#answer-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}


button {
    font-family: 'Press Start 2P', cursive;
    background: #222;
    color: #fff;
    border: 2px solid #fff;
    padding: 12px 20px;
    cursor: pointer;
}

button:hover:not(.disabled-btn) {
    background: #fff;
    color: #000;
}

button.selected {
    background: #fff;
    color: #000;
    box-shadow: 0 0 8px #fff;
}

.disabled-btn {
    color: #777;
    border-color: #777;
    cursor: not-allowed;
}

#action-menu {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

#inventory-screen {
    justify-content: flex-start;
    gap: 15px;
}
#inventory-screen h2 {
    text-align: center;
    border-bottom: 2px solid white;
    padding-bottom: 10px;
}
#inventory-list {
    list-style: none;
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
}
#inventory-list li {
    padding: 8px 5px;
    border-bottom: 1px dashed #555;
    cursor: pointer;
}
#inventory-list li:hover {
    background: rgba(255,255,255,0.2);
}
#close-inventory-btn {
    align-self: center;
}

.hidden {
    display: none !important;
}

#damage-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 100;
}
.damage-number {
    position: absolute;
    font-size: 2rem;
    font-weight: bold;
    color: #ffdd55;
    text-shadow: 2px 2px #000;
    animation: float-up 1.5s ease-out forwards;
}
@keyframes float-up {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-80px); opacity: 0; }
}


@keyframes damage-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.monster-damage-flash {
    animation: damage-flash 0.3s 3;
}

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

.player-damage-flash {
    animation: screen-shake 0.5s;
}

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 1.5rem;
    z-index: 200;
}

#gold-timer-container {
    width: 200px;
    height: 2px;
    background-color: #1a1a1a;
}

#gold-timer-bar {
    width: 100%;
    height: 100%;
    background-color: gold;
    transition: width 1s linear;
}
