:root {
    --bg-color-a: #f8fafc;
    --bg-color-b: #f0fdf4;
    --card-bg: rgba(255, 255, 255, 0.7);
    --accent-color: #4f46e5;
    --secondary-accent: #059669;
    --text-color: #0f172a;
    --text-secondary: #475569;
    --danger-color: #e11d48;
    --success-color: #10b981;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-soft:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06),
        0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-elevated:
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --safe-area-inset-top: env(safe-area-inset-top, 0px);

    /* Premium Shadow Color (not pure black) */
    --shadow-color: rgba(79, 70, 229, 0.15);

    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

[x-cloak] {
    display: none !important;
}

body {
    background-color: var(--bg-color-a);
    background-image:
        radial-gradient(circle at 2px 2px, rgba(79, 70, 229, 0.05) 1px, transparent 0),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    background-size: 32px 32px, 150px 150px;
    background-blend-mode: normal, overlay;
    color: var(--text-color);
    font-family: 'Noto Sans JP', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
    transition: background-color 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    position: relative;
}

body.player-b-active {
    background-color: var(--bg-color-b);
}

#app {
    width: 100%;
    max-width: 500px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100dvh;
    justify-content: flex-start;
    padding-top: calc(var(--safe-area-inset-top) + 20px);
    overflow: hidden;
}

@media (min-width: 851px) {
    #app {
        max-width: 900px;
        display: grid;
        grid-template-columns: 1.2fr 300px;
        height: auto;
        overflow: visible;
    }
}

@media (max-width: 850px) {
    body {
        align-items: flex-start;
        overflow-y: auto;
    }

    #app {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    .history-box {
        max-height: 300px;
    }

    .main-panel .logo {
        font-size: 1.2rem;
        margin-top: 5px;
        margin-bottom: 10px;
    }

    .timer-wrapper {
        position: sticky;
        top: 0;
        z-index: 50;
        background: var(--card-bg);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        margin: 0 -25px;
        padding: 8px 25px;
        border-bottom: 1px solid var(--border-color);
    }
}

.main-panel {
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-lg);
    /* 8px -> 24px */
    padding: 30px;
    box-shadow: 0 8px 32px 0 var(--shadow-color);
    border: 1px solid rgba(255, 255, 255, 0.4);
    position: relative;
    z-index: 10;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    transition: all 0.3s ease;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.logo {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 2.8rem;
    font-weight: 900;
    margin-bottom: 2rem;
    text-align: center;
    background: linear-gradient(135deg, #5c67f2 0%, #818cf8 40%, #10b981 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 10px;
    filter: drop-shadow(0 4px 12px rgba(92, 103, 242, 0.25));
}

.turn-indicator {
    position: absolute;
    top: -13px;
    left: 25px;
    padding: 6px 20px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.72rem;
    color: #fff;
    background: linear-gradient(135deg, #5c67f2, #818cf8);
    box-shadow: 0 4px 14px rgba(92, 103, 242, 0.45);
    z-index: 10;
    letter-spacing: 1.5px;
}

.info-section {
    text-align: center;
    margin: 0.5rem 0;
    /* 1remから縮小 */
    background: rgba(248, 250, 252, 0.5);
    padding: 12px 20px;
    /* 20pxから縦を縮小 */
    border-radius: var(--radius-sm);
    /* 4px -> 8px */
    border: 1px solid var(--border-color);
}

.label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 1.5px;
    margin-bottom: 0.8rem;
    display: block;
}

.current-station {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.station-name-tag {
    background: #fff;
    color: #0f172a;
    padding: 8px 16px;
    border: 3px solid #0f172a;
    border-radius: 4px;
    /* 2px -> 4px */
    position: relative;
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    box-shadow:
        0 12px 24px rgba(0, 0, 0, 0.1),
        0 4px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 320px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    white-space: normal;
    /* Allow wrapping */
    text-align: center;
    line-height: 1.1;
    /* Tighter line height for multi-line */
    text-wrap: balance;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.station-name-tag.text-md {
    font-size: 2.2rem;
}

.station-name-tag.text-sm {
    font-size: 1.8rem;
}

.station-name-tag.text-xs {
    font-size: 1.4rem;
}

.station-name-tag::before,
.station-name-tag::after {
    content: '';
    position: absolute;
    left: -3.5px;
    right: -3.5px;
    height: 9px;
    background: #00a651;
}

.station-name-tag::before {
    top: 0;
}

.station-name-tag::after {
    bottom: 0;
}

.station-name-reading {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 2px;
    letter-spacing: 0.05em;
}

.station-prefecture {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

.line-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.line-badge {
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
    background: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.15s ease;
    outline: none;
}

.line-badge:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(92, 103, 242, 0.2);
}

.line-badge.selected {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(92, 103, 242, 0.35);
}

.line-badge.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

.input-wrapper input {
    width: 100%;
    padding-right: 44px;
}

#clear-input-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    z-index: 5;
}

#clear-input-btn:hover {
    background: #e2e8f0;
    color: var(--danger-color);
}

#clear-input-btn .material-icons {
    font-size: 18px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    /* 4px -> 8px */
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.autocomplete-dropdown.open {
    display: block;
}

.autocomplete-item {
    padding: 12px 16px;
    font-size: 0.95rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background: #f0f2ff;
    border-left: 3px solid var(--accent-color);
    padding-left: 13px;
    /* Adjust for border */
}

.candidate-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 10px;
    padding: 0;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.candidate-item {
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
    border-radius: 0;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    color: var(--text-color);
}

.candidate-item:last-child {
    border-bottom: none;
}

.candidate-item:hover {
    background: #f8fafc;
    color: var(--accent-color);
    transform: none;
}

.candidate-item::before {
    content: 'location_on';
    font-family: 'Material Icons';
    margin-right: 10px;
    font-size: 18px;
    color: var(--text-secondary);
}

.candidate-item:hover::before {
    color: var(--accent-color);
}

select,
input {
    background: #fff;
    border: 2px solid var(--border-color);
    color: var(--text-color);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    /* 4px -> 8px */
    font-size: 0.95rem;
    font-weight: 500;
    outline: none;
    transition: all 0.3s ease;
    width: 100%;
}

select:focus,
input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(92, 103, 242, 0.1);
}

