/* 第五人格風 アンティーク・エレガントデザイン v2 */

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

body {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    font-family: 'Cinzel', 'Noto Serif JP', serif;
    background: #0a0a0a;
    color: #f5f5dc;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 800px;
    height: 80%;
    background-image: url('mono_white.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: 0.03;
    z-index: 0;
    pointer-events: none;
}

.container {
    position: relative;
    width: 100%;
    min-height: 100%;
    height: 100%;
}

#mainCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 0;
}

/* ============ デバフパネル（左サイド） ============ */
.debuff-panel {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    max-height: 80vh;
    background: linear-gradient(145deg, rgba(30, 25, 20, 0.95), rgba(20, 15, 10, 0.95));
    border: 3px solid #8b7355;
    border-radius: 12px;
    padding: 20px;
    z-index: 50;
    box-shadow: 
        0 0 30px rgba(212, 175, 55, 0.3),
        inset 0 0 30px rgba(0, 0, 0, 0.7);
    overflow-y: auto;
}

.debuff-title {
    font-size: 20px;
    font-weight: 700;
    color: #d4af37;
    text-align: center;
    margin-bottom: 15px;
    letter-spacing: 2px;
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.6);
}

.match-counter {
    font-size: 16px;
    color: #c9a961;
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    border: 1px solid #8b7355;
}

.match-counter span {
    color: #d4af37;
    font-weight: 700;
    font-size: 20px;
}

.debuff-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-debuff-backdrop,
.debuff-mobile-handle {
    display: none;
}

.mobile-debuff-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 3, 2, 0.58);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

.mobile-debuff-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.debuff-mobile-handle {
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid rgba(212, 175, 55, 0.26);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(58, 45, 28, 0.92), rgba(24, 18, 12, 0.92));
    color: #f5f5dc;
    cursor: pointer;
    font-family: 'Noto Serif JP', serif;
}

.debuff-mobile-handle-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    min-width: 0;
}

.debuff-mobile-label {
    font-size: 14px;
    font-weight: 700;
    color: #d4af37;
    letter-spacing: 0.08em;
}

.debuff-mobile-summary {
    font-size: 12px;
    color: #c9a961;
    letter-spacing: 0.04em;
}

.debuff-mobile-summary span {
    color: #f5f5dc;
    font-weight: 700;
}

.debuff-mobile-chevron {
    font-size: 20px;
    line-height: 1;
    color: #d4af37;
    transition: transform 0.25s ease;
}

