/* デザインシステム - TRON MONITOR */
:root {
    --bg-dark: #000205;
    --neon-blue: #00d2ff;
    --neon-green: #00ff88;
    --neon-red: #ff2a6d;
    --neon-orange: #ff8c00;
    --standby-color: rgba(224, 250, 255, 0.1);
    --text-main: #e0faff;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Noto Sans JP', sans-serif;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    /* モニタなので基本スクロールなし */
}

.monitor-wrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

/* ヘッダー */
.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 2px solid var(--neon-blue);
    padding-bottom: 8px;
    margin-bottom: 15px;
}

.monitor-header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    letter-spacing: 4px;
    color: var(--neon-blue);
    text-shadow: 0 0 15px var(--neon-blue);
}

.clock {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    color: var(--neon-blue);
}

/* =========================================================================
   ヘッダー凡例
   ========================================================================= */
.header-legend {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 2px;
    margin-right: auto;
    margin-left: 40px;
    /* タイトルとの間隔 */
}

.legend-ready {
    color: var(--neon-green);
    text-shadow: 0 0 10px var(--neon-green);
}

.legend-error {
    color: var(--neon-red);
    text-shadow: 0 0 10px var(--neon-red);
}

.legend-standby {
    color: #bbbbbb;
    /* 視認性を高めるための明るいグレー */
}

.legend-redirect {
    color: var(--neon-orange);
    text-shadow: 0 0 10px var(--neon-orange);
}

/* バース変更発生アラート */
.berth-change-alert {
    display: none;
    /* 初期状態は非表示 */
    font-size: 1.8vw;
    font-weight: bold;
    color: var(--neon-orange);
    border: 2px solid var(--neon-orange);
    padding: 4px 16px;
    border-radius: 4px;
    background: rgba(255, 140, 0, 0.1);
    box-shadow: 0 0 10px var(--neon-orange), inset 0 0 5px var(--neon-orange);
    text-shadow: 0 0 8px var(--neon-orange);
    animation: alert-blink 1.5s infinite alternate;
    letter-spacing: 2px;
}

@keyframes alert-blink {
    0% {
        opacity: 1;
        box-shadow: 0 0 15px var(--neon-orange), inset 0 0 8px var(--neon-orange);
    }

    100% {
        opacity: 0.4;
        box-shadow: 0 0 5px var(--neon-orange), inset 0 0 2px var(--neon-orange);
    }
}

/* グリッドレイアウト - 画面全体にフィットするように調整 */
.monitor-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    /* 10列 */
    grid-template-rows: repeat(9, minmax(0, 1fr));
    /* 行がコンテンツに合わせて広がらないように固定 */
    gap: 8px;
    min-height: 0;
    /* flex container内で縮小可能にする */
}

/* バースタイル */
.berth-tile {
    background: rgba(0, 30, 50, 0.2);
    border: 1px solid var(--standby-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    transition: all 0.5s ease;
    height: 100%;
    width: 100%;
    min-height: 0;
    /* 文字サイズによって枠が広がらないようにする */
    overflow: hidden;
    /* 万が一、文字がはみ出す場合はカットする */
}

.berth-number {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.4vw;
    /* 元のサイズに戻す（待機中・搬送NG共通） */
    font-weight: bold;
    color: var(--standby-color);
}

/* 背景のブリージング（背景・グロー） */
@keyframes bg-pulse {

    0%,
    100% {
        background: rgba(255, 140, 0, 0.05);
        box-shadow: 0 0 20px rgba(255, 140, 0, 0.2), inset 0 0 15px rgba(255, 140, 0, 0.1);
    }

    50% {
        background: rgba(255, 140, 0, 0.15);
        box-shadow: 0 0 35px rgba(255, 140, 0, 0.4), inset 0 0 25px rgba(255, 140, 0, 0.2);
    }
}

/* 文字のブリージング（テキスト・グロー） */
@keyframes text-pulse {

    0%,
    100% {
        opacity: 1;
        text-shadow: 0 0 4px var(--neon-red);
        /* 極薄：15px -> 4px */
    }

    50% {
        opacity: 0.7;
        /* 不透明度の変化も少しマイルドに（0.6 -> 0.7） */
        text-shadow: 0 0 8px var(--neon-red);
        /* 最大でも 8px */
    }
}

/* 準備完了状態 (Green) */
.berth-tile.is-ready {
    background: rgba(0, 255, 136, 0.05);
    border-color: var(--neon-green);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.2), inset 0 0 15px rgba(0, 255, 136, 0.1);
}

.berth-tile.is-ready .berth-number {
    color: var(--neon-green);
    text-shadow: 0 0 5px var(--neon-green);
    font-size: 3.2vw;
    /* 搬送OKの時は大きく */
    transition: font-size 0.3s ease;
    /* スムーズな拡大縮小 */
}

/* 問題あり状態 (Red) */
.berth-tile.has-error {
    background: rgba(255, 42, 109, 0.05);
    border-color: var(--neon-red);
    box-shadow: 0 0 20px rgba(255, 42, 109, 0.2), inset 0 0 15px rgba(255, 42, 109, 0.1);
}

.berth-tile.has-error .berth-number {
    color: var(--neon-red);
    text-shadow: 0 0 4px var(--neon-red);
    /* font-sizeは.berth-numberのデフォルト（2.4vw）を引き継ぐ */
}

/* リダイレクト状態 (Orange/Yellow) */
.berth-tile.is-redirect {
    background: rgba(255, 140, 0, 0.05);
    border-color: var(--neon-orange);
    box-shadow: 0 0 20px rgba(255, 140, 0, 0.2), inset 0 0 15px rgba(255, 140, 0, 0.1);
    animation: bg-pulse 3s ease-in-out infinite;
    /* 背景を明滅 */
}