.btn-action {
    background: linear-gradient(135deg, var(--accent-color), #6366f1);
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: var(--radius-md);
    /* 4px -> 16px */
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px var(--shadow-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-action:active {
    transform: scale(0.96);
    filter: brightness(0.9);
}

.btn-action:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
    box-shadow: 0 8px 24px var(--shadow-color);
}

.move-error {
    color: var(--danger-color);
    font-size: 0.85rem;
    font-weight: 500;
    min-height: 1.2em;
    padding: 0 4px;
}

.timer-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

/* Grouped Timers Row */
.game-timers-row {
    display: flex;
    align-items: flex-end;
    /* Align to bottom so labels stay top */
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 0;
    margin-top: -10px;
}

.timer-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timer-column.global {
    flex: 2;
}

.timer-column.turn {
    flex: 1;
}

.timer-label-tiny {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 700;
    margin-left: 2px;
    letter-spacing: 0.02em;
}

/* Global Timer: Green Bar Style */
.global-timer-bar-container {
    display: flex;
    align-items: center;
    gap: 4px;
    /* Reduced gap */
    background: transparent;
    padding: 0;
}

.global-timer-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    /* Slightly smaller */
}

.global-timer-icon .material-icons {
    font-size: 24px;
    /* Smaller */
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
}

.global-timer-icon.left {
    color: #fbbf24;
}

/* Moon color */
.global-timer-icon.right {
    color: #f59e0b;
}

/* Sun color */

.global-timer-gauge-wrapper {
    flex-grow: 1;
    height: 30px;
    /* Smaller height */
    background: #e2e8f0;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    border: 2px solid #64748b;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.global-timer-gauge-fill {
    height: 100%;
    background: linear-gradient(90deg, #86efac, #22c55e);
    /* Light green to Green */
    width: 100%;
    transition: width 1s linear;
}

.global-timer-text-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    /* Smaller font */
    color: #1e293b;
    /* Dark text for contrast on green */
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
    letter-spacing: 0.05em;
    z-index: 2;
}


/* Turn Timer: Digital Board Style */
.digital-board-style {
    display: flex;
    align-items: center;
}

.digital-timer-display {
    background: #1e293b;
    /* Dark background */
    width: 100%;
    height: 30px;
    /* Same height as global timer bar */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 2px solid #334155;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.digital-timer-display span {
    font-family: 'Orbitron', monospace;
    font-size: 1.4rem;
    /* Smaller font */
    font-weight: 700;
    color: #4ade80;
    /* Bright Green */
    text-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
    display: block;
    line-height: 1;
}

/* Danger State (Siren effect) */
.digital-timer-display.danger {
    border-color: #ef4444;
    animation: borderFlash 0.5s infinite alternate;
}

.digital-timer-display.danger span {
    color: #ef4444;
    text-shadow: 0 0 12px rgba(239, 68, 68, 0.8);
    animation: textFlash 0.2s infinite alternate;
}

@keyframes borderFlash {
    from {
        box-shadow: 0 0 2px rgba(239, 68, 68, 0.2);
    }

    to {
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    }
}

@keyframes textFlash {
    from {
        opacity: 1;
    }

    to {
        opacity: 0.7;
    }
}

/* Reusing timer-danger for red flashing */
.timer-danger {
    background: linear-gradient(90deg, #ef4444, #b91c1c) !important;
    animation: timerPulse 0.5s ease-in-out infinite !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.6) !important;
}




/* Result history list */
.result-history {
    margin: 16px 0 0;
}

.result-history-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    padding: 0 2px;
}

