@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
    --bg-color: #101410;
    --screen-bg: #050a05;
    --text-color: #33ff33;
    --text-dim: #1e991e;
    --accent-color: #ffff33;
    --accent-red: #ff3333;
    --accent-blue: #33ffff;
    --bezel-color: #2b1d0c;
    --border-color: #33ff33;
    --scanline-opacity: 0.25;
}

/* Apple II Green Theme (Default) */
body.theme-green {
    --bg-color: #0d140d;
    --screen-bg: #050f05;
    --text-color: #33ff33;
    --text-dim: #1f8a1f;
    --accent-color: #66ff66;
    --accent-red: #ff5555;
    --accent-blue: #55ffff;
    --border-color: #33ff33;
}

/* DOS 16-Color VGA Theme */
body.theme-vga {
    --bg-color: #121820;
    --screen-bg: #0000aa;
    --text-color: #ffffff;
    --text-dim: #aaaaaa;
    --accent-color: #ffff55;
    --accent-red: #ff5555;
    --accent-blue: #55ffff;
    --border-color: #ffffff;
}

/* Amber Phosphor Theme */
body.theme-amber {
    --bg-color: #140d00;
    --screen-bg: #0f0a00;
    --text-color: #ffaa00;
    --text-dim: #996600;
    --accent-color: #ffdd44;
    --accent-red: #ff4400;
    --accent-blue: #ffcc66;
    --border-color: #ffaa00;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 20px;
}

/* CRT Cabinet Bezel */
.cabinet {
    position: relative;
    background: radial-gradient(circle at center, #3d2714 0%, #1a0f05 100%);
    border: 14px solid #4a3319;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8), inset 0 0 15px rgba(0,0,0,0.9);
    padding: 20px;
    max-width: 960px;
    width: 100%;
}

.bezel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 11px;
    color: #e5b97d;
    text-shadow: 1px 1px 2px #000;
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    letter-spacing: 1px;
}

.theme-controls {
    display: flex;
    gap: 6px;
}

.theme-btn, .sound-btn {
    background: #2a180b;
    color: #dfb277;
    border: 1px solid #754c24;
    padding: 5px 9px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 9px;
    transition: all 0.2s;
}

.theme-btn:hover, .sound-btn:hover {
    background: #4a2d15;
    color: #fff;
}

/* Party Roster Deck */
.party-roster {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.party-card {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #754c24;
    border-radius: 8px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.party-img-wrap {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
    overflow: hidden;
    background: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.party-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.party-pixel-avatar {
    font-size: 20px;
}

.party-info {
    overflow: hidden;
}

.party-name {
    font-size: 10px;
    font-weight: bold;
    color: #fff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.party-role {
    font-size: 8px;
    color: #dfb277;
    white-space: nowrap;
}

/* CRT Screen Frame */
.crt-monitor {
    position: relative;
    background-color: var(--screen-bg);
    border: 4px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    min-height: 560px;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.95), 0 0 15px var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Title / Attract Screen */
#title-overlay {
    display: none; /* JS switches to flex */
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 92; /* under scanline overlay (100) so the CRT look stays */
    align-items: center;
    justify-content: center;
    text-align: center;
    background:
        linear-gradient(rgba(5, 15, 5, 0.62), rgba(5, 15, 5, 0.9)),
        radial-gradient(circle at 50% 35%, rgba(51, 255, 51, 0.12), transparent 60%);
    cursor: pointer;
}

.title-card {
    padding: 20px;
}

.title-logo {
    font-family: 'Press Start 2P', monospace;
    font-size: 44px;
    line-height: 1.25;
    color: var(--accent-color);
    text-shadow:
        0 0 8px var(--text-color),
        3px 3px 0 rgba(0, 0, 0, 0.6);
    letter-spacing: 2px;
    animation: title-glow 2.2s ease-in-out infinite;
}

@keyframes title-glow {
    0%, 100% { text-shadow: 0 0 8px var(--text-color), 3px 3px 0 rgba(0,0,0,0.6); }
    50% { text-shadow: 0 0 18px var(--text-color), 0 0 28px var(--accent-color), 3px 3px 0 rgba(0,0,0,0.6); }
}

.title-sub {
    margin-top: 18px;
    font-size: 13px;
    color: var(--accent-blue);
    letter-spacing: 3px;
}

.start-btn {
    margin-top: 34px;
    background: transparent;
    color: var(--text-color);
    border: 3px solid var(--text-color);
    padding: 16px 32px;
    font-family: 'Press Start 2P', monospace;
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px;
    animation: start-blink 1.1s step-end infinite;
    transition: transform 0.1s;
}

.start-btn:hover {
    background: var(--text-color);
    color: var(--screen-bg);
    box-shadow: 0 0 22px var(--text-color);
    animation: none;
    transform: scale(1.05);
}

@keyframes start-blink {
    0%, 55% { opacity: 1; }
    56%, 100% { opacity: 0.45; }
}

.title-credit {
    margin-top: 30px;
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 1px;
}

@media (max-width: 768px) {
    .title-logo { font-size: 30px; }
    .start-btn { font-size: 15px; padding: 14px 24px; }
    .title-credit { font-size: 8px; }
}

/* Intro Cinematic Overlay */
#intro-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #000;
    z-index: 90; /* under the scanline overlay so the CRT look stays */
    cursor: pointer;
}

#intro-overlay video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
}

