/* --- Fireworks Styles (Fix: Number cut-off) --- */

* { box-sizing: border-box; }
body, html {
    margin: 0; padding: 0; width: 100%; height: 100%;
    overflow: hidden;
    background: #000;
    font-family: "Noto Sans JP", sans-serif;
}

/* 背景画像コンテナ */
#bg-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0; 
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-image: url('https://images.unsplash.com/photo-1519681393784-d120267933ba?q=80&w=2070&auto=format&fit=crop');
}

#bg-container::before {
    content: '';
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1;
}

.input_video { display: none; }

.output_canvas {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    z-index: 2;
    background: transparent !important;
}

/* UIレイヤー */
.ui-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10;
    display: flex; flex-direction: column;
    padding: 10px;
    pointer-events: none;
}

.header-bar, .setup-card, .overlay-screen, #game-ui button, .s-row select {
    pointer-events: auto;
}

/* ヘッダー */
.header-bar {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255,255,255,0.9);
    padding: 8px 15px; border-radius: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 10px; flex-shrink: 0;
}
.btn-menu {
    background: transparent; border: 2px solid #6d4c41;
    color: #6d4c41; padding: 5px 15px; border-radius: 20px;
    font-weight: bold; font-size: 0.85rem; cursor: pointer;
}
.header-title { font-weight: bold; color: #6d4c41; font-size: 1.1rem; }

/* 設定カード */
.setup-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px; padding: 20px;
    width: 95%; max-width: 400px; margin: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    text-align: center;
}
.card-title { margin: 0 0 5px 0; color: #6d4c41; font-size: 1.5rem; }
.card-desc { font-size: 0.9rem; color: #666; margin-bottom: 15px; }

.settings-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.s-row {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px dashed #ddd; padding-bottom: 10px;
}
.s-row label { font-weight: bold; color: #5d4037; font-size: 0.95rem; }

/* ★修正：AIリーチ訓練と同じスタイルへ */
.s-row select {
    padding: 8px; border-radius: 6px; border: 1px solid #ccc;
    font-size: 1rem; width: 50%; /* 幅を少し狭めて右寄せ */
    text-align: center; /* もし切れる場合は left にする */
    background: #fff;
}

/* ★追加：ダブルセレクト用コンテナ */
.double-select {
    display: flex; align-items: center; gap: 5px; width: 60%; justify-content: flex-end;
}
.double-select select {
    width: 80%; /* 数字部分 */
    text-align: center;
}
.double-select .unit {
    font-size: 0.9rem; color: #555; white-space: nowrap;
}

.start-btn {
    width: 100%; padding: 15px;
    background: #6d4c41; color: white;
    font-size: 1.3rem; font-weight: bold;
    border: none; border-radius: 50px;
    box-shadow: 0 4px 10px rgba(109, 76, 65, 0.4);
    cursor: pointer;
}
.start-btn:active { transform: scale(0.98); }

/* ゲーム中UI */
#game-ui {
    flex: 1; display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 20px;
}
.game-header {
    display: flex; justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.9);
    padding: 15px 20px;
    border-radius: 15px;
    margin-top: 10px;
    width: 98%; max-width: 600px; margin-left: auto; margin-right: auto;
}
.g-stat {
    font-weight: bold; color: #6d4c41; 
    font-size: 1.3rem;
    white-space: nowrap;
    flex: 1; text-align: center;
}
.highlight {
    color: #d32f2f; font-size: 1.8rem; margin-left: 8px;
    display: inline-block; min-width: 40px; text-align: right;
}

.great-message {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 3rem; font-weight: 900; color: gold;
    text-shadow: 0 0 20px rgba(255,215,0,0.8);
    pointer-events: none;
    animation: popUp 1s ease-out forwards;
}
@keyframes popUp {
    0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

.btn-stop {
    align-self: center;
    background: rgba(255,255,255,0.9); border: 2px solid #999;
    padding: 8px 25px; border-radius: 30px; font-weight: bold; color: #555;
    cursor: pointer;
}

/* 結果画面 */
.overlay-screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    z-index: 100; color: white;
}
.result-data {
    background: rgba(255,255,255,0.1); padding: 30px; border-radius: 20px;
    margin-bottom: 30px; text-align: center; border: 2px solid gold;
    backdrop-filter: blur(10px);
}
.result-data p { color: white; }

.btn-primary {
    width: 80%; padding: 12px; background: gold; color: #5d4037;
    border: none; border-radius: 30px; font-size: 1.2rem; font-weight: bold; margin-bottom: 15px;
    box-shadow: 0 5px 15px rgba(255,215,0,0.3);
}
.btn-secondary {
    width: 80%; padding: 10px; background: transparent; color: white;
    border: 2px solid white; border-radius: 30px; font-size: 1rem; font-weight: bold;
}

.hidden { display: none !important; }