.result-history-list {
    max-height: 160px;
    overflow-y: auto;
    list-style: none;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 0.8rem;
    color: var(--text-color);
    margin: 0;
}

.result-history-list li {
    padding: 4px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 6px;
}

.result-history-list li:last-child {
    border-bottom: none;
}

.result-history-num {
    color: var(--text-secondary);
    min-width: 22px;
    font-size: 0.74rem;
}

.timer-container {
    flex-grow: 1;
    height: 14px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 7px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

#timer-bar {
    height: 100%;
    width: 100%;
    background: var(--success-color);
    transition: width 1s linear, background-color 0.3s ease;
    box-shadow: 0 0 10px rgba(72, 187, 120, 0.3);
}

.timer-success {
    background: var(--success-color) !important;
    box-shadow: 0 0 10px rgba(72, 187, 120, 0.3) !important;
}

.timer-warning {
    background: #fbbf24 !important;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.3) !important;
}

.timer-danger {
    background: var(--danger-color) !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5) !important;
    animation: timerPulse 0.5s ease-in-out infinite !important;
}

@keyframes timerPulse {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 22px rgba(239, 68, 68, 0.8);
    }
}

.timer-text-box {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-color);
    min-width: 44px;
    text-align: right;
    letter-spacing: -0.02em;
}

.history-box {
    background: var(--card-bg);
    border-radius: 6px;
    border-radius: var(--radius-sm);
    /* 6px -> 8px */
    padding: 24px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    max-height: 400px;
}

.history-list {
    list-style: none;
    overflow-y: auto;
    margin-top: 10px;
    position: relative;
    padding-left: 20px;
    /* Space for timeline line */
}

/* Vertical line for timeline */
.history-list::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: #e0e7ff;
}

.history-item {
    position: relative;
    padding-bottom: 12px;
    padding-left: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item:last-child {
    padding-bottom: 0;
}

/* Bullet point for timeline */
.history-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -20px;
    /* Align with parent line */
    width: 16px;
    height: 16px;
    background: #fff;
    border: 4px solid var(--accent-color);
    border-radius: 50%;
    z-index: 2;
}

.history-item.player-b-item::before {
    border-color: var(--secondary-accent);
}

.history-item.warp-item::before {
    border-color: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.history-item.player-b-item {
    border-left-color: var(--secondary-accent);
}

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

.history-header span:first-child {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.history-header span:last-child {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
}

.history-item>div:last-child {
    font-size: 0.875rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.4;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
    visibility: hidden;
    opacity: 0;
    transition: all 0.4s ease;
}

.modal.active {
    visibility: visible;
    opacity: 1;
}

.modal-content {
    position: relative;
    background: #fff;
    padding: 50px;
    border-radius: var(--radius-lg);
    /* 8px -> 24px */
    text-align: center;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--border-color);
}

.btn-back-topleft {
    position: absolute;
    top: 20px;
    left: 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}

.btn-back-topleft:hover {
    background: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
    transform: translateX(-2px);
}

.modal-title {
    color: #000;
    font-size: 2rem;
    margin-bottom: 1rem;
    font-weight: 700;
    text-align: center;
}

.game-over-desc {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
}

.animate-pop {
    animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Give Up Button */
.btn-give-up {
    background: none;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: var(--radius-md);
    /* 4px -> 12px */
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-give-up:hover {
    background: #fff0f0;
    color: var(--danger-color);
    border-color: var(--danger-color);
}

/* Warp Button */
.btn-warp {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: var(--radius-md);
    /* 4px -> 12px */
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

.btn-warp:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4);
}

.btn-warp:disabled {
    background: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
    box-shadow: none;
}

/* Warp Overlay */
#warp-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#warp-overlay.active {
    display: flex;
    opacity: 1;
}

.warp-content {
    position: relative;
    text-align: center;
    padding: 40px 32px;
    background: #fff;
    border-radius: var(--radius-lg);
    /* 8px -> 24px */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.12);
    border: 2px solid var(--border-color);
    max-width: 380px;
    width: 90%;
}

.warp-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 24px;
    margin-bottom: 0.4rem;
    color: var(--text-color);
}

.warp-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.8rem;
}

.warp-prefectures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.warp-prefecture-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    padding: 20px 12px;
    border-radius: var(--radius-md);
    /* 4px -> 12px */
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.warp-prefecture-btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.45);
    filter: brightness(1.1);
}

