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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ================================
   ラウンドセレクター / 終了画面 / エラー画面
   ================================ */
#round-select-screen,
#error-screen,
#setup-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #fff;
    z-index: 9999;
}

#end-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #fff;
    z-index: 9999;
    overflow-y: auto;
    padding: 40px 20px;
}

.select-container {
    text-align: center;
}

.select-container h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.select-container p {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: #ccc;
}

.round-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.round-btn {
    padding: 14px 28px;
    font-size: 1.3rem;
    font-weight: bold;
    border: 2px solid #e94560;
    background: transparent;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.round-btn:hover {
    background: #e94560;
    transform: scale(1.05);
}

.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* ================================
   サイトロゴ（常時表示）
   ================================ */
#site-logo {
    position: fixed;
    top: 10px;
    right: 24px;
    z-index: 10000;
    user-select: none;
    pointer-events: none;
}

#site-logo-image {
    display: block;
    width: 250px;
    height: 50px;
    object-fit: contain;
}

#version-info {
    position: fixed;
    right: 40px;
    bottom: 30px;
    font-size: 0.8rem !important;
    color: rgba(255, 255, 255, 0.5) !important;
    margin: 0 !important;
    z-index: 10000;
}

/* ================================
   メインゲーム画面
   ================================ */
#game-screen {
    position: fixed;
    inset: 0;
}

#street-view {
    width: 100%;
    height: 100%;
}

/* タイムラインコントロール非表示 */
#street-view .gm-bundled-control,
#street-view .gm-bundled-control-on-bottom {
    display: none !important;
}

/* ステータスバー */
#status-bar {
    position: fixed;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: bold;
    z-index: 100;
    pointer-events: none;
    user-select: none;
}

#status-bar-row {
    display: flex;
    gap: 20px;
}

#status-map-name {
    font-size: 0.78rem;
    color: #bbb;
    font-weight: normal;
    letter-spacing: 0.03em;
}

#status-map-name:empty {
    display: none;
}

/* コンパス */
#compass {
    position: fixed;
    bottom: 175px;
    left: 20px;
    z-index: 100;
    pointer-events: none;
    user-select: none;
}

/* ================================
   ストリートビュー操作コントロール
   ================================ */
#sv-controls {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 100;
    display: grid;
    grid-template-columns: 40px 40px;
    grid-template-rows: repeat(3, 40px);
    gap: 5px;
}

#sv-controls.one-col {
    grid-template-columns: 40px;
}

.sv-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    cursor: pointer;
    color: #fff;
    transition: background 0.15s;
}

.sv-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.88);
}

.sv-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.sv-btn.active {
    background: #e94560;
    border-color: #e94560;
}

/* ================================
   タイトルに戻る 確認モーダル
   ================================ */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#modal-dialog {
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 32px 40px 28px;
    text-align: center;
    min-width: 280px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
    color: #fff;
}

#modal-message {
    font-size: 1.05rem;
    margin-bottom: 24px;
    color: #ddd;
    line-height: 1.5;
}

#modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 10px 28px;
    font-size: 0.95rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background 0.2s, transform 0.1s;
}

.modal-btn-cancel {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.3);
    color: #ccc;
}

.modal-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.modal-btn-confirm {
    background: #e94560;
    border-color: #e94560;
    color: #fff;
}

.modal-btn-confirm:hover {
    background: #c73652;
    transform: scale(1.04);
}

/* ================================
   推測用地図
   ================================ */
#map-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    z-index: 100;
}

/* 地図ヘッダー（ピン・サイズボタン） */
#map-header {
    width: 240px;
    display: flex;
    align-items: center;
    transition: width 0.25s ease;
}

#map-size-controls {
    display: flex;
    gap: 4px;
}

#btn-pin,
#btn-size-up,
#btn-size-down {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #333;
    transition: background 0.15s;
}

#btn-pin:hover,
#btn-size-up:hover:not(:disabled),
#btn-size-down:hover:not(:disabled) {
    background: #fff;
}

#btn-pin.active {
    background: #e94560;
    color: #fff;
}

#btn-size-up:disabled,
#btn-size-down:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#map-container {
    width: 240px;
    height: 180px;
    opacity: 0.75;
    border-radius: 6px;
    position: relative;
    transition: width 0.25s ease, height 0.25s ease, opacity 0.2s ease;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

#guess-map {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    overflow: hidden;
}

/* 地図内ズームボタン（左上） */
#map-zoom-controls {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 10;
}

#btn-zoom-in,
#btn-zoom-out {
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 3px;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

#btn-zoom-in:hover,
#btn-zoom-out:hover {
    background: #fff;
}

/* 地図フッター（Guessボタン） */
#map-footer {
    width: 240px;
    transition: width 0.25s ease;
}

/* ================================
   Guess ボタン
   ================================ */
#btn-guess {
    width: 100%;
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: bold;
    background: #7ac74f;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

#btn-guess:disabled {
    background: #666;
    cursor: not-allowed;
    opacity: 0.6;
}

#btn-guess:not(:disabled):hover {
    background: #5fa33d;
}

/* ================================
   リザルトパネル
   ================================ */
#result-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 500;
}

#result-content {
    background: rgba(26, 26, 46, 0.95);
    color: #fff;
    padding: 20px 28px;
    border-radius: 12px;
    text-align: center;
    min-width: 240px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

#result-content p {
    font-size: 1.15rem;
    margin-bottom: 12px;
}

#btn-next {
    margin-top: 8px;
    padding: 10px 36px;
    font-size: 1rem;
    font-weight: bold;
    border: 2px solid #e94560;
    background: transparent;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

