@import url('https://fonts.googleapis.com/css2?family=DotGothic16&family=Zen+Kaku+Gothic+New:wght@400;700&display=swap');

:root {
    --bg-color: #000;
    --text-color: #fff;
    --highlight-color: #f1c40f;
    --accent-color: #3498db;
    --danger-color: #e74c3c;
    --window-bg: rgba(0, 0, 0, 0.85);
    --border-color: #fff;
    --border-width: 4px;
    --border-radius: 8px;
    --font-main: 'Zen Kaku Gothic New', sans-serif;
    --font-header: 'DotGothic16', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: #111;
    color: var(--text-color);
    font-family: var(--font-main);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* Scanline Effect */
.scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 999;
}

.app-container {
    width: 100%;
    max-width: 800px;
    height: 100%;
    max-height: 600px;
    background-color: var(--bg-color);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 10px;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Common Window Style */
.rpg-window {
    background-color: var(--window-bg);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    position: relative;
}

/* Start Screen */
.start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.title-logo {
    font-family: var(--font-header);
    font-size: 3rem;
    color: var(--highlight-color);
    text-shadow: 4px 4px 0 #ff0000;
    margin-bottom: 2rem;
    border: 4px double white;
    padding: 20px;
}

.start-menu {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 80%;
    max-width: 400px;
}

.rpg-btn {
    background: transparent;
    color: var(--text-color);
    border: 2px solid transparent;
    font-family: var(--font-header);
    font-size: 1.5rem;
    padding: 10px;
    cursor: pointer;
    text-align: left;
    position: relative;
    padding-left: 30px;
}

.rpg-btn:hover,
.rpg-btn:focus {
    color: var(--highlight-color);
}

.rpg-btn:hover::before,
.rpg-btn:focus::before {
    content: '▶';
    position: absolute;
    left: 0;
    color: var(--highlight-color);
    animation: blink 1s infinite;
}

/* Game Layout */
.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    flex-shrink: 0;
    font-family: var(--font-header);
}

.status-item {
    font-size: 1.2rem;
}

.status-label {
    color: #aaa;
    margin-right: 5px;
}

.status-value {
    color: var(--text-color);
    font-weight: bold;
}

.main-view {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #000;
    min-height: 150px;
}

.era-background {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.pixel-art-container {
    font-size: 4rem;
    display: flex;
    gap: 20px;
    filter: grayscale(0.3) contrast(1.2);
}

.mascot-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 3rem;
    animation: bounce 2s infinite;
}

.message-window {
    height: 120px;
    font-size: 1.2rem;
    line-height: 1.6;
    overflow-y: auto;
    flex-shrink: 0;
}

.command-window {
    height: 150px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    flex-shrink: 0;
}

.command-btn {
    background: transparent;
    border: 2px solid transparent;
    color: white;
    font-family: var(--font-main);
    font-size: 1.1rem;
    text-align: left;
    padding: 5px 10px;
    cursor: pointer;
    position: relative;
    padding-left: 25px;
}

.command-btn:hover {
    border: 2px solid white;
    background-color: #222;
}

.command-btn::before {
    content: '▶';
    position: absolute;
    left: 5px;
    opacity: 0;
}

.command-btn:hover::before {
    opacity: 1;
}

.command-btn.correct {
    color: var(--highlight-color);
    border-color: var(--highlight-color);
}

.command-btn.wrong {
    color: #888;
    text-decoration: line-through;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
}

.level-up-box {
    text-align: center;
    animation: flash 0.5s 3;
}

.level-up-text {
    font-family: var(--font-header);
    font-size: 3rem;
    color: var(--highlight-color);
    margin-bottom: 20px;
}