.history-item.warp-item {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

/* Mode Select */
.mode-select {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 340px;
}

.mode-section {
    width: 100%;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mode-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: left;
    margin-bottom: 8px;
    padding-left: 4px;
    letter-spacing: 0.5px;
}

.mode-divider {
    height: 1px;
    background: var(--border-color);
    margin: 10px 0;
    width: 100%;
}

.mode-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 10px;
}

.btn-mode {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 12px 20px;
    font-size: 1.05rem;
    text-align: center;
}

.btn-info-circle {
    width: 48px;
    background: #fff;
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    /* 4px -> 8px */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-info-circle:hover {
    background: #f8fafc;
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.btn-local {
    background: linear-gradient(135deg, #1e3a8a, #1e40af);
    /* ネイビー */
}

.btn-online-mode {
    background: linear-gradient(135deg, #10b981, #059669);
    /* グリーン */
}

.btn-cpu {
    background: linear-gradient(135deg, #718096, #4a5568);
    /* グレー */
}

.mode-desc {
    font-size: 0.72rem;
    font-weight: 400;
    opacity: 0.85;
}

/* NEW DETAILED BUTTONS */
.btn-mode-detailed {
    display: flex;
    align-items: flex-start;
    padding: 20px;
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid #f1f5f9;
    box-shadow: 0 2px 10px -3px rgba(0, 0, 0, 0.02);
    transition: all 0.3s ease;
    text-align: left;
    width: 100%;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    text-decoration: none;
}

.btn-mode-detailed:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
    border-color: #e0e7ff;
    transform: translateY(-2px);
}

.btn-mode-icon-box {
    width: 48px;
    height: 48px;
    background: #eef2ff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    flex-shrink: 0;
    transition: all 0.3s;
}

.btn-mode-detailed:hover .btn-mode-icon-box {
    background: var(--accent-color);
}

.btn-mode-detailed:hover .btn-mode-icon-box .material-icons {
    color: #fff;
}

.btn-mode-icon-box .material-icons {
    font-size: 24px;
    color: var(--accent-color);
    transition: color 0.3s;
}

/* CPU対戦ボタン - グレー */
#cpu-btn .btn-mode-icon-box {
    background: #f1f5f9;
}

#cpu-btn .btn-mode-icon-box .material-icons {
    color: #64748b;
}

#cpu-btn:hover .btn-mode-icon-box {
    background: #64748b;
}

#cpu-btn:hover .btn-mode-icon-box .material-icons {
    color: #fff;
}

/* ローカル対戦ボタン - ネイビー */
#local-btn .btn-mode-icon-box {
    background: #dbeafe;
}

#local-btn .btn-mode-icon-box .material-icons {
    color: #1e40af;
}

#local-btn:hover .btn-mode-icon-box {
    background: #1e40af;
}

#local-btn:hover .btn-mode-icon-box .material-icons {
    color: #fff;
}

/* リモート対戦ボタン - グリーン */
#online-btn .btn-mode-icon-box {
    background: #d1fae5;
}

#online-btn .btn-mode-icon-box .material-icons {
    color: #059669;
}

#online-btn:hover .btn-mode-icon-box {
    background: #059669;
}

#online-btn:hover .btn-mode-icon-box .material-icons {
    color: #fff;
}

/* 部屋を作るボタン - グリーン */
#create-room-btn .btn-mode-icon-box {
    background: #d1fae5;
}

#create-room-btn .btn-mode-icon-box .material-icons {
    color: #059669;
}

#create-room-btn:hover .btn-mode-icon-box {
    background: #059669;
}

#create-room-btn:hover .btn-mode-icon-box .material-icons {
    color: #fff;
}

.btn-mode-content {
    flex: 1;
}

.btn-mode-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 2px;
    display: block;
}

.btn-mode-subtitle {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
    line-height: 1.4;
    display: block;
}

.btn-mode-info-icon {
    color: #cbd5e1;
    transition: color 0.3s;
    margin-left: 8px;
    flex-shrink: 0;
}

.btn-mode-info-icon .material-icons {
    font-size: 20px;
}

.btn-mode-detailed:hover .btn-mode-info-icon {
    color: var(--accent-color);
}

/* Online Lobby Modal */
.lobby-content {
    max-width: 380px;
    width: 92%;
    padding: 36px;
}

.lobby-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 24px;
}

.divider-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.join-row {
    display: flex;
    gap: 10px;
}

.room-code-input {
    flex: 1;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 6px;
    font-weight: 700;
    outline: none;
    transition: all 0.2s ease;
    background: #f8fafc;
}

.room-code-input:focus {
    border-color: var(--accent-color);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Waiting Room Modal */
.waiting-content {
    max-width: 380px;
    width: 92%;
    padding: 36px;
    text-align: center;
}

.waiting-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 700;
}

.room-code-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