/* ユーザーグループ */
.debuff-user-group {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #8b7355;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.debuff-user-group:hover {
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.debuff-user-header {
    font-size: 16px;
    font-weight: 700;
    color: #d4af37;
    margin-bottom: 10px;
    padding: 10px;
    border-bottom: 1px solid rgba(139, 115, 85, 0.5);
    letter-spacing: 1px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.debuff-user-header:hover {
    background: rgba(212, 175, 55, 0.1);
}

.debuff-user-name {
    flex: 1;
}

.debuff-user-count {
    font-size: 14px;
    color: #c9a961;
    margin-right: 10px;
}

.debuff-toggle-icon {
    font-size: 12px;
    color: #8b7355;
    transition: transform 0.3s ease;
}

.debuff-user-group.collapsed .debuff-toggle-icon {
    transform: rotate(-90deg);
}

.debuff-items-container {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.debuff-user-group.collapsed .debuff-items-container {
    max-height: 0;
    opacity: 0;
}

/* シンプルなデバフアイテム（ユーザー名なし） */
.debuff-item-simple {
    background: rgba(0, 0, 0, 0.3);
    border-left: 3px solid #8b7355;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.debuff-item-simple:last-child {
    margin-bottom: 0;
}

.debuff-item-simple:hover {
    border-left-color: #d4af37;
    background: rgba(0, 0, 0, 0.5);
}

.debuff-action {
    font-size: 13px;
    color: #f5f5dc;
    margin-bottom: 6px;
    line-height: 1.4;
    white-space: pre-line;
}

.debuff-action.danger {
    color: #ff6666;
    font-weight: 600;
}

.debuff-remaining {
    font-size: 12px;
    color: #c9a961;
    text-align: right;
}

.debuff-list:empty::after {
    content: 'デバフなし';
    display: block;
    text-align: center;
    color: #8b7355;
    font-size: 14px;
    padding: 20px;
}

/* ============ 脱出カウンター（右上） ============ */
.escape-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
    background: linear-gradient(145deg, rgba(30, 25, 20, 0.95), rgba(20, 15, 10, 0.95));
    border: 3px solid #8b7355;
    border-radius: 8px;
    min-height: 50px;
    padding: 10px 18px;
    font-size: 18px;
    font-weight: 700;
    color: #d4af37;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.escape-counter span {
    color: #ffd700;
    font-size: 20px;
}

.escape-counter.near-escape {
    border-color: #d4af37;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.6);
    animation: victoryPulse 1.5s ease-in-out infinite;
}

@keyframes victoryPulse {
    0%, 100% {
        box-shadow: 0 0 30px rgba(212, 175, 55, 0.6);
    }
    50% {
        box-shadow: 0 0 50px rgba(255, 215, 0, 0.9);
    }
}

/* ============ 脱出成功演出 ============ */
.escape-success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 600;
    pointer-events: none;
    transition: background 0.8s ease;
}

.escape-success-overlay.show {
    background: rgba(0, 0, 0, 0.85);
    pointer-events: auto;
}

.escape-success {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
    pointer-events: none;
    z-index: 700;
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.escape-success.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.escape-success-content {
    background: linear-gradient(145deg, rgba(30, 25, 20, 0.98), rgba(10, 8, 5, 0.98));
    border: 6px solid #ffd700;
    border-radius: 20px;
    padding: 70px 100px;
    box-shadow:
        0 0 100px rgba(255, 215, 0, 1),
        0 0 200px rgba(255, 215, 0, 0.4),
        inset 0 0 60px rgba(0, 0, 0, 0.7);
    animation: successGlow 1.5s ease-in-out infinite;
}

@keyframes successGlow {
    0%, 100% {
        box-shadow:
            0 0 100px rgba(255, 215, 0, 1),
            0 0 200px rgba(255, 215, 0, 0.4),
            inset 0 0 60px rgba(0, 0, 0, 0.7);
    }
    50% {
        box-shadow:
            0 0 150px rgba(255, 215, 0, 1),
            0 0 300px rgba(255, 215, 0, 0.6),
            inset 0 0 60px rgba(0, 0, 0, 0.7);
    }
}

.escape-success-title {
    font-size: 72px;
    font-weight: 700;
    color: #ffd700;
    text-align: center;
    margin-bottom: 20px;
    letter-spacing: 12px;
    text-shadow:
        0 0 30px rgba(255, 215, 0, 1),
        0 0 60px rgba(255, 215, 0, 0.8),
        0 0 100px rgba(255, 215, 0, 0.4);
    font-family: 'Cinzel', serif;
    animation: successTitlePulse 2s ease-in-out infinite;
}

@keyframes successTitlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.escape-success-text {
    font-size: 28px;
    color: #f5f5dc;
    text-align: center;
    letter-spacing: 3px;
    text-shadow: 0 0 15px rgba(245, 245, 220, 0.5);
    margin-bottom: 30px;
}

.escape-success-close {
    display: block;
    margin: 0 auto;
    padding: 15px 50px;
    font-size: 20px;
    font-weight: 700;
    color: #f5f5dc;
    background: linear-gradient(145deg, #3a2f1f, #2a1f0f);
    border: 3px solid #d4af37;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 3px;
    font-family: 'Cinzel', serif;
}

.escape-success-close:hover {
    border-color: #ffd700;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
    transform: translateY(-2px);
}

/* 紙吹雪コンテナ */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 650;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -20px;
    width: 12px;
    height: 12px;
    opacity: 1;
    animation: confettiFall var(--fall-duration, 3s) linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        transform: translateY(110vh) rotate(var(--rotation, 720deg)) scale(0.5);
        opacity: 0;
    }
}

/* ============ メインコンテンツ ============ */
.main-content {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

/* トップコントロール（音量・設定） */
.top-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 260;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

/* 音量コントロール */
.volume-control {
    position: relative;
    display: flex;
    align-items: center;
}

.volume-button, .settings-button {
    width: 50px;
    height: 50px;
    font-size: 24px;
    background: rgba(30, 25, 20, 0.9);
    border: 2px solid #8b7355;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.volume-button:hover, .settings-button:hover {
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

.volume-slider-container {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: clamp(160px, 18vw, 220px);
    background: rgba(30, 25, 20, 0.95);
    border: 2px solid #8b7355;
    border-radius: 8px;
    padding: 12px 14px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    box-shadow:
        0 12px 24px rgba(0, 0, 0, 0.45),
        0 0 20px rgba(212, 175, 55, 0.12);
}

.volume-slider-container.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.volume-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #8b7355, #d4af37);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #d4af37;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    background: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.7);
}

.volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #d4af37;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.volume-value {
    font-size: 13px;
    color: #d4af37;
    font-weight: 600;
    min-width: 0;
    text-align: right;
    letter-spacing: 0.5px;
}

/* メインタイトル */
.main-title {
    font-size: 48px;
    font-weight: 700;
    color: #d4af37;
    text-align: center;
    margin-bottom: 40px;
    text-shadow: 
        0 0 20px rgba(212, 175, 55, 0.6),
        0 0 40px rgba(212, 175, 55, 0.3),
        2px 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 8px;
    font-family: 'Cinzel', serif;
}

/* ステージコンテナ */
.stages-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    max-width: 900px;
    width: 100%;
    margin-bottom: 40px;
    transition: opacity 0.5s ease, filter 0.5s ease;
}

/* 結果表示時にルーレットを暗くする */
.main-content.showing-result .stages-container,
.main-content.showing-result .main-title {
    opacity: 0.2;
    filter: brightness(0.4);
}

/* 各ステージ */
.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stage-title {
    font-size: 18px;
    font-weight: 600;
    color: #c9a961;
    text-align: center;
    margin-bottom: 15px;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* スロット表示エリア */
.slot-display {
    width: 100%;
    min-width: 280px;
    height: 200px;
    background: linear-gradient(145deg, rgba(30, 25, 20, 0.95), rgba(20, 15, 10, 0.95));
    border: 3px solid #8b7355;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 0 20px rgba(212, 175, 55, 0.2),
        inset 0 0 30px rgba(0, 0, 0, 0.7),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
}

.slot-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: linear-gradient(to bottom, 
        rgba(20, 15, 10, 1) 0%, 
        rgba(20, 15, 10, 0) 100%);
    z-index: 2;
    pointer-events: none;
}

.slot-display::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: linear-gradient(to top, 
        rgba(20, 15, 10, 1) 0%, 
        rgba(20, 15, 10, 0) 100%);
    z-index: 2;
    pointer-events: none;
}

/* スロットリール */
.slot-reel {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: none;
}

.slot-text {
    font-size: 24px;
    font-weight: 700;
    color: #f5f5dc;
    text-shadow: 
        0 0 15px rgba(212, 175, 55, 0.6),
        0 2px 8px rgba(0, 0, 0, 0.9);
    letter-spacing: 0.5px;
    line-height: 1.3;
    min-height: 100px;
    height: auto;
    text-align: center;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: anywhere;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    box-sizing: border-box;
}