.berth-tile.is-redirect .redirect-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.berth-tile.is-redirect .original-id {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2vw;
    /* 元の番号を小さめ */
    color: rgba(255, 140, 0, 0.5);
    margin-bottom: -4px;
}


.berth-tile.is-redirect .destination-id {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.2vw;
    /* 変更後の番号を大きめ（OKと同じか少し大きい程度） */
    font-weight: bold;
    color: var(--standby-color);
    text-shadow: 0 0 2px rgba(224, 250, 255, 0.2);
    line-height: 0.9;
}

.berth-tile.is-redirect .destination-id.status-ready {
    color: var(--neon-green);
    text-shadow: 0 0 5px var(--neon-green);
    /* 15px -> 5px */
}

.berth-tile.is-redirect .destination-id.status-error {
    color: var(--neon-red);
    text-shadow: 0 0 4px var(--neon-red);
    /* 15px -> 4px */
    animation: text-pulse 2s ease-in-out infinite;
    /* 文字を明滅 */
}

/* =========================================================================
   フッター (スクロールメッセージエリア)
   ========================================================================= */
.monitor-message-footer {
    height: 8vh;
    min-height: 60px;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    /* 常に確保 */
    align-items: center;
    overflow: hidden;
    /* はみ出したテキストを隠す */
    margin-top: 8px;
    /* グリッドとの間隔 */
}

.marquee-content {
    white-space: nowrap;
    will-change: transform;
    animation: marquee 35s linear infinite;
    display: none;
    align-items: center;
}

.marquee-content span {
    font-size: 5.5vh;
    font-weight: bold;
    color: var(--neon-orange);
    letter-spacing: 4px;
    line-height: 1;
    padding-bottom: 2px;
}

@keyframes intense-pulse {
    0% {
        opacity: 0.7;
        text-shadow: 0 0 2px var(--neon-orange);
    }

    /* ブラーを小さく、範囲を狭く */
    100% {
        opacity: 1;
        text-shadow: 0 0 10px var(--neon-orange), 0 0 2px #fff;
    }
}

@keyframes marquee {
    0% {
        transform: translateX(100vw);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* 削除済みの .footer-legend や .legend-item クラスは後方互換で残すか消すか自由だが、使わないので消す */

/* フッター */
.monitor-footer {
    padding-top: 10px;
    border-top: 1px solid rgba(0, 210, 255, 0.2);
    margin-top: 10px;
}

.footer-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    /* Reduced gap since boxes are wider */
    padding: 15px;
    /* Added padding to give room for boxes */
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: bold;
    padding: 5px 15px;
    border: 1px solid var(--dim-text);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.7);
    /* Standard background for items */
}

.legend-item .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-item:nth-child(1) {
    /* 搬送OK */
    border-color: var(--neon-green);
    color: var(--bright-text);
}

.legend-item:nth-child(1) .status-dot {
    background: var(--neon-green);
    box-shadow: 0 0 5px var(--neon-green);
}

.legend-item:nth-child(2) {
    /* 搬送NG */
    border-color: var(--neon-pink);
    color: var(--bright-text);
}

.legend-item:nth-child(2) .status-dot {
    background: var(--neon-pink);
    box-shadow: 0 0 5px var(--neon-pink);
}

.legend-item:nth-child(3) {
    /* 待機中 */
    border-color: var(--dim-text);
    color: var(--dim-text);
}

.legend-item:nth-child(3) .status-dot {
    border: 1px solid var(--dim-text);
    background: transparent;
}

.legend-item:nth-child(4) {
    /* バース変更 */
    border-color: var(--neon-orange);
    color: var(--bright-text);
}

.legend-item:nth-child(4) .status-dot {
    background: var(--neon-orange);
    box-shadow: 0 0 5px var(--neon-orange);
}

/* レスポンシブ調整 - スクリーン自体が小さくなった場合のみ */
@media (max-height: 600px) {
    .monitor-grid {
        gap: 4px;
    }

    .monitor-header h1 {
        font-size: 18px;
    }
}

/* システムインフォパネル (右下) */
.system-info {
    grid-column: span 6;
    background: rgba(0, 210, 255, 0.05);
    border: 1px solid rgba(0, 210, 255, 0.1);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    padding-right: 25px;
    position: relative;
    overflow: hidden;
}

.system-info::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--neon-blue);
    box-shadow: 0 0 10px var(--neon-blue);
}

.info-wave {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.2vw;
    font-weight: bold;
    color: var(--neon-blue);
    text-shadow: 0 0 15px var(--neon-blue);
    letter-spacing: 6px;
    line-height: 0.85;
}

.info-system-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.0vw;
    color: var(--dim-text);
    /* Changed from neon-blue to dim-text */
    opacity: 0.5;
    /* Reduced opacity */
    text-align: right;
    line-height: 1.2;
    margin-bottom: 2px;
}

/* 縦並び凡例 (右下システムインフォ内) */
.vertical-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 15px;
    border-left: 1px solid rgba(0, 210, 255, 0.2);
}

.vertical-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: bold;
    color: var(--bright-text);
}

.vertical-legend-item .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.vertical-legend-item .dot-ready {
    background: var(--neon-green);
    box-shadow: 0 0 5px var(--neon-green);
}

.vertical-legend-item .dot-error {
    background: var(--neon-pink);
    box-shadow: 0 0 5px var(--neon-pink);
}

.vertical-legend-item .dot-standby {
    border: 1px solid var(--dim-text);
    background: transparent;
}

.vertical-legend-item .dot-redirect {
    background: var(--neon-orange);
    box-shadow: 0 0 5px var(--neon-orange);
}