/* === 共通デザイン（ネオブルータリズム） === */
body {
    font-family: 'Helvetica Neue', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    background-color: #FFDE59;
    background-image: radial-gradient(#FFCE33 20%, transparent 20%), radial-gradient(#FFCE33 20%, transparent 20%);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    color: #222;
    text-align: center;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    position: relative;
}

h1 { font-size: 1.6rem; font-weight: 900; margin-bottom: 20px; text-shadow: 2px 2px 0 #fff; }
h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 15px; }
h3 { font-size: 1.1rem; border-bottom: 3px dashed #222; padding-bottom: 10px; margin-top: 0;}

.screen { display: none; width: 100%; max-width: 400px; padding-top: 20px; }
.active { display: block; }

/* === フォーム・ボタン === */
input[type="text"], input[type="number"] {
    font-size: 1.2rem;
    font-weight: bold;
    padding: 15px;
    border: 3px solid #222;
    border-radius: 12px;
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
    box-sizing: border-box;
    box-shadow: 4px 4px 0px #222;
}
input:focus { outline: none; background-color: #fffde7; }

.btn {
    font-size: 1.1rem;
    padding: 15px;
    border-radius: 16px;
    color: #222;
    border: 3px solid #222;
    font-weight: 900;
    cursor: pointer;
    width: 100%;
    margin-bottom: 15px;
    box-shadow: 4px 4px 0px #222;
    display: block;
    box-sizing: border-box;
    transition: all 0.1s ease;
    background-color: #fff;
}
.btn:active { transform: translate(4px, 4px); box-shadow: 0px 0px 0px #222; }

.btn-host { background-color: #FF5757; color: white; }
.btn-guest { background-color: #38B6FF; color: white; }
.btn-primary { background-color: #00E676; border-radius: 30px; }
.btn-fast { background-color: #FF5757; color: white; }
.btn-think { background-color: #CB6CE6; color: white; }
.btn-talk { background-color: #38B6FF; color: white; }
.btn-back { padding: 10px; font-size: 1rem; border-radius: 12px; margin-bottom: 20px; box-shadow: 2px 2px 0px #222; }

/* === カード・コンポーネント === */
.card {
    background: white;
    border: 3px solid #222;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 4px 4px 0px #222;
    text-align: left;
    line-height: 1.6;
    font-weight: bold;
}

.room-id-display {
    font-size: 2rem;
    color: #FF5757;
    text-align: center;
    letter-spacing: 2px;
    margin: 10px 0;
    padding: 10px;
    background: #f4f4f4;
    border-radius: 8px;
    border: 2px dashed #ccc;
}

.checkbox-label {
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    padding: 10px 0;
    border-bottom: 2px dashed #eee;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"], .radio-label input[type="radio"] {
    transform: scale(1.5);
    margin-right: 15px;
    accent-color: #FF5757;
}

.radio-label {
    display: flex;
    align-items: center;
    font-size: 1rem;
    padding: 8px 0;
    cursor: pointer;
    margin-left: 10px;
}

/* === ルーレット＆罰ゲームUI === */
.roulette-container {
    position: relative;
    margin: 30px auto;
    width: 300px;
    height: 300px;
}
.roulette-pointer {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    color: #FF5757;
    z-index: 10;
    text-shadow: 0px 2px 0px #222;
}
canvas {
    border-radius: 50%;
    border: 4px solid #222;
    box-shadow: 4px 4px 0px #222;
    background-color: white;
}

.result-display {
    font-size: 2.5rem;
    font-weight: 900;
    margin: 20px 0;
    color: #FF5757;
    text-shadow: 2px 2px 0px #222, -1px -1px 0px #222, 1px -1px 0px #222, -1px 1px 0px #222, 1px 1px 0px #222;
    background: white;
    padding: 20px;
    border: 4px solid #222;
    border-radius: 16px;
    box-shadow: 4px 4px 0px #222;
}

.penalty-box {
    background-color: #fff;
    border: 4px solid #222;
    padding: 20px;
    border-radius: 16px;
    margin: 20px 0 30px 0;
    box-shadow: 4px 4px 0px #FF5757;
    position: relative;
}
.penalty-box::before {
    content: "罰ゲーム";
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: #FF5757;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    border: 2px solid #222;
    font-size: 0.9rem;
    white-space: nowrap;
}

.change-btn {
    background: none;
    border: none;
    color: #666;
    text-decoration: underline;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 15px;
}

.top-left-toggle {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #222;
    color: #fff;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 2px 2px 0px #222;
    z-index: 100;
}
.top-left-toggle.off {
    background: #999;
    color: #fff;
    text-decoration: line-through;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.bomb-effects-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

.bomb-explosion-overlay {
    position: absolute;
    inset: -20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(3rem, 12vw, 7rem);
    animation: bombExplosion 0.9s ease-out forwards;
    filter: drop-shadow(0 0 25px rgba(255, 80, 80, 0.8));
}

@keyframes bombExplosion {
    0% {
        transform: scale(0.2) rotate(0deg);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    45% {
        transform: scale(1.2) rotate(10deg);
        opacity: 1;
    }
    100% {
        transform: scale(2.2) rotate(-12deg);
        opacity: 0;
    }
}

#bomb-board,
#bomb-board *,
.bomb-cell,
.bomb-cell * {
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -webkit-tap-highlight-color: transparent;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

.bomb-cell:hover {
    transform: translateY(-2px);
}

.bomb-cell:focus,
.bomb-cell:focus-visible,
.bomb-cell:active {
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
}

.bomb-safe-hit {
    animation: smokePop 0.7s ease-out forwards;
}

.bomb-bad-hit {
    animation: flashRed 0.45s ease-in-out 2 alternate;
}

.bomb-smoke-mark,
.bomb-safe-mark,
.bomb-reveal-mark,
.bomb-hidden-mark {
    display: inline-block;
    animation: floatUp 0.7s ease-out forwards;
    transform-origin: center;
}

.bomb-hidden-mark,
.bomb-reveal-mark {
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    line-height: 1;
}

@keyframes smokePop {
    0% { transform: scale(0.8); opacity: 0.2; }
    40% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 0.9; }
}

@keyframes flashRed {
    0% { filter: brightness(1); }
    50% { filter: brightness(1.5); }
    100% { filter: brightness(1); }
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(0.8); opacity: 0.5; }
    50% { transform: translateY(-6px) scale(1.05); opacity: 1; }
    100% { transform: translateY(-10px) scale(1); opacity: 0.9; }
}

/* === プレイヤー登録用リストデザイン（追記部分） === */
.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.input-group input {
    margin-bottom: 0;
    flex-grow: 1;
}
.input-group button {
    margin-bottom: 0;
    width: auto;
    padding: 0 20px;
}
.player-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.player-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 2px dashed #eee;
    font-size: 1.2rem;
}
.player-list li:last-child {
    border-bottom: none;
}
.delete-btn {
    background-color: #FF5757;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 5px 15px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 2px 2px 0px #222;
}
.delete-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 0px 0px 0px #222;
}

/* === ○×ゲーム用デザイン === */
.ttt-cell {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: white;
    border: 4px solid #222;
    border-radius: 12px;
    font-size: 3rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 4px 4px 0px #222;
    transition: background-color 0.1s;
}
.ttt-cell:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px #222;
}
.ttt-cell.x { color: #FF5757; } /* ✕は赤 */
.ttt-cell.o { color: #38B6FF; } /* 〇は青 */

/* === 💣 爆弾ゲーム：画面揺れ（大爆発）エフェクト === */
.shake-screen {
    /* ease-in-outの代わりにcubic-bezierを使うことで「ガタガタッ！」という激しい揺れを表現 */
    animation: screenShake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes screenShake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-8px, -5px) rotate(-2deg); }
    20%, 40%, 60%, 80% { transform: translate(8px, 5px) rotate(2deg); }
}

/* === ⏱️ タイマーゲーム：シャッター演出 === */
.timer-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 4px solid #222;
    border-radius: 16px;
    margin-bottom: 20px;
    box-shadow: 4px 4px 0px #222;
}

#timer-display {
    font-size: 5rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums; /* 数字の幅を固定してガタつきを防ぐ */
    color: #222;
    position: relative;
    z-index: 1;
}

#timer-shutter {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #222;
    background-image: repeating-linear-gradient(
        45deg,
        #222,
        #222 15px,
        #FFD700 15px,
        #FFD700 30px
    ); /* 工事現場風の警戒模様 */
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    font-weight: 900;
    text-shadow: 2px 2px 0px #000;
    border-bottom: 8px solid #555;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(-100%); /* 初期状態は上に隠れている */
}

/* シャッターが下りた状態 */
.shutter-closed {
    transform: translateY(0) !important;
}

/* 画面全体が揺れるアニメーション（シャッターが下りた時の焦り演出） */
.timer-shake {
    animation: timerShake 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes timerShake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-3px, -3px); }
    50% { transform: translate(3px, 3px); }
    75% { transform: translate(-3px, 3px); }
}

/* ストップした時の結果ドーン！の演出 */
.result-pop {
    animation: resultPopAnim 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes resultPopAnim {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* 爆発エフェクトの全画面レイヤー設定（最前面に固定） */
#bomb-effects-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === 💣 爆弾ゲーム：不発（プシュッ）エフェクト === */
.bomb-smoke-mark {
    display: inline-block;
    animation: defuseSputter 0.6s ease-out forwards;
}

@keyframes defuseSputter {
    0% { 
        transform: scale(1) translateY(0); 
        filter: grayscale(0); 
        opacity: 1; 
    }
    40% { 
        transform: scale(1.2) translateY(-5px); 
        filter: grayscale(0.3); 
        opacity: 0.8; 
    }
    100% { 
        /* しぼんで色を失う表現 */
        transform: scale(0.8) translateY(2px); 
        filter: grayscale(1); 
        opacity: 0.5; 
    }
}

/* === ⏱️ タイマーゲーム：シャッター演出 === */
.timer-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 4px solid #222;
    border-radius: 16px;
    margin-bottom: 20px;
    box-shadow: 4px 4px 0px #222;
}

#timer-display {
    font-size: 5rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums; /* 数字の幅を固定してガタつきを防ぐ */
    color: #222;
    position: relative;
    z-index: 1;
}

#timer-shutter {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #222;
    background-image: repeating-linear-gradient(
        45deg,
        #222,
        #222 15px,
        #FFD700 15px,
        #FFD700 30px
    ); /* 工事現場風の警戒模様 */
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    font-weight: 900;
    text-shadow: 2px 2px 0px #000;
    border-bottom: 8px solid #555;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(-100%); /* 初期状態は上に隠れている */
}

/* シャッターが下りた状態 */
.shutter-closed {
    transform: translateY(0) !important;
}

/* ストップした時の結果ドーン！の演出 */
.result-pop {
    animation: resultPopAnim 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes resultPopAnim {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}