/* アニメーション */
.slot-reel.spinning {
    animation: spinReel var(--spin-duration, 3s) cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

@keyframes spinReel {
    0% {
        filter: blur(0px);
    }
    10% {
        filter: blur(5px);
    }
    90% {
        filter: blur(5px);
    }
    100% {
        transform: translateX(-50%) translateY(var(--final-position));
        filter: blur(0px);
    }
}

.slot-reel.stopped {
    transition: filter 0.3s ease;
    filter: blur(0px);
}

/* 確定時のエフェクト */
.slot-reel.confirmed .slot-text {
    animation: confirmGlow 2s ease-in-out infinite;
    color: #d4af37;
    text-shadow: 
        0 0 25px rgba(212, 175, 55, 1),
        0 0 50px rgba(212, 175, 55, 0.6),
        0 0 75px rgba(212, 175, 55, 0.3);
}

.slot-display.danger .slot-reel.confirmed .slot-text {
    animation: confirmGlowDanger 1.5s ease-in-out infinite;
    color: #ff4444;
}

@keyframes confirmGlowDanger {
    0%, 100% {
        text-shadow: 
            0 0 25px rgba(255, 0, 0, 1),
            0 0 50px rgba(255, 0, 0, 0.6),
            0 0 75px rgba(255, 0, 0, 0.3);
    }
    50% {
        text-shadow: 
            0 0 35px rgba(255, 50, 50, 1),
            0 0 70px rgba(255, 50, 50, 0.8),
            0 0 100px rgba(255, 50, 50, 0.5);
    }
}

.stage.completed .slot-display {
    animation: boxGlow 2s ease-in-out infinite;
}

.slot-display.danger {
    animation: boxGlowDanger 1.5s ease-in-out infinite !important;
}

@keyframes confirmGlow {
    0%, 100% {
        text-shadow: 
            0 0 25px rgba(212, 175, 55, 1),
            0 0 50px rgba(212, 175, 55, 0.6),
            0 0 75px rgba(212, 175, 55, 0.3);
    }
    50% {
        text-shadow: 
            0 0 35px rgba(255, 215, 0, 1),
            0 0 70px rgba(255, 215, 0, 0.8),
            0 0 100px rgba(255, 215, 0, 0.5);
    }
}

@keyframes boxGlow {
    0%, 100% {
        border-color: #d4af37;
        box-shadow: 
            0 0 20px rgba(212, 175, 55, 0.4),
            inset 0 0 30px rgba(0, 0, 0, 0.7);
    }
    50% {
        border-color: #ffd700;
        box-shadow: 
            0 0 35px rgba(255, 215, 0, 0.7),
            inset 0 0 30px rgba(0, 0, 0, 0.7);
    }
}

@keyframes boxGlowDanger {
    0%, 100% {
        border-color: #ff0000;
        box-shadow: 
            0 0 25px rgba(255, 0, 0, 0.6),
            inset 0 0 30px rgba(0, 0, 0, 0.7);
    }
    50% {
        border-color: #ff4444;
        box-shadow: 
            0 0 45px rgba(255, 0, 0, 1),
            inset 0 0 30px rgba(0, 0, 0, 0.7);
    }
}

/* スタートボタン */
.start-button {
    padding: 20px 60px;
    font-size: 28px;
    font-weight: 700;
    font-family: 'Cinzel', serif;
    color: #f5f5dc;
    background: linear-gradient(145deg, #3a2f1f, #2a1f0f);
    border: 3px solid #8b7355;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 
        0 0 20px rgba(212, 175, 55, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.1),
        0 8px 15px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    letter-spacing: 4px;
    position: relative;
    overflow: hidden;
}

.start-button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(212, 175, 55, 0.1),
        transparent
    );
    transform: rotate(45deg);
    transition: all 0.5s ease;
}

.start-button:hover:not(:disabled)::before {
    left: 100%;
}

.start-button:hover:not(:disabled) {
    transform: translateY(-3px);
    border-color: #d4af37;
    box-shadow: 
        0 0 30px rgba(212, 175, 55, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.2),
        0 12px 20px rgba(0, 0, 0, 0.6);
}

.start-button:active:not(:disabled) {
    transform: translateY(-1px);
}

.start-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #5a4a3a;
}

.button-text {
    position: relative;
    z-index: 1;
}

/* 結果表示パネル */
.result-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 90%;
    max-width: 800px;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    transition: all 0.5s ease;
}

.result-panel::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: -1;
    transition: background 0.5s ease;
    pointer-events: none;
}

.result-panel.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.result-panel.show::before {
    background: rgba(0, 0, 0, 0.85);
    pointer-events: auto;
}

.result-frame {
    background: linear-gradient(145deg, rgba(30, 25, 20, 0.98), rgba(20, 15, 10, 0.98));
    border: 4px solid #d4af37;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 
        0 0 40px rgba(212, 175, 55, 0.6),
        inset 0 0 40px rgba(0, 0, 0, 0.7),
        0 20px 60px rgba(0, 0, 0, 0.9);
    position: relative;
    transition: all 0.5s ease;
}

.result-panel.danger .result-frame {
    background: linear-gradient(145deg, rgba(50, 10, 10, 0.98), rgba(30, 5, 5, 0.98));
    border: 4px solid #ff0000;
    box-shadow: 
        0 0 50px rgba(255, 0, 0, 0.8),
        inset 0 0 40px rgba(0, 0, 0, 0.7),
        0 20px 60px rgba(0, 0, 0, 0.9);
    animation: dangerPulse 1s ease-in-out infinite;
}

.result-panel.danger .result-frame::before,
.result-panel.danger .result-frame::after {
    color: #ff0000;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
}

.result-panel.danger .result-title {
    color: #ff4444;
    text-shadow: 0 0 25px rgba(255, 0, 0, 0.8);
}

.result-panel.danger .result-text {
    color: #ffcccc;
}

@keyframes dangerPulse {
    0%, 100% {
        box-shadow: 
            0 0 50px rgba(255, 0, 0, 0.8),
            inset 0 0 40px rgba(0, 0, 0, 0.7),
            0 20px 60px rgba(0, 0, 0, 0.9);
    }
    50% {
        box-shadow: 
            0 0 80px rgba(255, 0, 0, 1),
            inset 0 0 40px rgba(0, 0, 0, 0.7),
            0 20px 60px rgba(0, 0, 0, 0.9);
    }
}

.result-frame::before,
.result-frame::after {
    content: '◆';
    position: absolute;
    font-size: 24px;
    color: #d4af37;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.8);
}

.result-frame::before {
    top: 15px;
    left: 15px;
}

