/* =====================================================
   共通スタイル (style.css)
   車種固有のスタイルは各 theme-*.css ファイルを参照。
   ===================================================== */

:root {
    --bg-color: #1a1a1a;
    --text-color: #f0f0f0;
    --pole-color: #e0e0e0;
    --warning-red: #ff3333;
    --warning-red-dim: #4d0000;
    --cross-buck-yellow: #ffcc00;
    --cross-buck-black: #111;
    --gate-yellow: #ffcc00;
    --gate-black: #111;

    /* デフォルトの電車変数（阪急） */
    --train-body-color: #6b1d28;
    /* 阪急マルーン (より深みのある色に調整) */
    --train-roof-color: #888;
    /* 屋根のグレー */
    --train-window-frame: #d4cfc7;
    /* アイボリー調のフレーム */
    --train-line-color: transparent;
    --train-face-color: #6b1d28;
    --train-ivory: #f5f5f0;
    /* 阪急アイボリー */
}

/* 設定パネル */
.settings-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 8px;
    color: #fff;
    z-index: 100;
}

.settings-panel select {
    margin-left: 5px;
    padding: 5px;
    border-radius: 4px;
    border: none;
    font-size: 1rem;
}

/* 入力表示 */
.input-display {
    position: absolute;
    top: 20px;
    left: 20px;
    font-family: 'Inter', monospace;
    font-size: 2rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 15px;
    border-radius: 8px;
    pointer-events: none;
    min-height: 2.5rem;
    z-index: 100;
    display: flex;
    align-items: center;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
}

.container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