.room-code-display {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 12px;
    color: var(--accent-color);
    background: #f0f4ff;
    border-radius: var(--radius-sm);
    /* 4px -> 8px */
    padding: 14px 48px 14px 20px;
    margin: 10px 0;
    width: 100%;
    box-sizing: border-box;
}

#copy-room-code-btn {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--accent-color);
    opacity: 0.55;
    transition: opacity 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 5px;
}

#copy-room-code-btn:hover {
    opacity: 1;
    color: var(--accent-color);
}

#copy-room-code-btn.copied {
    opacity: 1;
    color: #10b981;
}

.btn-line-invite {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    padding: 13px 0;
    background: #06c755;
    color: #fff;
    border: none;
    border-radius: 4px;
    /* 14px -> 4px */
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 16px;
    transition: opacity 0.15s;
    letter-spacing: 0.02em;
}

.btn-line-invite:hover {
    opacity: 0.88;
}

.waiting-status {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 8px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 16px auto 0;
}

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

/* Online Indicator */
.online-indicator {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 4px;
    /* 10px -> 4px */
    background: #f0f4ff;
    margin-bottom: 8px;
    color: var(--accent-color);
}

/* Opponent turn overlay */
/* Opponent turn overlay */
#opponent-turn-overlay {
    display: flex;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    /* 32px -> 8px */
    z-index: 2000;
    cursor: wait;
    justify-content: center;
    align-items: flex-start;
    padding-top: 22vh;
    /* Use viewport height for better positioning relative to timer */
    pointer-events: auto;
}

#opponent-status-text {
    background: rgba(51, 65, 85, 0.9);
    /* Dark slate background */
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 50px;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Start Screen */
#start-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-color-a);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
}

.start-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Site Header */
.site-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.site-header-logo {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 900;
    font-size: 1.15rem;
    background: linear-gradient(135deg, var(--accent-color), var(--secondary-accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 4px;
}

#app-logo {
    cursor: pointer;
    user-select: none;
}

.site-header-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Site Footer */
.site-footer {
    width: 100%;
    padding: 14px 24px;
    border-top: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.site-footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 4px;
}

.site-footer-links a {
    font-size: 0.75rem;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.site-footer-links a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.site-footer-copy {
    font-size: 0.68rem;
    color: var(--text-secondary);
}

.start-logo {
    font-size: 4rem;
    font-weight: 900;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--accent-color), var(--secondary-accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 12px;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.05));
}

/* Turn Change Overlay */
#turn-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 2500;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#turn-overlay.active {
    display: flex;
    opacity: 1;
}

.turn-message {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--text-color);
}

@keyframes slideFade {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-slide-up {
    animation: slideFade 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

#loading-overlay {
    position: fixed;
    inset: 0;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 4000;
}

/* Attribution Footer (legacy - kept for compatibility) */
.footer {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

/* site-header / site-footer inside #app: span full grid width */
#app>.site-header,
#app>.site-footer {
    grid-column: 1 / -1;
}

/* Game stats bar */
.game-stats-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    padding: 0 4px;
}

#turn-count-display {
    margin-right: auto;
}

.fault-label {
    color: var(--text-secondary);
}

.fault-player {
    padding: 1px 6px;
    border-radius: 4px;
    /* 10px -> 4px */
    font-size: 0.74rem;
}

.fault-a {
    background: rgba(92, 103, 242, 0.12);
    color: var(--accent-color);
}

.fault-b {
    background: rgba(16, 185, 129, 0.12);
    color: var(--secondary-accent);
}

.fault-player.danger {
    background: rgba(245, 101, 101, 0.15);
    color: var(--danger-color);
}

/* Score bar */
.score-bar {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 12px;
    padding: 0 4px;
}

.score-bar .score-player {
    display: flex;
    align-items: center;
    gap: 6px;
}

.score-bar .score-label {
    color: var(--text-secondary);
}

.score-bar .score-value {
    font-size: 1rem;
    font-weight: 900;
}

.score-bar .score-value.player-a {
    color: var(--accent-color);
}

.score-bar .score-value.player-b {
    color: var(--secondary-accent);
}

/* Mission badge */
.mission-badge {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 5px 12px;
    margin-bottom: 8px;
    border-radius: 4px;
    /* 20px -> 4px */
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.05));
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #f59e0b;
}

.mission-badge.cleared {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
    border-color: rgba(16, 185, 129, 0.4);
    color: #10b981;
}

/* Point popup */
.point-popup {
    position: fixed;
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--accent-color);
    pointer-events: none;
    z-index: 9999;
    animation: pointFloat 1.2s ease forwards;
}

@keyframes pointFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-60px) scale(1.2);
    }
}

/* Result score section */
.result-score-section {
    display: flex;
    gap: 16px;
    margin: 16px 0;
    justify-content: center;
}

