:root {
    --bg-0: #05060a;
    --bg-1: #0b0e16;
    --panel: rgba(14, 18, 28, 0.78);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text: #e9ecf3;
    --text-dim: #9aa3b2;
    --accent: #7cc4ff;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-0);
    color: var(--text);
    font-family: 'Inter', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

#canvas-container {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 50% 60%, #131826 0%, #06070b 70%, #030407 100%);
}

canvas {
    display: block;
    outline: none;
}

.overlay {
    position: fixed;
    background: var(--panel);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    z-index: 10;
    pointer-events: auto;
}

.top-left { top: 20px; left: 20px; }
.top-right { top: 20px; right: 20px; width: 280px; max-height: calc(100vh - 40px); overflow-y: auto; }
.bottom-left { bottom: 20px; left: 20px; }
.bottom-right { bottom: 20px; right: 20px; width: 280px; min-height: 60px; }

.title .kanji {
    display: block;
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.2em;
    color: var(--accent);
    opacity: 0.85;
    margin-bottom: 4px;
}

.title h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.title .subtitle {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
}

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

.legend-header h2 {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.ghost-btn {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.ghost-btn:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.25);
}

.legend-section {
    margin-bottom: 14px;
}

.legend-section:last-child { margin-bottom: 0; }

.legend-section-title {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 8px;
    padding-left: 4px;
}

#legend ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.line-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
    user-select: none;
}

.line-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.line-item.disabled {
    opacity: 0.35;
}

.line-letter {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.25);
}

.line-name {
    font-size: 13px;
    font-weight: 500;
    flex: 1;
}

.line-name-jp {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 11px;
    color: var(--text-dim);
}

.controls-hint {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dim);
    padding: 12px 14px;
}

.controls-hint .key {
    display: inline-block;
    background: rgba(255,255,255,0.06);
    color: var(--text);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 8px;
    border: 1px solid var(--panel-border);
    min-width: 60px;
    text-align: center;
}

#info-panel .info-empty {
    color: var(--text-dim);
    font-size: 12px;
    text-align: center;
    padding: 14px 0;
}

.station-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.station-info .station-name-en {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.station-info .station-name-jp {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 13px;
    color: var(--text-dim);
    margin-top: -4px;
}

.station-info .station-lines {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.station-info .line-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.04);
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    font-size: 11px;
}

.station-info .line-tag .dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    color: white;
    font-weight: 700;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tooltip {
    position: fixed;
    z-index: 20;
    background: rgba(8, 10, 16, 0.95);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(8px);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
    transform: translate(-50%, calc(-100% - 12px));
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.tooltip .jp {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 10px;
    color: var(--text-dim);
    display: block;
    margin-top: 1px;
}

#loader {
    position: fixed;
    inset: 0;
    background: var(--bg-0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.6s ease;
}

#loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-dim);
    font-size: 13px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255,255,255,0.08);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 720px) {
    .top-right { width: calc(100vw - 40px); max-height: 38vh; }
    .bottom-right { display: none; }
    .bottom-left { font-size: 11px; padding: 8px 10px; }
    .top-left .title h1 { font-size: 16px; }
}