h1 {
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.instruction {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 2rem;
}

/* =====================================================
   踏切の構造
   ===================================================== */
.rail-crossing {
    position: relative;
    width: 300px;
    height: 400px;
    display: flex;
    justify-content: center;
}

.pole {
    position: absolute;
    bottom: 0;
    width: 20px;
    height: 100%;
    /* 黄色と黒の縞模様 */
    background: repeating-linear-gradient(-45deg,
            var(--gate-yellow),
            var(--gate-yellow) 10px,
            var(--gate-black) 10px,
            var(--gate-black) 20px);
    border: 1px solid #000;
    z-index: 2;
}

/* クロスバック（×印） */
.cross-buck {
    position: absolute;
    top: 20px;
    width: 200px;
    height: 100px;
    z-index: 3;
}

.plank {
    position: absolute;
    width: 200px;
    height: 25px;
    /* 黄色と黒の縞模様 */
    background: repeating-linear-gradient(90deg,
            var(--cross-buck-yellow),
            var(--cross-buck-yellow) 20px,
            var(--cross-buck-black) 20px,
            var(--cross-buck-black) 40px);
    border: 2px solid #000;
    top: 37px;
    left: 0;
    transform-origin: center;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
}

.plank.left {
    transform: rotate(45deg);
}

.plank.right {
    transform: rotate(-45deg);
}

/* 警報灯 */
.lights-container {
    position: absolute;
    top: 130px;
    width: 240px;
    height: 80px;
    background-color: #000;
    border-radius: 40px;
    z-index: 4;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    padding: 0 10px;
}

.light-unit {
    position: relative;
    width: 90px;
    height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.light {
    width: 70px;
    height: 70px;
    background-color: var(--warning-red-dim);
    border-radius: 50%;
    transition: background-color 0.1s;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 5;
}

.visor {
    position: absolute;
    top: -10px;
    width: 80px;
    height: 80px;
    border-top: 25px solid #111;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-radius: 50%;
    z-index: 6;
    pointer-events: none;
}

/* 遮断機 */
.gate-container {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-15px);
    z-index: 10;
}

.counterweight {
    width: 40px;
    height: 40px;
    background-color: #333;
    border-radius: 50%;
    border: 2px solid #555;
    position: absolute;
    top: -20px;
    left: -20px;
    z-index: 11;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
}

.gate-arm {
    width: 350px;
    height: 18px;
    background-color: var(--gate-yellow);
    border: 1px solid #000;
    position: absolute;
    top: -9px;
    left: 0;
    transform-origin: 0% 50%;
    transform: rotate(-85deg);
    /* 初期状態は上がっている */
    transition: transform 4s ease-in-out;
    display: flex;
    overflow: hidden;
    box-shadow: 2px 5px 10px rgba(0, 0, 0, 0.3);
}

.stripe {
    width: 50px;
    height: 100%;
    background-color: var(--gate-black);
    margin-left: 50px;
    transform: skewX(-20deg);
}

/* =====================================================
   電車（共通構造）
   ===================================================== */
.train-container {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    height: 200px;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

/* 線路 */
.train-container::before {
    content: '';
    position: absolute;
    bottom: 15px;
    /* 大きな電車に合わせて調整 */
    left: 0;
    width: 100%;
    height: 15px;
    background: #555;
    box-shadow: 0 5px 0 #333;
}

.train-set {
    position: absolute;
    bottom: 25px;
    left: 120%;
    display: flex;
    gap: 5px;
}

.train-car {
    width: 360px;
    height: 160px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: 4px 10px 10px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

/* 連結器（共通） */
.train-car::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 60%;
    width: 5px;
    height: 10px;
    background-color: #333;
    z-index: -1;
}

.train-car:last-child::after {
    display: none;
}

/* 窓（共通） */
.window {
    width: 70px;
    height: 80px;
    background-color: #81D4FA;
    border: 5px solid var(--train-window-frame);
    border-radius: 4px;
    box-sizing: border-box;
    margin-top: 10px;
    position: relative;
    z-index: 2;
}

/* =====================================================
   Sign Box
   ===================================================== */
.sign-box {
    position: absolute;
    top: 230px;
    background-color: #fff;
    border: 3px solid #000;
    padding: 5px 15px;
    z-index: 2;
    transform: rotate(-2deg);
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

.sign-text {
    color: #000;
    font-weight: 900;
    font-size: 1.2rem;
    letter-spacing: 0.1em;
}

/* Status Indicator */
.status-indicator {
    margin-top: 2rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    z-index: 20;
    position: relative;
}

.status-indicator.active {
    background-color: rgba(255, 30, 30, 0.2);
    border: 1px solid var(--warning-red);
}

#status-text {
    font-weight: bold;
    font-size: 1.1rem;
}

/* =====================================================
   アニメーション（共通）
   ===================================================== */

/* Active Animation States */
.active .light.left {
    animation: flashLeft 1s infinite alternate;
}

.active .light.right {
    animation: flashRight 1s infinite alternate;
}

.active .gate-arm {
    transform: rotate(0deg);
    transition-delay: 1s;
}

.gate-arm {
    transition: transform 4s ease-in-out;
}

.train-set.passing {
    animation: trainPass 6s linear forwards;
}

@keyframes trainPass {
    0% {
        left: 120%;
    }

    100% {
        left: -3000px;
    }
}

@keyframes flashLeft {

    0%,
    49% {
        background-color: var(--warning-red);
        box-shadow: 0 0 30px var(--warning-red);
    }

    50%,
    100% {
        background-color: var(--warning-red-dim);
        box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    }
}

@keyframes flashRight {

    0%,
    49% {
        background-color: var(--warning-red-dim);
        box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    }

    50%,
    100% {
        background-color: var(--warning-red);
        box-shadow: 0 0 30px var(--warning-red);
    }
}

/* SL・トーマス共通の車輪・ロッドアニメーション */
@keyframes slWheelTurn {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes slRodMove {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    25% {
        transform: translate(15px, 15px) rotate(-5deg);
    }

    50% {
        transform: translate(30px, 0) rotate(0deg);
    }

    75% {
        transform: translate(15px, -15px) rotate(5deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}