#intro-skip {
    position: absolute;
    right: 18px;
    bottom: 14px;
    font-size: 11px;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    padding: 6px 10px;
    animation: skip-blink 1.4s step-end infinite;
}

@keyframes skip-blink {
    0%, 60% { opacity: 1; }
    61%, 100% { opacity: 0.35; }
}

.crt-overlay {
    pointer-events: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, var(--scanline-opacity)) 50%
    ), linear-gradient(
        90deg,
        rgba(255, 0, 0, 0.03),
        rgba(0, 255, 0, 0.01),
        rgba(0, 255, 0, 0.03)
    );
    background-size: 100% 4px, 6px 100%;
    z-index: 100;
    border-radius: 8px;
}

#game-canvas {
    width: 100%;
    height: 240px;
    background-color: #000;
    border: 2px solid var(--text-dim);
    margin-bottom: 12px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
}

#game-ui {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#screen-text {
    flex: 1;
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 14px;
    min-height: 170px;
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--text-dim) var(--screen-bg);
}

.highlight {
    color: var(--accent-color);
    font-weight: bold;
}

.danger {
    color: var(--accent-red);
}

.info {
    color: var(--accent-blue);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    background: rgba(0, 50, 0, 0.3);
    border: 1px dashed var(--text-dim);
    padding: 8px;
    margin-bottom: 12px;
    font-size: 10px;
    text-align: center;
    gap: 4px;
}

.status-label {
    color: var(--text-dim);
    font-size: 9px;
}

.status-val {
    font-weight: bold;
    color: var(--accent-color);
}

#input-zone {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.options-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
}

.option-btn {
    background: transparent;
    color: var(--text-color);
    border: 2px solid var(--text-color);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 11px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
    border-radius: 4px;
}

.option-btn:hover, .option-btn:focus {
    background: var(--text-color);
    color: var(--screen-bg);
    outline: none;
    box-shadow: 0 0 10px var(--text-color);
}

.custom-input-box {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.prompt-prefix {
    font-size: 14px;
    font-weight: bold;
}

#player-input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--text-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 14px;
    padding: 4px 8px;
    outline: none;
    text-transform: uppercase;
}

#submit-btn {
    background: transparent;
    color: var(--text-color);
    border: 2px solid var(--text-color);
    padding: 6px 14px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}

#submit-btn:hover {
    background: var(--text-color);
    color: var(--screen-bg);
}

/* Photo Upload Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-card {
    background: #1e1308;
    border: 4px solid #b8860b;
    border-radius: 12px;
    padding: 20px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: #ffdd44;
}

.modal-header h3 {
    font-size: 12px;
}

.modal-close {
    background: transparent;
    border: none;
    color: #ff5555;
    font-size: 18px;
    cursor: pointer;
    font-weight: bold;
}

.modal-desc {
    font-size: 10px;
    color: #dfb277;
    margin-bottom: 16px;
    line-height: 1.5;
}

.upload-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.upload-slot {
    background: rgba(0, 0, 0, 0.5);
    border: 1px dashed #754c24;
    padding: 10px;
    border-radius: 6px;
}

.upload-slot label {
    display: block;
    font-size: 9px;
    color: #ffdd44;
    margin-bottom: 6px;
}

.upload-slot input[type="file"] {
    font-size: 8px;
    color: #fff;
    width: 100%;
}

@media (max-width: 768px) {
    body { padding: 6px; }
    .cabinet { padding: 12px; border-width: 6px; }
    .party-roster { grid-template-columns: 1fr; }
    .upload-grid { grid-template-columns: 1fr; }
}