.result-frame::after {
    bottom: 15px;
    right: 15px;
}

.result-title {
    font-size: 28px;
    font-weight: 700;
    color: #d4af37;
    text-align: center;
    margin-bottom: 30px;
    letter-spacing: 4px;
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.6);
    font-family: 'Cinzel', serif;
}

.result-text {
    font-size: 24px;
    line-height: 1.8;
    color: #f5f5dc;
    text-align: center;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    white-space: pre-line;
}

/* 次へボタン */
.next-button {
    margin: 30px auto 0;
    padding: 15px 50px;
    font-size: 20px;
    font-weight: 700;
    color: #f5f5dc;
    background: linear-gradient(145deg, #3a2f1f, #2a1f0f);
    border: 3px solid #8b7355;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 3px;
    font-family: 'Cinzel', serif;
    display: block;
}

.next-button:hover {
    border-color: #d4af37;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
    transform: translateY(-2px);
}

.stage.active .slot-display {
    border-color: #d4af37;
    box-shadow: 
        0 0 30px rgba(212, 175, 55, 0.5),
        inset 0 0 30px rgba(0, 0, 0, 0.7);
}

/* ============ モーダル共通 ============ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: linear-gradient(145deg, rgba(30, 25, 20, 0.98), rgba(20, 15, 10, 0.98));
    border: 4px solid #d4af37;
    border-radius: 12px;
    box-shadow: 
        0 0 50px rgba(212, 175, 55, 0.7),
        inset 0 0 40px rgba(0, 0, 0, 0.7);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid #8b7355;
}

.modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #d4af37;
    letter-spacing: 3px;
    font-family: 'Cinzel', serif;
}

.modal-close {
    width: 40px;
    height: 40px;
    font-size: 28px;
    color: #c9a961;
    background: transparent;
    border: 2px solid #8b7355;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    color: #d4af37;
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.modal-body {
    padding: 30px;
}

/* ============ ユーザー設定モーダル ============ */
.user-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #8b7355;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
}

.user-item:hover {
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.user-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #8b7355;
    border-radius: 6px;
    padding: 10px 15px;
    color: #f5f5dc;
    font-size: 16px;
    font-family: 'Noto Serif JP', serif;
    transition: all 0.3s ease;
}

.user-input:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

.remove-user-button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    color: #ff6666;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #8b7355;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-user-button:hover {
    border-color: #ff0000;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.4);
}

