body {
    margin: 0;
    padding: 0;
    background-color: #222;
    font-family: 'DotGothic16', sans-serif;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* GBA Frame */
#handheld-frame {
    background: #e0e0e0;
    border-radius: 20px;
    padding: 40px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.8);
    position: relative;
    width: 600px;
}

/* Screen Area */
#screen-border {
    background: #111;
    border-radius: 10px;
    padding: 20px;
    border: 2px solid #333;
    margin-bottom: 20px;
    box-shadow: inset 0 0 10px #000;
}

#screen-wrapper {
    position: relative;
    width: 480px; /* 240 * 2 */
    height: 320px; /* 160 * 2 */
    margin: 0 auto;
    overflow: hidden;
    background: #000;
}

#screen-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    image-rendering: pixelated; /* Crisp pixels */
}

.home-link {
    color: #0ff;
    text-decoration: none;
    font-size: 20px;
}

.hidden {
    display: none !important;
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}

#battle-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Base Menu Box */
.menu-box {
    position: absolute;
    background: #f8f8f8;
    border: 4px solid #333;
    border-radius: 6px;
    color: #333;
    font-size: 18px;
    padding: 5px;
    box-sizing: border-box;
}

/* Dialogue Box */
#dialogue-box {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px; 
    background: #f8f8f8;
    border: 4px solid #333;
    border-radius: 6px;
    color: #333;
    font-size: 20px;
    padding: 10px;
    box-sizing: border-box;
    font-weight: bold;
    display: flex;
    align-items: flex-start;
    white-space: pre-wrap;
}

/* Command Menu */
#command-menu, #move-menu {
    bottom: 0;
    right: 0;
    width: 50%;
    height: 80px;
    display: flex;
    flex-wrap: wrap;
}

#field-menu {
    top: 0;
    right: 0;
    width: 120px;
    display: flex;
    flex-direction: column;
}

.menu-item, .move-item {
    width: 50%;
    padding: 5px;
    box-sizing: border-box;
    position: relative;
}

#field-menu .menu-item, #choice-menu .menu-item {
    width: 100%;
}

.menu-item.active::before, .move-item.active::before, .list-item.active::before {
    content: '▶';
    position: absolute;
    left: -8px;
}
.list-item.active::before {
    left: 5px;
}

#move-details {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 50%;
    background: #f8f8f8;
    border: 4px solid #333;
    border-radius: 6px;
    padding: 5px;
    box-sizing: border-box;
    color: #333;
    font-size: 16px;
}

/* Lists Screen (Bag / Pokemon) */
.list-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #e0f8e0;
    padding: 10px;
    box-sizing: border-box;
    color: #333;
    z-index: 50;
}
.list-screen h2 {
    margin: 0 0 10px 0;
    font-size: 22px;
    border-bottom: 2px solid #333;
}
.list-screen ul {
    list-style: none;
    padding: 0;
    margin: 0;
    height: 240px;
    overflow-y: auto;
}
.list-item {
    padding: 5px 5px 5px 25px;
    position: relative;
    font-size: 18px;
}
.list-instructions {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 14px;
}


/* Transition Overlay */
#transition-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: black;
    z-index: 100;
    opacity: 0;
}

.flash-animation {
    animation: flashAnim 1.2s ease-in-out forwards;
}

.fade-in-out {
    animation: fadeAnim 0.6s ease-in-out forwards;
}

@keyframes flashAnim {
    0% { opacity: 0; background: white; }
    20% { opacity: 1; background: white; }
    40% { opacity: 0; background: white; }
    60% { opacity: 1; background: black; }
    80% { opacity: 1; background: black; }
    100% { opacity: 0; background: black; }
}

@keyframes fadeAnim {
    0% { opacity: 0; background: black; }
    50% { opacity: 1; background: black; }
    100% { opacity: 0; background: black; }
}

/* HP Bars */
.status-bar {
    position: absolute;
    background: #f8f8f8;
    border: 3px solid #333;
    border-radius: 6px;
    padding: 5px 10px;
    color: #333;
    font-size: 18px;
    z-index: 15;
    width: 220px;
}

#enemy-hp-bar {
    top: 20px;
    left: 10px;
}

#player-hp-bar {
    bottom: 90px;
    right: 10px;
}

.name { font-weight: bold; float: left;}
.gender { float: left; margin-left: 5px; color: #555;}
.level { float: right; }
.hp-track {
    clear: both;
    width: 100%;
    height: 10px;
    background: #444;
    border-radius: 5px;
    margin-top: 5px;
    border: 2px solid #222;
}

.hp-fill {
    height: 100%;
    width: 100%;
    background: #0f0;
    border-radius: 3px;
    transition: width 0.3s;
}

.hp-text {
    text-align: right;
    font-size: 14px;
    margin-top: 2px;
}

/* Controls (GBA style layout) */
#controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    margin-top: 10px;
}

#dpad {
    position: relative;
    width: 100px;
    height: 100px;
}

#dpad div {
    position: absolute;
    background: #333;
    width: 30px;
    height: 30px;
    cursor: pointer;
}

#dpad .up { top: 0; left: 35px; border-radius: 5px 5px 0 0; }
#dpad .down { bottom: 0; left: 35px; border-radius: 0 0 5px 5px; }
#dpad .left { top: 35px; left: 0; border-radius: 5px 0 0 5px; }
#dpad .right { top: 35px; right: 0; border-radius: 0 5px 5px 0; }
#dpad::after {
    content: '';
    position: absolute;
    top: 35px; left: 35px;
    width: 30px; height: 30px;
    background: #333;
}

#action-buttons {
    display: flex;
    gap: 15px;
    transform: rotate(-15deg);
}

#action-buttons div {
    width: 50px;
    height: 50px;
    background: #c00;
    border-radius: 50%;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
}

#action-buttons .btn-b { margin-top: 20px; }

#start-select {
    display: flex;
    gap: 20px;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

#start-select div {
    width: 50px;
    height: 12px;
    background: #333;
    border-radius: 6px;
    transform: rotate(-15deg);
    cursor: pointer;
    font-size: 10px;
    text-align: center;
    line-height: 25px; /* push text down */
    color: #666;
}