.result-score-item {
    flex: 1;
    max-width: 140px;
    background: #f8fafc;
    border-radius: 4px;
    /* 14px -> 4px */
    padding: 14px 16px;
    text-align: center;
    border: 2px solid var(--border-color);
}

.result-score-item.winner {
    background: #fffbeb;
    border-color: #f59e0b;
}

.result-score-player {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
    letter-spacing: 1px;
}

.result-score-value {
    font-size: 1.6rem;
    font-weight: 900;
}

.result-score-value.player-a {
    color: var(--accent-color);
}

.result-score-value.player-b {
    color: var(--secondary-accent);
}

.winner-crown {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 2px;
}

/* Result buttons */
.result-buttons {
    display: flex;
    gap: 10px;
    margin: 14px 0 6px;
}

/* Share buttons */
.share-buttons {
    display: flex;
    gap: 10px;
    margin: 14px 0 6px;
}

.share-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 14px 0 6px;
}

.share-divider::before,
.share-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #000;
}

.share-divider span {
    padding: 0 12px;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.75rem;
}

.btn-share {
    flex: 1;
    padding: 10px 8px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-share:hover {
    opacity: 0.85;
}

.btn-share-url {
    background: var(--accent-color, #5c67f2);
    color: #fff;
}

.btn-share-url.copied {
    background: #10b981;
}

.btn-share-x {
    background: #000;
    color: #fff;
}

.btn-share-line {
    background: #06c755;
    color: #fff;
}

.btn-share .material-icons {
    font-size: 1.1rem;
}

.share-icon-x,
.share-icon-line {
    font-weight: 700;
    font-size: 1rem;
}

/* Map expand button */
.result-map-wrapper {
    position: relative;
}

.btn-expand-map {
    position: absolute;
    bottom: 28px;
    right: 10px;
    z-index: 400;
    width: 36px;
    height: 36px;
    background: rgba(30, 30, 50, 0.75);
    border: none;
    border-radius: 2px;
    /* 8px -> 2px */
    font-size: 1.2rem;
    line-height: 1;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    padding: 0;
}

.btn-expand-map:hover {
    background: rgba(92, 103, 242, 0.9);
}

/* Fullscreen map overlay */
.map-fullscreen-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 20000;
    flex-direction: column;
}

.map-fullscreen-overlay.active {
    display: flex;
}

.btn-close-map {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 20001;
    padding: 8px 18px;
    background: #fff;
    border: none;
    border-radius: 4px;
    /* 10px -> 4px */
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

#map-fullscreen-inner {
    flex: 1;
    width: 100%;
}


/* Result screen */
.result-content {
    max-width: 520px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 36px;
    background: #fff;
    border-radius: 8px;
    /* 40px -> 8px */
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--border-color);
}

/* Score breakdown table */
.score-breakdown {
    margin: 12px 0 4px;
}

.score-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.score-breakdown-table thead th {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 12px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.score-breakdown-table th.breakdown-col-a {
    color: var(--accent-color);
}

.score-breakdown-table th.breakdown-col-b {
    color: var(--secondary-accent);
}

.score-breakdown-table tbody td {
    padding: 4px 12px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
}

.score-breakdown-table tbody td:first-child {
    text-align: left;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.score-breakdown-table .breakdown-bonus {
    color: #10b981;
    font-weight: 600;
}

.result-stats {
    display: flex;
    gap: 16px;
    margin: 16px 0;
    justify-content: center;
}

.stat-item {
    background: #f8fafc;
    border-radius: 4px;
    /* 14px -> 4px */
    padding: 12px 20px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-color);
}

/* Toast notification */
.toast-notification {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    padding: 14px 28px;
    border-radius: 4px;
    /* 16px -> 4px */
    font-size: 0.9rem;
    font-weight: 700;
    z-index: 30000;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
    transition: top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 90%;
    text-align: center;
    pointer-events: none;
}

.toast-notification.show {
    top: 24px;
}

/* Rematch button */
.btn-rematch {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    margin-bottom: 8px;
}

.btn-rematch:hover {
    filter: brightness(1.1);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3) !important;
}

.btn-rematch:disabled {
    background: var(--border-color) !important;
    color: var(--text-secondary) !important;
    cursor: not-allowed;
    box-shadow: none !important;
}

/* CPU難易度選択モーダル */
.cpu-difficulty-title {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    margin-top: 24px;
    margin-bottom: 20px;
    color: var(--text-color);
}

.cpu-difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

/* CPU難易度ボタン - かんたん */
.btn-easy .btn-mode-icon-box {
    background: #d1fae5;
}

.btn-easy .btn-mode-icon-box .material-icons {
    color: #059669;
}

.btn-easy:hover .btn-mode-icon-box {
    background: #6ee7b7;
}

.btn-easy:hover .btn-mode-icon-box .material-icons {
    color: #fff;
}