.level-up-info {
    font-size: 1.5rem;
    margin-bottom: 30px;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes flash {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Era Specific Backgrounds */
.bg-jomon {
    background: #2e8b57;
}

.bg-yayoi {
    background: #daa520;
}

.bg-kofun {
    background: #8b4513;
}

.bg-asuka {
    background: #800080;
}

.bg-nara {
    background: #cd5c5c;
}

.bg-heian {
    background: #4b0082;
}

.bg-kamakura {
    background: #708090;
}

.bg-muromachi {
    background: #556b2f;
}

.bg-azuchi {
    background: #ffd700;
    color: black;
}

.bg-edo {
    background: #000080;
}

.bg-meiji {
    background: #b22222;
}

.bg-taisho {
    background: #c71585;
}

.bg-showa {
    background: #696969;
}

.bg-heisei {
    gap: 20px;
    filter: grayscale(0.3) contrast(1.2);
}

.mascot-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 3rem;
    animation: bounce 2s infinite;
}

.message-window {
    height: 120px;
    font-size: 1.2rem;
    line-height: 1.6;
    overflow-y: auto;
    flex-shrink: 0;
}

.command-window {
    height: 150px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    flex-shrink: 0;
}

.command-btn {
    background: transparent;
    border: 2px solid transparent;
    color: white;
    font-family: var(--font-main);
    font-size: 1.1rem;
    text-align: left;
    padding: 5px 10px;
    cursor: pointer;
    position: relative;
    padding-left: 25px;
}

.command-btn:hover {
    border: 2px solid white;
    background-color: #222;
}

.command-btn::before {
    content: '▶';
    position: absolute;
    left: 5px;
    opacity: 0;
}

.command-btn:hover::before {
    opacity: 1;
}

.command-btn.correct {
    color: var(--highlight-color);
    border-color: var(--highlight-color);
}

.command-btn.wrong {
    color: #888;
    text-decoration: line-through;
}

.command-btn.next-btn {
    background-color: var(--accent-color);
    color: white;
    font-weight: bold;
    text-align: center;
    border: 2px solid white;
    animation: flash 1s infinite;
}

.command-btn.next-btn:hover {
    background-color: var(--highlight-color);
    color: black;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
}

.level-up-box {
    text-align: center;
    animation: flash 0.5s 3;
}

.level-up-text {
    font-family: var(--font-header);
    font-size: 3rem;
    color: var(--highlight-color);
    margin-bottom: 20px;
}

.level-up-info {
    font-size: 1.5rem;
    margin-bottom: 30px;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes flash {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Era Specific Backgrounds */
.bg-jomon {
    background: #2e8b57;
}

.bg-yayoi {
    background: #daa520;
}

.bg-kofun {
    background: #8b4513;
}

.bg-asuka {
    background: #800080;
}

.bg-nara {
    background: #cd5c5c;
}

.bg-heian {
    background: #4b0082;
}

.bg-kamakura {
    background: #708090;
}

.bg-muromachi {
    background: #556b2f;
}

.bg-azuchi {
    background: #ffd700;
    color: black;
}

.bg-edo {
    background: #000080;
}

.bg-meiji {
    background: #b22222;
}

.bg-taisho {
    background: #c71585;
}

.bg-showa {
    background: #696969;
}

.bg-heisei {
    background: #00ced1;
    color: black;
}

/* HP Gauge */
.hp-bar-fill {
    height: 100%;
    background-color: var(--accent-color);
    width: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.hp-container {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 150px;
}

.hp-bar-bg {
    flex: 1;
    height: 15px;
    transform: translateX(0);
}

/* Image Display (Integrated) */
.image-display-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    height: auto;
    max-width: 95%;
    max-height: 85%;
    z-index: 10;
    border: 4px solid white;
    background: black;
    display: none;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
}

.image-display-area.visible {
    display: flex;
    justify-content: center;
    align-items: center;
    animation: popIn 0.3s ease-out;
}

.image-display-area img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

@keyframes popIn {
    0% {
        transform: translate(-50%, -50%) scale(0);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

.flash-red {
    animation: flashRed 0.5s;
}

.flash-green {
    animation: flashGreen 0.5s;
}

@keyframes flashRed {

    0%,
    100% {
        background-color: var(--bg-color);
    }

    50% {
        background-color: rgba(255, 0, 0, 0.3);
    }
}

@keyframes flashGreen {

    50% {
        opacity: 0;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes flash {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Era Specific Backgrounds */
.bg-jomon {
    background: #2e8b57;
}

.bg-yayoi {
    background: #daa520;
}

.bg-kofun {
    background: #8b4513;
}

.bg-asuka {
    background: #800080;
}

.bg-nara {
    background: #cd5c5c;
}

.bg-heian {
    background: #4b0082;
}

.bg-kamakura {
    background: #708090;
}

.bg-muromachi {
    background: #556b2f;
}

.bg-azuchi {
    background: #ffd700;
    color: black;
}

.bg-edo {
    background: #000080;
}

.bg-meiji {
    background: #b22222;
}

.bg-taisho {
    background: #c71585;
}

.bg-showa {
    background: #696969;
}

.bg-heisei {
    background: #00ced1;
    color: black;
}

/* HP Gauge */
.hp-bar-fill {
    height: 100%;
    background-color: var(--accent-color);
    width: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.hp-container {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 150px;
}

.hp-bar-bg {
    flex: 1;
    height: 15px;
    transform: translateX(0);
}

/* Image Display (Integrated) */
.image-display-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    height: auto;
    max-width: 95%;
    max-height: 85%;
    z-index: 10;
    border: 4px solid white;
    background: black;
    display: none;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
}

.image-display-area.visible {
    display: flex;
    justify-content: center;
    align-items: center;
    animation: popIn 0.3s ease-out;
}

.image-display-area img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

@keyframes popIn {
    0% {
        transform: translate(-50%, -50%) scale(0);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

.flash-red {
    animation: flashRed 0.5s;
}

.flash-green {
    animation: flashGreen 0.5s;
}

@keyframes flashRed {

    0%,
    100% {
        background-color: var(--bg-color);
    }

    50% {
        background-color: rgba(255, 0, 0, 0.3);
    }
}

@keyframes flashGreen {

    0%,
    100% {
        background-color: var(--bg-color);
    }

    50% {
        background-color: rgba(50, 205, 50, 0.3);
    }
}

/* Help Modal */
#help-modal .rpg-window {
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

#help-content h3 {
    color: var(--highlight-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
    margin-top: 20px;
}

#help-content p {
    margin-bottom: 10px;
    line-height: 1.6;
}

#help-content ul {
    list-style-type: disc;
    padding-left: 20px;
    margin-bottom: 10px;
}

#help-content li {
    margin-bottom: 5px;
}