#btn-next:hover {
    background: #e94560;
}

/* ================================
   終了画面の追加スタイル
   ================================ */
#end-total-score {
    font-size: 2rem;
    font-weight: bold;
    color: #4a9eff;
}

#end-avg-distance {
    font-size: 1.2rem;
    color: #ccc;
    margin-bottom: 16px !important;
}

#end-map-container {
    width: min(720px, 90vw);
    margin: 0 auto 20px;
}

#end-map {
    width: 100%;
    height: 400px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

/* 各ラウンド詳細テーブル */
.round-table {
    margin: 0 auto 20px;
    border-collapse: collapse;
    font-size: 0.95rem;
    color: #fff;
    min-width: 280px;
}

.round-table th {
    padding: 6px 14px;
    border-bottom: 2px solid #4a9eff;
    color: #4a9eff;
    font-weight: bold;
    text-align: center;
}

.round-table td {
    padding: 5px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: right;
    color: #ddd;
}

.round-table td:first-child {
    text-align: center;
}

.round-table-total td {
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    border-bottom: none;
    font-weight: bold;
    color: #fff !important;
}

.round-table tr.highlighted td {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

#end-map-name {
    font-size: 1.4rem !important;
    font-weight: bold;
    color: #fff !important;
    margin-bottom: 0.2rem !important;
}

#end-game-info {
    font-size: 1rem !important;
    color: #888 !important;
    margin-bottom: 0.3rem !important;
    letter-spacing: 0.05em;
}

#end-screen .round-btn {
    border-color: #4a9eff;
}

#end-screen .round-btn:hover {
    background: #4a9eff;
}

/* ================================
   セットアップ画面
   ================================ */
#api-key-input {
    display: block;
    width: 360px;
    max-width: 90vw;
    margin: 0 auto 16px;
    padding: 10px 14px;
    font-size: 1rem;
    border: 2px solid #e94560;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    outline: none;
}

#api-key-input::placeholder {
    color: #777;
}

.setup-note {
    font-size: 0.85rem !important;
    color: #777 !important;
    margin-top: 12px !important;
}

#btn-change-key {
    display: block;
    margin: 16px auto 0;
    background: none;
    border: none;
    color: #888;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
}

#btn-change-key:hover {
    color: #fff;
}

/* ================================
   ゲームモード選択
   ================================ */
.mode-selector {
    margin-bottom: 1.5rem;
}

.mode-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.mode-btn {
    padding: 8px 20px;
    font-size: 0.95rem;
    font-weight: bold;
    border: 2px solid rgba(255, 255, 255, 0.22);
    background: transparent;
    color: #aaa;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.mode-btn:hover {
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
}

.mode-btn.active {
    border-color: #e94560;
    background: #e94560;
    color: #fff;
}

/* ================================
   NMPZオーバーレイ（アングル変更・ズーム禁止）
   ================================ */
#sv-nmpz-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    cursor: default;
}

/* ================================
   Round Time スライダー
   ================================ */
.time-limit-selector {
    margin-bottom: 1.5rem;
}

.selector-label {
    font-size: 1rem !important;
    color: #aaa !important;
    margin-bottom: 0.4rem !important;
}

.time-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.slider-edge-label {
    font-size: 0.8rem;
    color: #888;
    white-space: nowrap;
    min-width: 44px;
}

.slider-edge-label:last-child {
    text-align: right;
}

#time-limit-slider {
    width: 240px;
    max-width: 60vw;
    accent-color: #e94560;
    cursor: pointer;
}

#time-limit-label {
    display: block;
    margin-top: 6px;
    font-size: 1.15rem;
    font-weight: bold;
    color: #fff;
}

/* ================================
   カウントダウンタイマー
   ================================ */
#countdown-bar {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 101;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 8px;
    padding: 6px 22px;
    pointer-events: none;
    user-select: none;
}

#countdown-timer {
    font-size: 1.4rem;
    font-weight: bold;
    color: #fff;
    letter-spacing: 0.08em;
}

#countdown-timer.warning {
    color: #e94560;
}

/* ================================
   時間警告フラッシュ（外枠フェードアウト点滅）
   ================================ */
@keyframes timeWarningPulse {
    0% {
        opacity: 1;
    }

    70% {
        opacity: 0.15;
    }

    100% {
        opacity: 0;
    }
}

#time-warning-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    display: none;
    /* 内側ほど透明になる赤い縁（inset box-shadow を重ねて擬似グラデーション） */
    box-shadow:
        inset 0 0 8px 4px rgba(233, 69, 96, 0.85),
        inset 0 0 16px 8px rgba(233, 69, 96, 0.65),
        inset 0 0 28px 16px rgba(233, 69, 96, 0.40),
        inset 0 0 40px 24px rgba(233, 69, 96, 0.20),
        inset 0 0 56px 36px rgba(233, 69, 96, 0.00);
}

#time-warning-overlay.warning-active {
    animation: timeWarningPulse 1s ease-out infinite;
}

/* ================================
   マップ選択カード
   ================================ */
.map-selector {
    margin-bottom: 1.5rem;
}

#map-card-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

.map-card {
    width: 180px;
    padding: 12px 14px;
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, background 0.2s;
    color: #fff;
}

.map-card:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.08);
}

.map-card.selected {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.12);
}

.map-card-name {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 4px;
}

.map-card-desc {
    font-size: 0.78rem;
    color: #aaa;
    margin-bottom: 6px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.map-card-count {
    font-size: 0.78rem;
    color: #888;
}

.map-loading {
    font-size: 0.9rem !important;
    color: #888 !important;
    margin-bottom: 0 !important;
}