/* CPU難易度ボタン - ふつう */
.btn-normal .btn-mode-icon-box {
    background: #fef3c7;
}

.btn-normal .btn-mode-icon-box .material-icons {
    color: #d97706;
}

.btn-normal:hover .btn-mode-icon-box {
    background: #fcd34d;
}

.btn-normal:hover .btn-mode-icon-box .material-icons {
    color: #fff;
}

/* CPU難易度ボタン - むずかしい */
.btn-hard .btn-mode-icon-box {
    background: #fecdd3;
}

.btn-hard .btn-mode-icon-box .material-icons {
    color: #e11d48;
}

.btn-hard:hover .btn-mode-icon-box {
    background: #fda4af;
}

.btn-hard:hover .btn-mode-icon-box .material-icons {
    color: #fff;
}

/* CPU難易度ボタン - 鬼 */
.btn-oni .btn-mode-icon-box {
    background: #991b1b;
}

.btn-oni .btn-mode-icon-box .material-icons {
    color: #fff;
}

.btn-oni:hover .btn-mode-icon-box {
    background: #7f1d1d;
}

.btn-oni:hover .btn-mode-icon-box .material-icons {
    color: #fff;
}

/* Warp Effect */
.warp-flash-overlay {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.warp-flash-overlay.active {
    animation: flash-bg 2s ease-out forwards;
}

@keyframes flash-bg {
    0% {
        opacity: 0;
        background: rgba(255, 255, 255, 0.4);
    }

    50% {
        opacity: 1;
        background: rgba(255, 255, 255, 0.8);
    }

    100% {
        opacity: 0;
        background: rgba(255, 255, 255, 0);
    }
}

.warp-text-effect {
    font-size: 5rem;
    font-weight: 900;
    font-style: italic;
    color: #f59e0b;
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.8);
    transform: scale(0.5);
    opacity: 0;
}

.warp-flash-overlay.active .warp-text-effect {
    animation: flash-text 2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes flash-bg {
    0% {
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes flash-text {
    0% {
        transform: scale(0.5) rotate(-5deg);
        opacity: 0;
    }

    30% {
        transform: scale(1.2) rotate(5deg);
        opacity: 1;
    }

    100% {
        transform: scale(1) rotate(0);
        opacity: 0;
    }
}

@media (max-width: 600px) {
    .warp-text-effect {
        font-size: 3rem;
    }
}

.player-a-text {
    color: var(--accent-color);
}

.player-b-text {
    color: var(--secondary-accent);
}

.cpu-difficulty-badge {
    background: #334155;
    color: #fff;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    margin: 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.controls .label {
    display: block;
    margin-bottom: 8px;
}

.input-button-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    /* flex-endからflex-startに変更、高さ固定なのでtopで揃う */
    width: 100%;
}

.input-button-row .input-wrapper {
    flex: 1;
}

.input-button-row #submit-move {
    height: 48px;
    padding: 0 24px;
    border-radius: 4px;
    /* 12px -> 4px */
}

.move-error {
    min-height: 20px;
    margin-top: 4px;
}

.secondary-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
    /* 6pxからさらに縮小 */
}

/* Mission Effect */
.mission-flash-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    /* 元の黒ベースに戻す */
    z-index: 15000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    /* テキストは白 */
}

.info-section {
    position: relative;
    /* 既存のスタイルがあるはずなので、z-index等を確認するため一度viewしたいが、上書きで対応 */
}

.mission-panel-tag {
    position: absolute;
    top: 5px;
    right: 15px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    /* 10px -> 4px */
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    text-align: center;
    transform: rotate(2deg);
    z-index: 5;
    animation: missionPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mission-tag-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    opacity: 0.9;
    margin-bottom: 1px;
}

.mission-tag-pref {
    font-size: 1.1rem;
    font-weight: 900;
}

@keyframes missionPop {
    from {
        transform: scale(0.8) rotate(-5deg);
        opacity: 0;
    }

    to {
        transform: scale(1) rotate(2deg);
        opacity: 1;
    }
}

