@import url('https://fonts.googleapis.com/css2?family=VT323&family=Cormorant+Garamond:ital,wght@0,400;0,700;1,400&display=swap');

:root {
    --bg-dark: #050505;
    --ui-border: #333;
    --ui-bg: rgba(10, 10, 15, 0.95);
    --accent-prim: #e0e0e0; /* Bone white */
    --accent-tech: #00ffcc; /* Cyan glitch */
    --accent-danger: #ff0055;
    --font-pixel: 'VT323', monospace;
    --font-serif: 'Cormorant Garamond', serif;
}

body {
    background-color: #000;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    color: var(--accent-prim);
    font-family: var(--font-pixel);
    overflow: hidden;
}

#game-container {
    width: 1100px;
    height: 700px;
    background: var(--bg-dark);
    display: grid;
    grid-template-columns: 1fr 280px; /* Stage | Sidebar */
    grid-template-rows: 1fr 220px; /* Stage | Dialogue */
    border: 2px solid var(--ui-border);
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.1);
    position: relative;
}

/* --- STAGE (Top Left) --- */
#stage {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    overflow: hidden;
    background: #111;
    border-right: 2px solid var(--ui-border);
    border-bottom: 2px solid var(--ui-border);
}

.layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: opacity 0.5s;
}

#bg-layer {
    background-size: cover;
    background-position: center;
    image-rendering: pixelated;
}

#sprite-layer {
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.sprite {
    height: 80%;
    width: auto;
    filter: drop-shadow(0 0 5px rgba(0,0,0,0.8));
    transition: transform 0.3s;
}

/* --- SIDEBAR (Right Column) --- */
#sidebar {
    grid-column: 2;
    grid-row: 1 / 3; /* Spans full height */
    background: var(--ui-bg);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-left: 1px solid #222;
}

.panel-header {
    color: var(--accent-tech);
    border-bottom: 1px solid var(--accent-tech);
    font-size: 1.4em;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 1.5em;
}

.glitch-bar-container {
    width: 100%;
    height: 10px;
    background: #333;
    margin-top: 5px;
}

.glitch-bar-fill {
    height: 100%;
    background: var(--accent-danger);
    width: 0%;
    transition: width 0.5s;
    box-shadow: 0 0 5px var(--accent-danger);
}

#inventory-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.inv-slot {
    aspect-ratio: 1;
    border: 1px solid #444;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.inv-slot img {
    max-width: 80%;
    max-height: 80%;
}

#log-container {
    flex-grow: 1;
    overflow-y: auto;
    font-family: var(--font-serif);
    font-size: 1.1em;
    color: #888;
    border-top: 1px solid #333;
    padding-top: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-tech) #000;
}

.log-entry {
    margin-bottom: 8px;
    line-height: 1.3;
}

/* --- DIALOGUE (Bottom Left) --- */
#dialogue-area {
    grid-column: 1;
    grid-row: 2;
    background: var(--ui-bg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

#speaker-tag {
    position: absolute;
    top: -15px;
    left: 20px;
    background: var(--accent-tech);
    color: #000;
    padding: 2px 10px;
    font-weight: bold;
    font-size: 1.1em;
}

#dialogue-text {
    font-family: var(--font-serif);
    font-size: 1.5em;
    line-height: 1.4;
    min-height: 80px;
}

#choice-container {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 10px;
}

button {
    background: transparent;
    border: 1px solid var(--accent-tech);
    color: var(--accent-tech);
    padding: 10px 15px;
    font-family: var(--font-pixel);
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s;
}

button:hover {
    background: var(--accent-tech);
    color: #000;
}

button.skill-check {
    border-color: #ffaa00;
    color: #ffaa00;
}

button.skill-check:hover {
    background: #ffaa00;
    color: #000;
}

/* --- OVERLAYS --- */
#crt-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
    z-index: 100;
    opacity: 0.4;
}

#dice-container {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    display: flex;
    gap: 20px;
    z-index: 50;
}

.die {
    width: 60px;
    height: 60px;
    background: #fff;
    color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    border-radius: 5px;
    animation: rollAnim 0.5s ease-out;
}

.die.success {
    background: var(--accent-tech);
    box-shadow: 0 0 15px var(--accent-tech);
}

.die.fail {
    background: #555;
    color: #888;
}

/* --- ANIMATIONS --- */

@keyframes rollAnim {
    0% { transform: translateY(-50px) rotate(0deg); opacity: 0; }
    100% { transform: translateY(0) rotate(360deg); opacity: 1; }
}

@keyframes glitch-skew {
    0% { transform: translate(0) }
    20% { transform: translate(-2px, 2px) skewX(5deg) }
    40% { transform: translate(-2px, -2px) skewX(-5deg) }
    60% { transform: translate(2px, 2px) skewX(2deg) }
    80% { transform: translate(2px, -2px) skewX(-2deg) }
    100% { transform: translate(0) }
}

/* Utility */
.hidden { display: none !important; }
