:root {
    --retro-blue: #001a6d;
    --retro-text: #ffffff;
    --retro-border: #c3c3c3;
    --gold: #FFDF00;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: 'Press Start 2P', cursive;
    background-color: black;
    color: var(--retro-text);
    text-align: center;
    image-rendering: pixelated;
    font-smooth: never;
    -webkit-font-smoothing: none;
}

#game-container {
    position: relative;
    height: 100%;
    padding: 10px;
    box-sizing: border-box;
}

#start-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
}

#persona-select-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    gap: 20px;
    margin-top: 20px;
}

#start-screen button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 15px;
    min-width: 150px;
}

h3, h4 {
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--retro-text);
}

#game-screen {
    display: grid;
    height: 100%;
    max-height: 100%;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 4fr auto 1fr auto;
    grid-template-areas: 
        "player enemy"
        "actions actions"
        "log log"
        "system system";
    gap: 10px;
}

#player-stats, #enemy-display {
    background-color: var(--retro-blue);
    padding: 15px;
    text-align: left;
    border: 12px solid;
    border-image-source: url(https://i.imgur.com/jI9a614.png);
    border-image-slice: 6;
    border-image-width: 1;
    border-image-repeat: stretch;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#player-stats::-webkit-scrollbar, #enemy-display::-webkit-scrollbar {
    display: none;
}

#player-stats { grid-area: player; }
#enemy-display {
    grid-area: enemy;
    background-color: var(--retro-blue);
    padding: 15px;
    text-align: left;
    border: 12px solid;
    border-image-source: url(https://i.imgur.com/jI9a614.png);
    border-image-slice: 6;
    border-image-width: 1;
    border-image-repeat: stretch;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.game-title {
    font-size: 1.5em;
    color: var(--gold);
    text-shadow: 2px 2px #000000;
    margin-bottom: 30px;
}

#actions {
    grid-area: actions;
    border: 12px solid;
    border-image-source: url(https://i.imgur.com/jI9a614.png);
    border-image-slice: 6;
    border-image-width: 1;
    background-color: var(--retro-blue);
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 15px;
    padding: 15px;
    align-items: stretch;
}

#actions.reward-mode {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #000;
}

.reward-cards-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
}

.reward-mode h4 {
    color: var(--gold);
    font-size: 1.1em;
    margin-bottom: 15px;
}

.card-button {
    flex-basis: 200px;
    min-height: 130px;
    border: 2px solid var(--gold);
    background-color: var(--retro-blue);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 12px;
    text-align: center;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
    cursor: pointer;
    animation: fadeIn 0.5s ease-out forwards;
}

.card-button:hover {
    transform: translateY(-8px) scale(1.03);
    box-shadow: 0 8px 15px rgba(255, 223, 0, 0.25);
}

.card-button strong {
    color: var(--gold);
    font-size: 0.85em;
    margin-bottom: 8px;
}

.card-button span {
    font-size: 0.7em;
    line-height: 1.3;
}

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

.icon {
    width: 100px;
    height: 100px;
    object-fit: contain;
    image-rendering: pixelated;
}

button {
    background-color: var(--retro-blue);
    color: var(--retro-text);
    border: 2px solid var(--retro-border);
    padding: 10px 15px;
    cursor: pointer;
    font-family: 'Press Start 2P', cursive;
    margin: 0;
    font-size: 0.8em;
}

button:hover:not(:disabled) {
    background-color: var(--retro-text);
    color: var(--retro-blue);
}

ul {
    list-style-type: none;
    padding: 0;
    text-align: left;
    margin: 10px 0;
}
li {
    padding: 2px 0;
}