.mission-text-effect {
    font-size: 1.2rem;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.5rem;
    margin-bottom: 2rem;
    animation: slideInDown 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mission-pref-effect {
    font-size: 5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 30px rgba(79, 70, 229, 0.6);
    text-align: center;
    width: 100%;
    word-break: keep-all;
    overflow-wrap: break-word;
    animation: zoomInBounce 1s 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes zoomInBounce {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    70% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
    }

    15% {
        opacity: 1;
    }

    85% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Siren Effect */
.siren-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9000;
    box-shadow: inset 0 0 0 rgba(225, 29, 72, 0);
    transition: box-shadow 0.5s ease;
    background: rgba(255, 255, 255, 0.05);
    /* 透明に近い白 */
}

.siren-overlay.active {
    animation: siren-pulse 0.8s infinite alternate cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes siren-pulse {
    from {
        box-shadow: inset 0 0 60px rgba(225, 29, 72, 0.1),
            inset 40px 40px 80px rgba(225, 29, 72, 0.1),
            inset -40px -40px 80px rgba(225, 29, 72, 0.1),
            inset 40px -40px 80px rgba(225, 29, 72, 0.1),
            inset -40px 40px 80px rgba(225, 29, 72, 0.1);
    }

    to {
        box-shadow: inset 0 0 120px rgba(225, 29, 72, 0.4),
            inset 60px 60px 120px rgba(225, 29, 72, 0.3),
            inset -60px -60px 120px rgba(225, 29, 72, 0.3),
            inset 60px -60px 120px rgba(225, 29, 72, 0.3),
            inset -60px 60px 120px rgba(225, 29, 72, 0.3);
    }
}

/* Transfer Effect */
.transfer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    /* 白ベース */
    z-index: 10000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #0f172a;
    /* テキストは黒 */
    text-align: center;
}

.transfer-overlay[data-player="A"] {
    border: 8px solid var(--accent-color);
}

.transfer-overlay[data-player="B"] {
    border: 8px solid var(--secondary-accent);
}

.transfer-overlay[data-player="A"] .transfer-title {
    color: var(--accent-color);
}

.transfer-overlay[data-player="B"] .transfer-title {
    color: var(--secondary-accent);
}

.transfer-details {
    text-align: center;
    padding: 30px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #e2e8f0;
    border-radius: 4px;
    /* 24px -> 4px */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    /* 影を柔らかく */
}

.transfer-overlay.active {
    display: flex;
    animation: transferFadeInOut 2.5s forwards;
}

.transfer-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.3rem;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    /* opacity: 0; Removed to prevent disappearance */
}

/* Animate whenever overlay is active */
.transfer-overlay.active .transfer-title {
    animation: transferSlideRight 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

/* Override for Warp */
.transfer-overlay.active .transfer-title.warp-mode {
    animation: warpParabolic 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    color: #f59e0b !important;
}

@keyframes transferSlideRight {
    0% {
        transform: translateX(-100px);
        opacity: 0;
    }

    30% {
        transform: translateX(20px);
        opacity: 1;
    }

    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes warpParabolic {
    0% {
        transform: translate(-100px, 50px) scale(0.5);
        opacity: 0;
    }

    50% {
        transform: translate(0, -30px) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
}

.transfer-line-name {
    font-size: 1.2rem;
    /* 小さく変更 */
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    animation: transferZoomIn 0.8s 0.1s both;
}

.transfer-path {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 2rem;
    animation: transferFadeInUp 0.8s 0.2s both;
}

.transfer-station {
    font-size: 2.2rem;
    /* 大きく変更 */
    font-weight: 900;
}

.transfer-arrow {
    font-size: 2rem;
    color: var(--text-secondary);
}

.transfer-next-player {
    font-size: 1.2rem;
    font-weight: 700;
    padding: 8px 24px;
    border-radius: 4px;
    /* 99px -> 4px */
    background: rgba(255, 255, 255, 0.1);
    animation: transferFadeInUp 0.8s 0.4s both;
    margin-top: 1rem;
}

.transfer-points {
    margin-top: 1.5rem;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    animation: slideInUp 0.6s 0.5s both;
}

.transfer-points-label {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-secondary);
}

.transfer-points-value {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--accent-color);
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.transfer-points-unit {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.transfer-overlay[data-player="B"] .transfer-points-value {
    color: var(--secondary-accent);
}

@keyframes transferFadeInOut {
    0% {
        opacity: 0;
    }

    15% {
        opacity: 1;
    }

    85% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes transferSlideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes transferZoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes transferFadeInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mission-flash-overlay.active {
    display: flex;
    animation: fadeInOut 3s forwards;
}

#mission-clear-flash .mission-flash-title {
    font-size: 6rem;
    color: #ffd700;
    /* Gold for clear */
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}

#game-over-flash .mission-pref-effect {
    color: #ff3e3e;
    /* Red for game over */
    text-shadow: 0 0 30px rgba(255, 62, 62, 0.6);
}

#game-start-flash .mission-pref-effect {
    color: #fff;
    /* White for start */
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.6);
}

/* お手つき演出 */
.fault-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 0, 0, 0.4);
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: none;
}

.fault-overlay.active {
    animation: faultFlash 1s ease-out forwards;
}

body.fault-shake .main-panel {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes faultFlash {
    0% {
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

.route-tooltip {
    background: rgba(15, 23, 42, 0.9) !important;
    border: 1px solid var(--accent-color) !important;
    color: white !important;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 2px;
    /* 8px -> 2px */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.route-tooltip::before {
    border-top-color: rgba(15, 23, 42, 0.9) !important;
}