.add-user-button {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    font-weight: 600;
    color: #f5f5dc;
    background: linear-gradient(145deg, #3a2f1f, #2a1f0f);
    border: 2px solid #8b7355;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 2px;
}

.add-user-button:hover:not(:disabled) {
    border-color: #d4af37;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
}

.add-user-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 設定モーダルの区切り線 */
.settings-divider {
    height: 2px;
    background: linear-gradient(to right, transparent, #8b7355, transparent);
    margin: 30px 0;
}

/* 危険ゾーン */
.settings-danger-zone {
    background: rgba(50, 10, 10, 0.3);
    border: 2px solid rgba(139, 55, 55, 0.5);
    border-radius: 8px;
    padding: 20px;
}

.danger-zone-title {
    font-size: 16px;
    font-weight: 600;
    color: #d4af37;
    text-align: center;
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.reset-buttons-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.reset-button {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #c9a961;
    background: linear-gradient(145deg, #2a2520, #1a1510);
    border: 2px solid #8b7355;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.reset-button:hover {
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
    color: #d4af37;
}

.reset-button:active {
    transform: scale(0.98);
}

/* ============ 戦績登録モーダル ============ */
.record-modal-content {
    max-width: 500px;
}

.record-info {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #8b7355;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 25px;
    font-size: 14px;
    line-height: 1.8;
    color: #c9a961;
    text-align: center;
}

.record-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.record-item {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #8b7355;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
}

.record-item:hover {
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

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

.record-username {
    font-size: 18px;
    font-weight: 600;
    color: #d4af37;
    letter-spacing: 1px;
}

.record-buttons {
    display: flex;
    gap: 10px;
}

.record-button {
    width: 50px;
    height: 50px;
    font-size: 24px;
    font-weight: 700;
    border: 2px solid #8b7355;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}

.record-button.escape {
    color: #4CAF50;
}

.record-button.eliminated {
    color: #f44336;
}

.record-button.active {
    border-color: currentColor;
    box-shadow: 0 0 15px currentColor;
    transform: scale(1.1);
}

.record-button:hover {
    border-color: currentColor;
    box-shadow: 0 0 10px currentColor;
}

.record-special {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #8b7355;
}

.record-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #c9a961;
    cursor: pointer;
}

.record-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.submit-button {
    width: 100%;
    padding: 18px;
    font-size: 22px;
    font-weight: 700;
    color: #f5f5dc;
    background: linear-gradient(145deg, #3a2f1f, #2a1f0f);
    border: 3px solid #8b7355;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 3px;
    font-family: 'Cinzel', serif;
}

.submit-button:hover:not(:disabled) {
    border-color: #d4af37;
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.5);
    transform: translateY(-2px);
}

.submit-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============ 確認モーダル ============ */
.confirm-modal-content {
    max-width: 500px;
}

.confirm-message {
    font-size: 24px;
    font-weight: 600;
    color: #d4af37;
    text-align: center;
    margin-bottom: 25px;
    letter-spacing: 2px;
}

.confirm-summary {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #8b7355;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    font-size: 16px;
    line-height: 1.8;
    color: #c9a961;
}

.confirm-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(139, 115, 85, 0.3);
}

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

.confirm-summary-label {
    font-weight: 600;
    color: #d4af37;
}

.confirm-summary-value {
    color: #f5f5dc;
}

.confirm-summary-value.escaped {
    color: #4CAF50;
}

.confirm-summary-value.eliminated {
    color: #f44336;
}

.confirm-buttons {
    display: flex;
    gap: 15px;
}

.back-button, .proceed-button {
    flex: 1;
    padding: 18px;
    font-size: 20px;
    font-weight: 700;
    border: 3px solid #8b7355;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 2px;
    font-family: 'Cinzel', serif;
}

.back-button {
    color: #c9a961;
    background: linear-gradient(145deg, #2a2520, #1a1510);
}

.back-button:hover {
    border-color: #c9a961;
    box-shadow: 0 0 20px rgba(201, 169, 97, 0.4);
}

.proceed-button {
    color: #f5f5dc;
    background: linear-gradient(145deg, #3a2f1f, #2a1f0f);
}

.proceed-button:hover {
    border-color: #d4af37;
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.5);
    transform: translateY(-2px);
}

/* ============ 天使のルーレット ============ */
.angel-modal-content {
    max-width: 520px;
    background: linear-gradient(145deg, rgba(20, 20, 40, 0.98), rgba(10, 10, 30, 0.98));
    border: 4px solid #e8d5a3;
    box-shadow:
        0 0 60px rgba(255, 255, 255, 0.3),
        0 0 120px rgba(200, 200, 255, 0.15),
        inset 0 0 40px rgba(0, 0, 0, 0.5);
}

.angel-header {
    text-align: center;
    padding: 25px 30px 15px;
}

.angel-title {
    font-size: 28px;
    font-weight: 700;
    color: #fffbe6;
    letter-spacing: 4px;
    text-shadow:
        0 0 20px rgba(255, 255, 255, 0.8),
        0 0 40px rgba(200, 200, 255, 0.4);
    font-family: 'Cinzel', serif;
}

.angel-body {
    padding: 10px 30px 30px;
}

.angel-slot-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.angel-slot-window {
    width: 320px;
    height: 240px;
    overflow: hidden;
    position: relative;
    background: linear-gradient(145deg, rgba(10, 10, 30, 0.9), rgba(20, 15, 40, 0.9));
    border: 3px solid #e8d5a3;
    border-radius: 12px;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.7),
        0 0 20px rgba(232, 213, 163, 0.3);
}

.angel-slot-window::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(to bottom,
        rgba(10, 10, 30, 1) 0%,
        rgba(10, 10, 30, 0) 100%);
    z-index: 2;
    pointer-events: none;
}

.angel-slot-window::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(to top,
        rgba(10, 10, 30, 1) 0%,
        rgba(10, 10, 30, 0) 100%);
    z-index: 2;
    pointer-events: none;
}

.angel-slot-reel {
    display: flex;
    flex-direction: column;
    will-change: transform;
}

.angel-slot-item {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #fffbe6;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    font-family: 'Noto Serif JP', serif;
    flex-shrink: 0;
}

.angel-slot-item.miss {
    color: #9999aa;
    text-shadow: none;
}

.angel-slot-item.final {
    color: #ffd700;
    text-shadow:
        0 0 15px rgba(255, 215, 0, 0.8),
        0 0 30px rgba(255, 215, 0, 0.4);
}

.angel-slot-item.final.miss {
    color: #9999aa;
    text-shadow: 0 0 10px rgba(150, 150, 170, 0.5);
}

/* 結果表示 */
.angel-result-area {
    text-align: center;
    margin-bottom: 20px;
    animation: angelFadeIn 0.5s ease;
}

@keyframes angelFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.angel-result-text {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.6;
    letter-spacing: 1px;
    font-family: 'Noto Serif JP', serif;
}

.angel-result-text.success {
    color: #fffbe6;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
}

.angel-result-text.miss-text {
    color: #9999aa;
    text-shadow: none;
}

/* デバフ選択UI */
.angel-debuff-select {
    max-height: 300px;
    overflow-y: auto;
    animation: angelFadeIn 0.5s ease;
}

.angel-debuff-group {
    margin-bottom: 15px;
}

.angel-debuff-user-name {
    font-size: 16px;
    font-weight: 700;
    color: #e8d5a3;
    padding: 6px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(232, 213, 163, 0.3);
    letter-spacing: 1px;
}

.angel-debuff-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(232, 213, 163, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.angel-debuff-item:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: #fffbe6;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
    transform: translateX(4px);
}

.angel-debuff-item.danger {
    border-color: rgba(255, 100, 100, 0.4);
}

.angel-debuff-item.danger:hover {
    border-color: #ff6666;
    box-shadow: 0 0 15px rgba(255, 100, 100, 0.3);
}

.angel-debuff-item.selected {
    background: rgba(255, 215, 0, 0.2);
    border-color: #ffd700;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.5);
    animation: angelSelectPulse 0.5s ease;
}

@keyframes angelSelectPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

.angel-debuff-item-text {
    font-size: 14px;
    color: #f5f5dc;
    flex: 1;
    white-space: pre-line;
    line-height: 1.4;
}

.angel-debuff-item.danger .angel-debuff-item-text {
    color: #ff6666;
}

.angel-debuff-item-remain {
    font-size: 12px;
    color: #c9a961;
    margin-left: 12px;
    white-space: nowrap;
}

.angel-debuff-select::-webkit-scrollbar {
    width: 6px;
}

.angel-debuff-select::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

.angel-debuff-select::-webkit-scrollbar-thumb {
    background: #e8d5a3;
    border-radius: 3px;
}

.angel-close-button {
    display: block;
    margin: 20px auto 0;
    padding: 14px 50px;
    font-size: 18px;
    font-weight: 700;
    color: #fffbe6;
    background: linear-gradient(145deg, #2a2540, #1a1530);
    border: 3px solid #e8d5a3;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 3px;
    font-family: 'Cinzel', serif;
    animation: angelFadeIn 0.5s ease;
}

.angel-close-button:hover {
    border-color: #fffbe6;
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

/* ============ 狂気のルーレット ============ */
.madness-modal-content {
    max-width: 520px;
    background: linear-gradient(145deg, rgba(40, 10, 15, 0.98), rgba(20, 5, 10, 0.98));
    border: 4px solid #cc3333;
    box-shadow:
        0 0 60px rgba(200, 0, 0, 0.5),
        0 0 120px rgba(150, 0, 50, 0.2),
        inset 0 0 40px rgba(0, 0, 0, 0.7);
    animation: madnessModalPulse 2s ease-in-out infinite;
}

@keyframes madnessModalPulse {
    0%, 100% {
        box-shadow:
            0 0 60px rgba(200, 0, 0, 0.5),
            0 0 120px rgba(150, 0, 50, 0.2),
            inset 0 0 40px rgba(0, 0, 0, 0.7);
    }
    50% {
        box-shadow:
            0 0 80px rgba(255, 0, 0, 0.7),
            0 0 160px rgba(200, 0, 80, 0.3),
            inset 0 0 40px rgba(0, 0, 0, 0.7);
    }
}

.madness-header {
    text-align: center;
    padding: 25px 30px 10px;
}

.madness-title {
    font-size: 28px;
    font-weight: 700;
    color: #ff4444;
    letter-spacing: 4px;
    text-shadow:
        0 0 20px rgba(255, 0, 0, 0.8),
        0 0 40px rgba(200, 0, 50, 0.4);
    font-family: 'Cinzel', serif;
    animation: madnessTitleFlicker 3s ease-in-out infinite;
}

@keyframes madnessTitleFlicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
    52% { opacity: 1; }
    70% { opacity: 0.9; }
    72% { opacity: 1; }
}

.madness-subtitle {
    font-size: 14px;
    color: #cc6666;
    letter-spacing: 2px;
    margin-top: 8px;
    font-family: 'Noto Serif JP', serif;
}

.madness-body {
    padding: 10px 30px 30px;
}

.madness-slot-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.madness-slot-window {
    width: 320px;
    height: 240px;
    overflow: hidden;
    position: relative;
    background: linear-gradient(145deg, rgba(30, 5, 10, 0.9), rgba(15, 0, 5, 0.9));
    border: 3px solid #cc3333;
    border-radius: 12px;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(200, 0, 0, 0.3);
}

.madness-slot-window::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(to bottom,
        rgba(30, 5, 10, 1) 0%,
        rgba(30, 5, 10, 0) 100%);
    z-index: 2;
    pointer-events: none;
}

.madness-slot-window::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(to top,
        rgba(30, 5, 10, 1) 0%,
        rgba(30, 5, 10, 0) 100%);
    z-index: 2;
    pointer-events: none;
}

.madness-slot-reel {
    display: flex;
    flex-direction: column;
    will-change: transform;
}

.madness-slot-item {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #ffaaaa;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(255, 100, 100, 0.4);
    font-family: 'Noto Serif JP', serif;
    flex-shrink: 0;
    text-align: center;
    padding: 0 15px;
    white-space: pre-line;
    line-height: 1.3;
}

.madness-slot-item.final {
    color: #ff4444;
    text-shadow:
        0 0 15px rgba(255, 0, 0, 0.8),
        0 0 30px rgba(255, 0, 0, 0.4);
    font-size: 20px;
}

.madness-result-area {
    text-align: center;
    margin-bottom: 20px;
    animation: madnessFadeIn 0.6s ease;
}

@keyframes madnessFadeIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.madness-result-text {
    font-size: 22px;
    font-weight: 700;
    color: #ff4444;
    line-height: 1.6;
    letter-spacing: 1px;
    font-family: 'Noto Serif JP', serif;
    text-shadow: 0 0 15px rgba(255, 0, 0, 0.6);
    margin-bottom: 12px;
    white-space: pre-line;
}

.madness-result-target {
    font-size: 15px;
    color: #cc8888;
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.madness-result-duration {
    font-size: 14px;
    color: #ffcc44;
    font-weight: 600;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 200, 0, 0.4);
}

.madness-close-button {
    display: block;
    margin: 20px auto 0;
    padding: 14px 50px;
    font-size: 18px;
    font-weight: 700;
    color: #ffcccc;
    background: linear-gradient(145deg, #3a1520, #2a0a15);
    border: 3px solid #cc3333;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 3px;
    font-family: 'Cinzel', serif;
    animation: madnessFadeIn 0.5s ease;
}

.madness-close-button:hover {
    border-color: #ff4444;
    box-shadow: 0 0 25px rgba(255, 0, 0, 0.5);
    transform: translateY(-2px);
    color: #ffffff;
}

/* スクロールバー */
.debuff-panel::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.debuff-panel::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.debuff-panel::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: #8b7355;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.debuff-panel::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover {
    background: #d4af37;
}

/* レスポンシブ対応 */
@media (max-width: 1400px) {
    .debuff-panel {
        width: 240px;
        left: 10px;
    }
    
    .stages-container {
        max-width: 700px;
    }
}

@media (max-width: 768px) {
    body {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    body.mobile-debuff-open {
        overflow: hidden;
    }

    body::before {
        width: min(92vw, 520px);
        height: 64dvh;
        opacity: 0.04;
    }

    .container {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    #mainCanvas {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100dvh;
    }

    .top-controls {
        top: calc(env(safe-area-inset-top, 0px) + 14px);
        right: 14px;
        gap: 8px;
    }

    .volume-button,
    .settings-button {
        width: 46px;
        height: 46px;
        font-size: 22px;
    }

    .volume-slider-container {
        width: min(176px, 58vw);
    }

    .debuff-panel {
        top: auto;
        right: 12px;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
        left: 12px;
        width: auto;
        max-height: min(60dvh, 480px);
        padding: 12px;
        border-radius: 20px;
        transform: none;
        overflow: hidden;
        z-index: 280;
        box-shadow:
            0 18px 44px rgba(0, 0, 0, 0.45),
            0 0 30px rgba(212, 175, 55, 0.16),
            inset 0 0 26px rgba(0, 0, 0, 0.72);
    }

    .mobile-debuff-backdrop {
        display: block;
        z-index: 270;
    }

    .debuff-panel.mobile-sheet {
        display: grid;
        grid-template-rows: auto 0fr;
        gap: 12px;
        transition: grid-template-rows 0.28s ease, box-shadow 0.28s ease;
    }

    .debuff-panel.mobile-sheet.mobile-open {
        grid-template-rows: auto minmax(0, 1fr);
        box-shadow:
            0 22px 54px rgba(0, 0, 0, 0.52),
            0 0 34px rgba(212, 175, 55, 0.2),
            inset 0 0 28px rgba(0, 0, 0, 0.72);
    }

    .debuff-panel.mobile-sheet .debuff-panel-body {
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        gap: 12px;
        opacity: 0;
        transform: translateY(8px);
        pointer-events: none;
        transition: opacity 0.22s ease, transform 0.22s ease;
    }

    .debuff-panel.mobile-sheet.mobile-open .debuff-panel-body {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    .debuff-mobile-handle {
        display: flex;
    }

    .debuff-panel.mobile-sheet .debuff-title {
        display: none;
    }

    .debuff-panel.mobile-sheet .match-counter {
        margin-bottom: 0;
    }

    .debuff-panel.mobile-sheet .debuff-list {
        min-height: 0;
        overflow-y: auto;
        padding-right: 4px;
    }

    .debuff-panel.mobile-sheet.mobile-open .debuff-mobile-chevron {
        transform: rotate(180deg);
    }
    
    .stages-container {
        grid-template-columns: 1fr;
        gap: 16px;
        width: 100%;
        max-width: none;
        margin-bottom: 8px;
    }

    .main-content {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        justify-content: flex-start;
        padding: calc(env(safe-area-inset-top, 0px) + 86px) 16px calc(env(safe-area-inset-bottom, 0px) + 112px);
        gap: 18px;
    }
    
    .main-title {
        font-size: clamp(28px, 8vw, 36px);
        margin-bottom: 4px;
        letter-spacing: 0.14em;
    }

    .stage {
        width: 100%;
    }
    
    .stage-title {
        font-size: 15px;
        margin-bottom: 10px;
    }

    .slot-display {
        width: 100%;
        min-width: 0;
        height: clamp(150px, 23vh, 188px);
        border-radius: 12px;
    }
    
    .slot-text {
        font-size: clamp(18px, 5.4vw, 22px);
        min-height: 78px;
        padding: 10px 14px;
    }
    
    .start-button {
        width: min(100%, 320px);
        padding: 16px 24px;
        font-size: 20px;
        letter-spacing: 0.14em;
    }

    .result-panel {
        width: calc(100vw - 24px);
        max-width: none;
        z-index: 320;
    }

    .result-frame {
        padding: 24px 20px 22px;
        border-radius: 18px;
    }

    .result-title {
        font-size: 22px;
        margin-bottom: 18px;
        letter-spacing: 0.12em;
    }

    .result-text {
        font-size: 18px;
        line-height: 1.7;
        letter-spacing: 0.05em;
    }

    .next-button {
        width: 100%;
        padding: 14px 18px;
        font-size: 18px;
    }

    .modal {
        align-items: flex-end;
        padding: 16px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
    }

    .modal-content {
        width: min(100%, 560px);
        max-height: min(82dvh, 740px);
        border-radius: 24px;
        transform: translateY(22px);
    }

    .modal.show .modal-content {
        transform: translateY(0);
    }

    .modal-header {
        padding: 18px 20px;
    }

    .modal-title {
        font-size: 20px;
        letter-spacing: 0.08em;
    }

    .modal-body {
        padding: 20px;
    }

    .user-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .remove-user-button {
        align-self: flex-end;
    }

    .record-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .record-buttons {
        width: 100%;
    }

    .record-button {
        flex: 1;
        width: auto;
    }

    .confirm-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .confirm-summary-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .back-button,
    .proceed-button,
    .submit-button {
        width: 100%;
        padding: 16px 18px;
        font-size: 18px;
    }

    .angel-modal-content,
    .madness-modal-content {
        width: min(100%, 560px);
    }

    .angel-header,
    .madness-header {
        padding: 20px 20px 10px;
    }

    .angel-body,
    .madness-body {
        padding: 10px 20px 22px;
    }

    .angel-title,
    .madness-title {
        font-size: 22px;
        letter-spacing: 0.12em;
    }

    .angel-slot-window,
    .madness-slot-window {
        width: min(100%, 320px);
        height: 200px;
    }

    .angel-slot-item,
    .madness-slot-item {
        height: 68px;
        font-size: 17px;
        padding: 0 12px;
    }

    .madness-slot-item.final {
        font-size: 18px;
    }

    .angel-result-text,
    .madness-result-text {
        font-size: 18px;
    }

    .escape-success-content {
        width: calc(100vw - 28px);
        padding: 36px 22px 28px;
        border-radius: 18px;
    }

    .escape-success-title {
        font-size: clamp(36px, 12vw, 52px);
        letter-spacing: 0.16em;
    }

    .escape-success-text {
        font-size: 20px;
        letter-spacing: 0.08em;
        margin-bottom: 22px;
    }

    .escape-success-close {
        width: 100%;
        padding: 14px 20px;
        font-size: 18px;
    }
    
    .escape-counter {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 14px);
        left: 14px;
        z-index: 240;
        font-size: 14px;
        min-height: 44px;
        padding: 8px 12px;
        max-width: calc(100vw - 96px);
    }
}

/* ============================================================
   ルーム参加オーバーレイ
   ============================================================ */

.room-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 3, 2, 0.97);
    backdrop-filter: blur(4px);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.room-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.room-card {
    background: linear-gradient(160deg, #1a1510 0%, #0f0c08 100%);
    border: 1px solid #5a4a2a;
    border-radius: 12px;
    padding: 48px 40px 40px;
    width: min(480px, 92vw);
    text-align: center;
    box-shadow:
        0 0 60px rgba(212, 175, 55, 0.08),
        0 0 0 1px rgba(212, 175, 55, 0.12) inset;
    position: relative;
}

.room-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #d4af37, transparent);
    border-radius: 12px 12px 0 0;
}

.room-title {
    font-family: 'Cinzel', serif;
    font-size: 26px;
    font-weight: 700;
    color: #d4af37;
    letter-spacing: 0.15em;
    margin-bottom: 6px;
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

.room-subtitle {
    font-size: 13px;
    color: #8b7355;
    margin-bottom: 32px;
    letter-spacing: 0.05em;
}

.room-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.room-option-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: 'Noto Serif JP', serif;
}

.room-option-btn:hover {
    transform: translateY(-2px);
}

.room-option-icon {
    font-size: 24px;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}

.room-option-label {
    font-size: 15px;
    font-weight: 600;
    display: block;
    line-height: 1.3;
}

.room-option-desc {
    font-size: 11px;
    display: block;
    opacity: 0.65;
    margin-top: 2px;
}

.host-btn {
    border-color: rgba(212, 175, 55, 0.4);
    color: #f5f0e8;
}
.host-btn:hover {
    border-color: #d4af37;
    background: rgba(212, 175, 55, 0.08);
    box-shadow: 0 0 16px rgba(212, 175, 55, 0.15);
}

.join-btn {
    border-color: rgba(100, 160, 200, 0.3);
    color: #c8e0ef;
}
.join-btn:hover {
    border-color: #64a0c8;
    background: rgba(100, 160, 200, 0.08);
}

.solo-btn {
    border-color: rgba(120, 120, 120, 0.25);
    color: #a0a0a0;
}
.solo-btn:hover {
    border-color: #888;
    background: rgba(150, 150, 150, 0.06);
}

/* --- 参加コード入力 --- */
.room-join-label {
    font-size: 14px;
    color: #c9a961;
    margin-bottom: 16px;
    letter-spacing: 0.05em;
}

.room-join-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.room-code-input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #5a4a2a;
    border-radius: 6px;
    color: #f5f0e8;
    font-family: 'Cinzel', monospace;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-align: center;
    text-transform: uppercase;
    transition: border-color 0.2s;
}

