/* ==========================================================================
   PPKA SIMULATOR — KYOSAN K5B VDU & RAIL ROUTE HUD DESIGN SYSTEM
   ========================================================================== */

:root {
    --bg-dark: #090d16;
    --bg-panel: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --border-color: #334155;
    --border-active: #38bdf8;

    --vdu-signal-orange: #ff9900;
    --vdu-route-green: #10b981;
    --vdu-pjl-yellow: #eab308;
    --vdu-switch-blue: #1d4ed8;
    --vdu-power-cyan: #06b6d4;

    --cyan-neon: #38bdf8;
    --emerald-neon: #10b981;
    --amber-neon: #f59e0b;
    --rose-neon: #f43f5e;
    --purple-neon: #a855f7;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --font-mono: 'Share Tech Mono', monospace;
    --font-sans: 'Outfit', sans-serif;
    --font-retro: 'Press Start 2P', cursive;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* SCREEN CONTROLLER */
.screen {
    display: none;
    height: 100vh;
    width: 100vw;
    position: relative;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* SCREEN 1: MAIN MENU & STATION SELECTION */
#screen-menu {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #1e1b4b 0%, #090d16 80%);
    padding: 2rem;
}

.menu-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0.15;
}

.flat-anim-line {
    position: absolute;
    background: var(--cyan-neon);
}
.fl-h1 { top: 20%; left: 0; width: 100%; height: 2px; }
.fl-h2 { top: 50%; left: 0; width: 100%; height: 2px; }
.fl-h3 { top: 80%; left: 0; width: 100%; height: 2px; }

.menu-center {
    z-index: 10;
    max-width: 1100px;
    width: 100%;
    text-align: center;
}

.game-title {
    font-family: var(--font-mono);
    font-size: 3.2rem;
    letter-spacing: 4px;
    color: var(--cyan-neon);
    text-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
    margin-bottom: 0.5rem;
}

.game-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
}

.station-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.station-card {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: left;
    position: relative;
    backdrop-filter: blur(8px);
}

.station-card:hover {
    transform: translateY(-4px);
    border-color: var(--cyan-neon);
    box-shadow: 0 10px 25px rgba(56, 189, 248, 0.15);
    background: rgba(30, 41, 59, 0.9);
}

.station-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 0.8rem;
    font-weight: bold;
}
.station-badge.beginner { background: rgba(16, 185, 129, 0.2); color: var(--emerald-neon); border: 1px solid var(--emerald-neon); }
.station-badge.intermediate { background: rgba(245, 158, 11, 0.2); color: var(--amber-neon); border: 1px solid var(--amber-neon); }
.station-badge.advanced { background: rgba(244, 63, 94, 0.2); color: var(--rose-neon); border: 1px solid var(--rose-neon); }
.station-badge.expert { background: rgba(168, 85, 247, 0.2); color: var(--purple-neon); border: 1px solid var(--purple-neon); }

.station-card h3 {
    font-size: 1.3rem;
    color: var(--text-main);
    margin-bottom: 0.3rem;
}

.station-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.station-meta {
    font-size: 0.8rem;
    color: var(--text-dim);
    border-top: 1px dashed var(--border-color);
    padding-top: 0.8rem;
}

.menu-footer-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-menu-sub {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    transition: background 0.2s;
}

.btn-menu-sub:hover {
    background: var(--bg-card-hover);
    border-color: var(--cyan-neon);
}

/* MAIN GAME HUD */
#screen-game {
    background: var(--bg-dark);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.hud-header {
    height: 60px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.btn-back-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.station-title-block h2 {
    font-size: 1.1rem;
    color: var(--cyan-neon);
    font-family: var(--font-mono);
    margin-bottom: 0.1rem;
}

.hud-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.header-center {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.shift-clock-box {
    text-align: center;
}

.hud-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
    margin-bottom: 0.1rem;
}

.hud-value {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: bold;
}

.text-emerald { color: var(--emerald-neon); }
.text-amber { color: var(--amber-neon); }
.text-rose { color: var(--rose-neon); }

.interlocking-status-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    border: 1px solid var(--emerald-neon);
    color: var(--emerald-neon);
    background: rgba(16, 185, 129, 0.1);
}

.header-right {
    display: flex;
    gap: 1.8rem;
}

.score-metric {
    text-align: right;
}

/* MAIN HUD BODY */
.hud-main-body {
    flex: 1;
    display: flex;
    flex-direction: row;
    height: calc(100vh - 170px);
    width: 100%;
    overflow: hidden;
}

.hud-diagram-container {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #03060c;
    border-right: 1px solid var(--border-color);
    position: relative;
}