.stat-bar {
    background-color: #333;
    border: 1px solid var(--retro-border);
    height: 12px;
    width: 100%;
    margin: 5px 0 15px 0;
}
.hp-fill {
    background-color: #32a852;
    height: 100%;
}
.sp-fill {
    background-color: #3262a8;
    height: 100%;
}
.xp-fill {
    background-color: var(--gold);
    height: 100%;
}
.feedback-text {
    position: absolute;
    font-size: 1.2em;
    font-weight: bold;
    transform: translate(50px, 50px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s;
}

.feedback-text.show {
    animation: fadeUp 1s ease-out;
}

@keyframes fadeUp {
    0% { opacity: 1; transform: translate(50px, 50px); }
    100% { opacity: 0; transform: translate(50px, 0px); }
}

#exit-container {
    display: block;
}

#exit-container button {
    margin-right: 5px;
}

#floor-counter {
    font-size: 0.8em;
    color: var(--retro-border);
    text-align: right;
}

.feedback-text.weak { color: #ff4d4d; }
.feedback-text.resist { color: #a2d2ff; }
.feedback-text.null { color: #b0b0b0; }
.feedback-text.critical { color: #ffd900; }
.feedback-text.damage { color: #ffffff; }
.feedback-text.healing { color: #32a852; }
@keyframes screen-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: screen-shake 0.3s;
}

#game-log-container {
    grid-area: log;
    background-color: var(--retro-blue);
    border: 12px solid;
    border-image-source: url(https://i.imgur.com/jI9a614.png);
    border-image-slice: 6;
    border-image-width: 1;
    padding: 10px;
    text-align: left;
    overflow: hidden;
}

#game-log {
    height: 100%;
    overflow-y: auto;
    font-size: 0.7em;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
#game-log::-webkit-scrollbar {
    display: none;
}

#game-log p {
    margin: 0 0 5px 0;
    line-height: 1.2;
}

#attack-button {
    height: 100%;
    font-size: 1.2em;
    box-sizing: border-box;
}

#skill-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
}

.skill-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background-color: rgba(0, 0, 0, 0.2);
    border: 2px solid var(--retro-border);
    width: 100%;
    text-align: left;
    font-size: 0.8em;
    box-sizing: border-box;
    margin: 0;
}

.skill-button.empty {
    border: 2px dashed rgba(255, 255, 255, 0.3);
    background: transparent;
    color: #6c757d;
    justify-content: center;
    align-items: center;
}

.skill-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.skill-cost {
    font-weight: bold;
    color: var(--gold);
}

#system-bar {
    grid-area: system;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--retro-blue);
    padding: 10px 15px;
    border: 12px solid;
    border-image-source: url(https://i.imgur.com/jI9a614.png);
    border-image-slice: 6;
    border-image-width: 1;
}

.log-player { color: #87CEEB; }
.log-enemy { color: #FFB6C1; }
.log-player-dmg { color: #ff4d4d; }
.log-healing { color: #90EE90; }
.log-system { color: #D3D3D3; }
.log-critical { color: var(--gold); }
.log-resist { color: #a2d2ff; }

@media (max-width: 768px) {
    #game-container {
        padding: 5px;
    }

    #game-screen {
        grid-template-columns: 1fr;
        grid-template-rows: 2.5fr 2.5fr auto 1fr auto;
        grid-template-areas: 
            "player"
            "enemy"
            "actions"
            "log"
            "system";
    }
    
    #persona-select-container {
        flex-direction: column;
    }

    #player-stats, #enemy-display, #actions, #game-log-container, #system-bar {
        padding: 10px;
        border-width: 10px;
    }
    
    .stat-panel-container {
        display: flex;
        gap: 15px;
    }

    .stat-panel-left {
        flex-basis: 120px;
        flex-shrink: 0;
        text-align: center;
    }

    .stat-panel-right {
        flex: 1;
    }

    #actions {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        gap: 10px;
    }

    #skill-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: repeat(3, 1fr);
    }

    button {
        padding: 8px 10px;
        font-size: 0.7em;
    }

    .reward-cards-container {
        gap: 10px;
        flex-wrap: wrap;
    }

    .card-button {
        flex-basis: 45%;
        min-height: 100px;
        padding: 8px;
    }
    
    .card-button span {
        font-size: 0.65em;
    }

    #system-bar {
        flex-direction: column;
        gap: 8px;
    }
}