.room-code-input:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

.room-code-input::placeholder {
    color: #4a3a1a;
    font-size: 14px;
    letter-spacing: 0.05em;
}

.room-join-submit {
    padding: 12px 20px;
    background: linear-gradient(135deg, #d4af37, #b8922a);
    border: none;
    border-radius: 6px;
    color: #1a1000;
    font-family: 'Noto Serif JP', serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.room-join-submit:hover {
    background: linear-gradient(135deg, #e8c44a, #d4af37);
    transform: translateY(-1px);
}

.room-back-btn {
    background: none;
    border: none;
    color: #8b7355;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 8px;
    transition: color 0.2s;
    font-family: 'Noto Serif JP', serif;
}
.room-back-btn:hover { color: #c9a961; }

/* --- ルーム作成完了表示 --- */
.room-created-label {
    font-size: 13px;
    color: #8b7355;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.room-code-display {
    font-family: 'Cinzel', monospace;
    font-size: 38px;
    font-weight: 700;
    color: #d4af37;
    letter-spacing: 0.18em;
    padding: 20px 16px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    margin: 0 auto 16px;
    word-break: break-all;
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
}

.room-created-hint {
    font-size: 12px;
    color: #6a5535;
    margin-bottom: 28px;
    letter-spacing: 0.03em;
}

.room-start-btn {
    padding: 14px 40px;
    background: linear-gradient(135deg, #d4af37, #b8922a);
    border: none;
    border-radius: 8px;
    color: #1a1000;
    font-family: 'Cinzel', serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.25s;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.25);
}
.room-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(212, 175, 55, 0.4);
}

/* --- エラー / ローディング --- */
.room-error {
    margin-top: 16px;
    padding: 10px 16px;
    background: rgba(200, 50, 50, 0.15);
    border: 1px solid rgba(200, 50, 50, 0.4);
    border-radius: 6px;
    color: #f87171;
    font-size: 13px;
    animation: fadeIn 0.3s ease;
}

.room-loading {
    margin-top: 20px;
    color: #8b7355;
    font-size: 14px;
    animation: pulse 1.2s infinite;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   ルームモード表示バッジ（右上）
   ============================================================ */

.room-mode-indicator {
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 200;
    padding: 6px 14px;
    background: rgba(10, 8, 5, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 20px;
    font-family: 'Noto Serif JP', serif;
    font-size: 12px;
    color: #c9a961;
    letter-spacing: 0.03em;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

@media (max-width: 768px) {
    .room-overlay {
        align-items: flex-start;
        overflow-y: auto;
        padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
    }

    .room-card {
        width: 100%;
        padding: 34px 20px 22px;
        border-radius: 18px;
    }

    .room-title {
        font-size: 22px;
        letter-spacing: 0.12em;
    }

    .room-subtitle {
        margin-bottom: 24px;
        font-size: 12px;
    }

    .room-option-btn {
        gap: 12px;
        padding: 14px 16px;
    }

    .room-option-icon {
        width: 30px;
        font-size: 22px;
    }

    .room-option-label {
        font-size: 14px;
    }

    .room-option-desc {
        font-size: 10px;
    }

    .room-join-input-row {
        flex-direction: column;
    }

    .room-code-input,
    .room-join-submit,
    .room-start-btn {
        width: 100%;
    }

    .room-code-input {
        font-size: 16px;
        letter-spacing: 0.12em;
    }

    .room-code-display {
        font-size: clamp(24px, 8vw, 32px);
        padding: 16px 12px;
        letter-spacing: 0.14em;
    }

    .room-created-hint {
        margin-bottom: 22px;
    }

    .room-mode-indicator {
        top: calc(env(safe-area-inset-top, 0px) + 72px);
        bottom: auto;
        left: 50%;
        max-width: calc(100vw - 28px);
        transform: translateX(-50%);
        text-align: center;
    }
}

/* ビューアモード: 回すボタンを非表示 */
body.viewer-mode .start-button {
    display: none !important;
}

/* ビューアモード: 設定ボタン・追加ボタンを無効化 */
body.viewer-mode .settings-button,
body.viewer-mode .add-user-button,
body.viewer-mode .reset-buttons-grid button {
    opacity: 0.4;
    pointer-events: none;
}

body.viewer-mode #nextButton {
    display: none !important;
}