.diagram-toolbar {
    height: 36px;
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.legend-items {
    display: flex;
    gap: 1.2rem;
}

.leg-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.leg-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.leg-dot.vdu-route-green { background: var(--vdu-route-green); box-shadow: 0 0 8px var(--vdu-route-green); }
.leg-dot.vdu-signal-orange { background: var(--vdu-signal-orange); box-shadow: 0 0 8px var(--vdu-signal-orange); }
.leg-dot.vdu-switch-darkblue { background: var(--vdu-switch-blue); }
.leg-dot.red { background: var(--rose-neon); }

#svg-viewport-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#track-svg {
    width: 100%;
    height: 100%;
    background: #020408;
}

/* HOVER TOOLTIP OVERLAY */
.vdu-tooltip {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--cyan-neon);
    color: var(--text-main);
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    z-index: 100;
    transition: opacity 0.15s ease;
}

.vdu-tooltip.hidden {
    opacity: 0;
}

/* ALERT BANNER */
.alert-banner {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    background: rgba(244, 63, 94, 0.95);
    color: white;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    box-shadow: 0 5px 20px rgba(244, 63, 94, 0.4);
    z-index: 50;
    transition: all 0.3s ease;
}

.alert-banner.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

/* MIDDLE-RIGHT CONTROL PANEL */
.hud-control-panel {
    width: 360px;
    min-width: 360px;
    max-width: 360px;
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 0.8rem;
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
}

.control-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.8rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.4rem;
    margin-bottom: 0.6rem;
}

.card-header h4 {
    font-size: 0.85rem;
    font-family: var(--font-mono);
    color: var(--cyan-neon);
}

.badge-train-id {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: rgba(56, 189, 248, 0.15);
    color: var(--cyan-neon);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.train-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
}

.detail-label { color: var(--text-muted); }
.detail-val { font-weight: 600; color: var(--text-main); }

.route-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.btn-action {
    width: 100%;
    padding: 0.6rem;
    border-radius: 6px;
    border: none;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-action.primary { background: var(--cyan-neon); color: #0f172a; }
.btn-action.success { background: var(--emerald-neon); color: #0f172a; }
.btn-action:disabled { opacity: 0.4; cursor: not-allowed; }

/* SWITCH BUTTON GRID */
.switch-button-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.switch-btn-item {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.switch-btn-item:hover:not(.locked) {
    border-color: var(--cyan-neon);
}

.switch-btn-item.locked {
    border-color: var(--amber-neon);
    background: rgba(245, 158, 11, 0.05);
    cursor: not-allowed;
}

.switch-pos-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--vdu-switch-blue);
}
.switch-pos-dot.reverse { background: var(--amber-neon); }

/* SIGNAL STATUS LIST */
.signal-status-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 120px;
    overflow-y: auto;
}

.signal-status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    padding: 0.3rem 0.5rem;
    background: var(--bg-panel);
    border-radius: 4px;
}

.aspect-lamp {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}
.aspect-lamp.stop { background: var(--rose-neon); box-shadow: 0 0 8px var(--rose-neon); }
.aspect-lamp.caution { background: var(--vdu-signal-orange); box-shadow: 0 0 8px var(--vdu-signal-orange); }
.aspect-lamp.proceed { background: var(--emerald-neon); box-shadow: 0 0 8px var(--emerald-neon); }

/* BLOCK STATUS GRID */
.block-status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    max-height: 110px;
    overflow-y: auto;
}

.block-status-item {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    background: var(--bg-panel);
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
}

/* FOOTER TRAIN QUEUE BAR */
.hud-footer-bar {
    height: 110px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 0.4rem 1rem;
}

.train-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.btn-toggle-auto {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.train-queue-scroll {
    display: flex;
    gap: 0.8rem;
    overflow-x: auto;
    padding-bottom: 0.4rem;
}

.train-card-item {
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.train-card-item.selected {
    border-color: var(--cyan-neon);
    background: rgba(56, 189, 248, 0.1);
}

.train-card-header {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: bold;
    margin-bottom: 0.2rem;
}

.train-card-body {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* MODAL GUIDES */
.modal-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-width: 650px;
    width: 90%;
    padding: 2rem;
    margin: auto;
}

.modal-card h2 {
    font-family: var(--font-mono);
    color: var(--cyan-neon);
    margin-bottom: 1rem;
}

.modal-content-scroll {
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.modal-content-scroll h3 {
    color: var(--text-main);
    margin-top: 1rem;
    margin-bottom: 0.4rem;
}

.btn-modal-close {
    background: var(--cyan-neon);
    color: #0f172a;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-weight: bold;
    cursor: pointer;
}