/* 🀄 聴牌で GO! - モダンデザイン */

/* ========== 基礎スタイル ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    background-color: var(--theme-bg-deep);
    background:
        radial-gradient(circle at 20% 20%, rgba(242, 208, 138, 0.08) 0%, transparent 45%),
        radial-gradient(circle at 80% 80%, rgba(22, 82, 58, 0.35) 0%, transparent 55%),
        linear-gradient(145deg, var(--theme-bg) 0%, var(--theme-bg-deep) 100%);
    position: relative;
    min-height: 100vh;
    font-family: 'Noto Sans JP', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
    overscroll-behavior: none;
    display: flex;
    /* 16:9 ステージを上寄せに固定し、短い画面で上部に大きな余白が出ないようにする */
    align-items: flex-start;
    justify-content: center;
    padding: 8px;
}

html[lang="zh"] body {
    font-family: 'Noto Sans TC', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

/* ========== ゲーム中レイアウト圧縮（問題エリアの余白確保） ========== */
body.in-game header {
    display: none;
}

body.in-game .design-root {
    padding: 1rem;
}

body.in-game footer {
    /* フッター行は縦スペースを取り、はみ出しのように見えることがあるため非表示 */
    display: none;
}

body.in-game #game-screen.screen-container {
    padding: 1rem;
}

/* ゲーム画面内の Tailwind 余白を上書き（詰めて表示） */
body.in-game #game-screen .mb-6 {
    margin-bottom: 0.75rem !important;
}

/* 手牌と待ち牌選択の間に余白を追加（縦方向に余裕があるため） */
body.in-game #game-screen .wait-section {
    margin-top: 1.4rem;
}

body.in-game #hand-title,
body.in-game #select-waiting-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem !important;
}

body.in-game #question-number {
    font-size: 1.6rem;
}

body.in-game #lives-display {
    font-size: 1.1rem;
}

/* ========== 16:9 固定比率スケール舞台（設計基準：1280x720） ========== */
:root {
    --ui-scale: 1;
    --transition-ui-button: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease;
    --transition-bounce: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --transition-bounce-fast: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --transition-soft: all 0.3s ease;
    --transition-expand: width 0.6s, height 0.6s;
    --theme-bg: #0b1f15;
    --theme-bg-deep: #08150f;
    --theme-felt: #0f3b2a;
    --theme-felt-light: #16523a;
    --theme-wood: #7a4a28;
    --theme-wood-dark: #5a331a;
    --theme-gold: #d9b26f;
    --theme-gold-bright: #f2d08a;
    --theme-border: rgba(217, 178, 111, 0.35);
    --theme-glow: rgba(217, 178, 111, 0.25);
}

.scale-stage {
    width: 1280px;
    height: 720px;
    flex: 0 0 auto;
    transform: scale(var(--ui-scale));
    transform-origin: top center;
}

/* デバッグ用（?debug=1 で有効） */
.scale-stage.debug-outline {
    outline: 2px dashed rgba(255, 255, 255, 0.35);
    outline-offset: -2px;
}

.scale-debug {
    position: fixed;
    left: 8px;
    bottom: 8px;
    z-index: 9999;
    white-space: pre;
    font-size: 12px;
    line-height: 1.35;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.9);
    pointer-events: none;
}

.design-root {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    position: relative;
}

.app-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.app-main > .screen-container {
    flex: 1;
    min-height: 0;
}

/* 非ゲーム画面は必要に応じて内部スクロール（ページ自体はスクロールしない） */
#language-screen,
#mode-screen,
#difficulty-screen {
    overflow: auto;
    -ms-overflow-style: none; /* IE/Edge（旧） */
    scrollbar-width: none; /* Firefox 用 */
    overscroll-behavior: contain;
}

/* WebKit：スクロールバーは非表示（スクロールは可能） */
#language-screen::-webkit-scrollbar,
#mode-screen::-webkit-scrollbar,
#difficulty-screen::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* 動的背景 - 柔らかい星空エフェクト */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.04) 0%, transparent 55%),
        radial-gradient(circle at 65% 75%, rgba(0, 0, 0, 0.25) 0%, transparent 60%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 6px);
    animation: pulse-bg 8s ease-in-out infinite;
    z-index: -2;
    pointer-events: none;
}

/* 回転する光のにじみ - ソフト版 */
body::after {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle, rgba(217, 178, 111, 0.08) 0%, transparent 45%);
    animation: rotate-bg 30s linear infinite;
    z-index: -1;
    pointer-events: none;
}

/* iOS / iPadOS Safari: avoid occasional white background artifacts from fixed pseudo layers + blur */
body.ios-texture-compat {
    background:
        radial-gradient(circle at 20% 20%, rgba(242, 208, 138, 0.08) 0%, transparent 45%),
        radial-gradient(circle at 80% 80%, rgba(22, 82, 58, 0.35) 0%, transparent 55%),
        linear-gradient(145deg, var(--theme-bg) 0%, var(--theme-bg-deep) 100%);
}

body.ios-texture-compat::before,
body.ios-texture-compat::after {
    display: none;
}

body.ios-texture-compat .screen-container,
body.ios-texture-compat .tutorial-overlay,
body.ios-texture-compat #result-section,
body.ios-texture-compat .timer-container,
body.ios-texture-compat .result-container,
body.ios-texture-compat .victory-content,
body.ios-texture-compat .gameover-content {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* 時間切迫時の背景エフェクト */
body.time-critical::before {
    background:
        radial-gradient(circle at 20% 30%, rgba(220, 38, 38, 0.09) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(239, 68, 68, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(185, 28, 28, 0.08) 0%, transparent 50%);
    animation: pulse-bg-danger 1.5s ease-in-out infinite;
}

body.time-critical::after {
    background: 
        radial-gradient(circle, rgba(220, 38, 38, 0.05) 0%, transparent 40%);
}

@keyframes pulse-bg-danger {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@keyframes pulse-bg {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

@keyframes rotate-bg {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== タイトルスタイル ========== */
#header-title {
    background: linear-gradient(135deg, #f5e1a6 0%, #d9b26f 55%, #b07a3a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-size: 200% 200%;
    animation: gradient-text 3s ease infinite;
    filter: drop-shadow(0 0 20px rgba(217, 178, 111, 0.35))
            drop-shadow(0 4px 20px rgba(0, 0, 0, 0.3));
}

@keyframes gradient-text {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

#header-subtitle {
    text-shadow: 0 2px 10px rgba(15, 59, 42, 0.55);
}

/* ========== コンテナスタイル ========== */
.screen-container {
    background: linear-gradient(135deg, rgba(15, 59, 42, 0.85) 0%, rgba(11, 32, 22, 0.75) 100%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    backdrop-filter: blur(18px) saturate(140%);
    border-radius: 24px;
    padding: 3rem;
    border: 2px solid var(--theme-border);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 0 60px var(--theme-glow);
    position: relative;
    overflow: hidden;
}

/* ========== プリロード画面 ========== */
.preload-progress-wrap {
    width: 100%;
}

.preload-progress-bar {
    height: 16px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.preload-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, rgba(217, 178, 111, 0.95) 0%, rgba(242, 208, 138, 0.95) 50%, rgba(154, 102, 52, 0.95) 100%);
    transition: width 0.18s ease;
}

/* ========== チュートリアル ========== */
.tutorial-btn {
    position: absolute;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 9999px;
    border: 2px solid var(--theme-border);
    background: rgba(15, 59, 42, 0.8);
    color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    transition: var(--transition-ui-button);
}

.nav-back-btn {
    position: absolute;
    left: 18px;
    top: 18px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 9999px;
    border: 2px solid var(--theme-border);
    background: rgba(15, 59, 42, 0.8);
    color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    transition: var(--transition-ui-button);
}

.nav-back-btn:hover {
    transform: translateY(-1px);
    background: rgba(22, 82, 58, 0.9);
    border-color: rgba(242, 208, 138, 0.45);
}

.nav-back-btn:active {
    transform: translateY(0px) scale(0.98);
}

/* チュートリアルのオーバーレイ（結果モーダル同様に内部スクロール） */
.tutorial-overlay {
    position: absolute;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 21, 15, 0.9);
    backdrop-filter: blur(16px) saturate(140%);
}

.tutorial-modal {
    width: min(980px, 94%);
    height: min(640px, calc(100% - 64px));
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    border: 2px solid var(--theme-border);
    background: linear-gradient(135deg, rgba(15, 59, 42, 0.92) 0%, rgba(11, 32, 22, 0.82) 100%);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.tutorial-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.tutorial-modal-title-wrap {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.tutorial-modal-title {
    font-size: 2.2rem;
    font-weight: 900;
    line-height: 1.1;
    white-space: nowrap;
}

.tutorial-modal-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.tutorial-modal-body {
    padding: 18px;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    -ms-overflow-style: none; /* IE/Edge（旧） */
    scrollbar-width: none; /* Firefox 用 */
}

.tutorial-modal-body::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.tutorial-btn:hover {
    transform: translateY(-1px) scale(1.03);
    background: rgba(22, 82, 58, 0.9);
    border-color: rgba(242, 208, 138, 0.45);
}

.tutorial-btn-text {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.tutorial-section {
    padding: 1.5rem 1.25rem;
    border-radius: 20px;
    border: 2px solid rgba(217, 178, 111, 0.25);
    background: rgba(15, 59, 42, 0.55);
}

.tutorial-page-indicator {
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tutorial-nav-btn {
    min-width: 180px;
}

.tutorial-nav-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}

.tutorial-close-btn {
    min-width: 180px;
    border-color: rgba(239, 68, 68, 0.35) !important;
}

.tutorial-close-btn:hover {
    border-color: rgba(239, 68, 68, 0.55) !important;
}

.tutorial-body {
    white-space: pre-line;
    opacity: 0.95;
}

.tutorial-visual {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid rgba(217, 178, 111, 0.28);
    background: rgba(8, 21, 15, 0.45);
    display: grid;
    gap: 0.75rem;
}

.tutorial-visual-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: rgba(242, 208, 138, 0.95);
    text-align: center;
}

.tutorial-visual-text {
    font-size: 0.95rem;
    line-height: 1.5;
    text-align: center;
    opacity: 0.92;
    white-space: pre-line;
}

.tutorial-tile-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.tutorial-row-label {
    min-width: 126px;
    font-size: 0.92rem;
    font-weight: 700;
    opacity: 0.9;
    text-align: right;
}

.tutorial-row-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.tutorial-mini-tile {
    width: 34px;
    height: 48px;
    border-radius: 8px;
    border: 1px solid #d2d2d2;
    background: linear-gradient(145deg, #ffffff, #f2f2f2);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.16),
        inset 0 1px 2px rgba(255, 255, 255, 0.92);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tutorial-mini-tile .tile-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tutorial-mini-tile.is-disabled {
    opacity: 0.35;
    filter: grayscale(0.9) saturate(0.25);
}

.tutorial-mini-tile.is-selected {
    border-color: rgba(134, 239, 172, 0.7);
    box-shadow: 0 0 0 2px rgba(134, 239, 172, 0.22);
}

.tutorial-mini-tile.is-crossed::after {
    content: '✕';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(248, 113, 113, 0.92);
    font-size: 1.15rem;
    font-weight: 900;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.tutorial-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.tutorial-chip {
    padding: 6px 10px;
    border-radius: 9999px;
    border: 1px solid rgba(217, 178, 111, 0.28);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
}

.tutorial-pattern-item {
    display: grid;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.03);
}

.tutorial-pattern-label {
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    opacity: 0.95;
}

.tutorial-pattern-groups {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tutorial-pattern-arrow {
    opacity: 0.8;
    font-weight: 800;
}

.tutorial-step-btn {
    border: 1px solid rgba(217, 178, 111, 0.36);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.96);
    border-radius: 9999px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-ui-button);
}

.tutorial-step-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(242, 208, 138, 0.62);
    background: rgba(255, 255, 255, 0.1);
}

.tutorial-step-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.tutorial-step-btn--ghost {
    border-style: dashed;
}

.tutorial-breakdown-wrap {
    display: grid;
    gap: 10px;
    margin-top: 4px;
}

.tutorial-breakdown-title {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 800;
    color: rgba(242, 208, 138, 0.95);
}

.tutorial-breakdown-item {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    padding: 10px;
    display: grid;
    gap: 8px;
    overflow: hidden;
}

.tutorial-breakdown-wait {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 700;
}

.tutorial-breakdown-stage .breakdown-bubble {
    gap: 0.75rem;
    padding: 0.75rem;
}

.tutorial-breakdown-stage .breakdown-source-row {
    gap: 0.35rem;
}

.tutorial-breakdown-stage .breakdown-target-groups {
    gap: 1rem;
}

.tutorial-breakdown-stage .breakdown-source-gap {
    flex-basis: 0.8rem;
}

.tutorial-breakdown-stage .breakdown-target-group {
    gap: 0.45rem;
}

.tutorial-breakdown-stage .breakdown-target-board,
.tutorial-breakdown-stage .breakdown-target-row {
    gap: 0.35rem;
}

.tutorial-breakdown-stage .breakdown-target-slot {
    width: 40px;
    height: 56px;
}

.tutorial-breakdown-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.tutorial-breakdown-group {
    display: grid;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(8, 21, 15, 0.35);
}

.tutorial-breakdown-label {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    opacity: 0.9;
}

/* ========== 選択不可の牌（同牌4枚使用済み） ========== */
.tile-disabled {
    opacity: 0.22;
    filter: grayscale(0.95) saturate(0.2);
    cursor: not-allowed !important;
    pointer-events: none;
    transform: none !important;
}

#game-screen {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.sound-toggle-btn {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    z-index: 24;
    width: 3.2rem;
    height: 3.2rem;
    border: 1px solid rgba(217, 178, 111, 0.3);
    border-radius: 999px;
    background: linear-gradient(145deg, rgba(15, 59, 42, 0.92), rgba(8, 21, 15, 0.86));
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    font-size: 1.4rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-soft);
}

.sound-toggle-btn:hover {
    transform: translateY(-1px) scale(1.03);
    border-color: rgba(242, 208, 138, 0.52);
}

.sound-toggle-btn.is-muted {
    border-color: rgba(148, 163, 184, 0.34);
    background: linear-gradient(145deg, rgba(34, 42, 51, 0.92), rgba(15, 23, 32, 0.88));
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ========== ステージ開始オーバーレイ（問題間） ========== */
.stage-intro {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    background: rgba(8, 21, 15, 0.9);
    backdrop-filter: blur(10px) saturate(135%);
}

.stage-intro-card {
    width: min(820px, 92%);
    padding: 2.2rem 2rem;
    border-radius: 24px;
    border: 2px solid var(--theme-border);
    background: linear-gradient(135deg, rgba(15, 59, 42, 0.92) 0%, rgba(11, 32, 22, 0.82) 100%);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
    text-align: center;
    animation: stageIntroIn 0.55s ease-out;
}

.stage-intro-title {
    font-weight: 900;
    font-size: 3rem;
    line-height: 1.1;
    margin-bottom: 0.75rem;
    text-shadow: 0 6px 26px rgba(0, 0, 0, 0.35);
}

.stage-intro-subtitle {
    font-weight: 700;
    font-size: 1.35rem;
    line-height: 1.3;
    opacity: 0.95;
}

.stage-intro.is-leaving {
    animation: stageIntroOut 0.45s ease-in forwards;
}

@keyframes stageIntroIn {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes stageIntroOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* HUD：上段レイアウト（左：ステージ/ライフ、中央：時間、右：延長ボタン） */
.hud-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.75rem;
    align-items: start;
    margin-bottom: 0.6rem;
}

.hud-top .hud-left {
    justify-self: start;
}

.hud-top .hud-center {
    justify-self: center;
    text-align: center;
}

.hud-top .hud-right {
    justify-self: end;
    display: flex;
    align-items: flex-start;
}

#question-number {
    font-size: 1.6rem;
    line-height: 1.1;
}

#stage-info {
    font-size: 1rem;
    line-height: 1.2;
}

/* ========== 難易度アクセント（HUDの視認性向上） ========== */
.difficulty-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.6rem;
    border-radius: 9999px;
    font-weight: 900;
    letter-spacing: 0.02em;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
}

.difficulty-badge--easy {
    color: rgb(134 239 172); /* Tailwind の green-300 相当 */
    border-color: rgba(134, 239, 172, 0.35);
    background: rgba(34, 197, 94, 0.12);
}

.difficulty-badge--medium {
    color: rgb(253 224 71); /* Tailwind の yellow-300 相当 */
    border-color: rgba(253, 224, 71, 0.35);
    background: rgba(234, 179, 8, 0.12);
}

.difficulty-badge--hard {
    color: rgb(252 165 165); /* Tailwind の red-300 相当 */
    border-color: rgba(252, 165, 165, 0.35);
    background: rgba(239, 68, 68, 0.12);
}

.difficulty-accent--easy {
    color: rgb(134 239 172);
}

.difficulty-accent--medium {
    color: rgb(253 224 71);
}

.difficulty-accent--hard {
    color: rgb(252 165 165);
}

#stage-info:empty {
    display: none;
}

#lives-display {
    font-size: 1.1rem;
}

#time-bonus-display {
    font-size: 1.05rem;
    color: #fde047;
}

.hud-left,
.hud-center,
.hud-right {
    min-width: 0;
}

/* メインプレイエリア（ページスクロールなし） */
#game-screen .game-main {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.action-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
}

.action-btn {
    padding: 1.1rem 1.4rem;
    border-radius: 14px;
    font-size: 1.1rem;
}

body.in-game .action-btn {
    padding: 0.9rem 1.1rem;
    font-size: 1rem;
}

.selection-status-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.9rem;
    text-align: center;
}

.selection-status {
    min-height: 1.6rem;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: rgba(255, 244, 214, 0.95);
}

.selection-status[data-state="empty"] {
    color: rgb(254 202 202);
}

.selection-status[data-state="ready"] {
    color: rgb(187 247 208);
}

.selection-status[data-state="locked"] {
    color: rgba(255, 244, 214, 0.78);
}

.selection-hint {
    min-height: 1.3rem;
    font-size: 0.88rem;
    color: rgba(255, 244, 214, 0.72);
}

/* 中央タイマー：数値はバーの上 */
.hud-center #timer-display {
    font-size: 2.6rem;
    line-height: 1;
    margin-bottom: 0.35rem;
}

.hud-center .timer-bar-container {
    width: min(520px, 46vw);
    height: 12px;
    margin: 0 auto;
}

body.in-game .hud-center .timer-bar-container {
    height: 10px;
}

body.in-game .time-extension-btn {
    padding: 0.55rem 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
}

.timer-value {
    font-variant-numeric: tabular-nums;
    font-weight: 900;
    text-shadow: 0 0 30px rgba(76, 175, 80, 0.8), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.time-extension-slot {
    margin-top: 0;
    text-align: right;
}

body.in-game .time-extension-slot {
    margin-top: 0;
}

/* 結果：ライフ減少のヒント + 消失アニメーション */
.result-lives {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.35rem;
    font-size: 2rem;
    line-height: 1;
}

.life-heart {
    display: inline-block;
    transform-origin: center;
}

.life-heart.heart-toggle {
    position: relative;
    width: 1em;
    height: 1em;
}

.life-heart.heart-toggle .heart-on,
.life-heart.heart-toggle .heart-off {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.life-heart.heart-toggle.pending-loss .heart-on {
    animation: heart-on 0.9s ease-in-out infinite;
}

.life-heart.heart-toggle.pending-loss .heart-off {
    animation: heart-off 0.9s ease-in-out infinite;
}

.life-heart.heart-toggle.removing .heart-on {
    animation: heart-remove 0.35s ease-out forwards;
}

.life-heart.heart-toggle.removing .heart-off {
    opacity: 1;
}

@keyframes heart-on {
    0%, 100% { opacity: 0.95; transform: scale(1); }
    50% { opacity: 0.15; transform: scale(0.95); }
}

@keyframes heart-off {
    0%, 100% { opacity: 0.15; transform: scale(0.95); }
    50% { opacity: 0.95; transform: scale(1.06); }
}

@keyframes heart-remove {
    from { opacity: 0.95; transform: scale(1); }
    to { opacity: 0; transform: scale(0.2); }
}

/* （コンティニュー / ゲームオーバーは結果モーダル内に表示） */

/* 結果モーダルのオーバーレイ（フレーム内のみスクロール） */
#result-section {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(6, 14, 10, 0.92);
    backdrop-filter: blur(10px);
}

#result-section.hidden {
    display: none;
}

#result-section .result-container {
    width: min(980px, 100%);
    height: 100%;
    overflow: auto;
}

.result-groups {
    display: grid;
    gap: 1rem;
}

.result-group {
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.result-group--correct {
    border-color: rgba(34, 197, 94, 0.28);
    background: linear-gradient(135deg, rgba(20, 83, 45, 0.28), rgba(20, 83, 45, 0.12));
}

.result-group--missed {
    border-color: rgba(245, 158, 11, 0.3);
    background: linear-gradient(135deg, rgba(120, 53, 15, 0.28), rgba(120, 53, 15, 0.12));
}

.result-group--wrong {
    border-color: rgba(239, 68, 68, 0.3);
    background: linear-gradient(135deg, rgba(127, 29, 29, 0.28), rgba(127, 29, 29, 0.12));
}

.result-group-title {
    margin: 0 0 0.8rem;
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.02em;
    text-align: center;
}

.result-group-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.screen-container::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg,
        rgba(217, 178, 111, 0.2),
        rgba(242, 208, 138, 0.2),
        rgba(122, 74, 40, 0.2),
        rgba(217, 178, 111, 0.2));
    background-size: 300% 300%;
    animation: border-glow 6s linear infinite;
    border-radius: 24px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.screen-container:hover::before {
    opacity: 1;
}

@keyframes border-glow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ========== ボタンスタイル ========== */
.mode-btn {
    background: linear-gradient(135deg, rgba(122, 74, 40, 0.95) 0%, rgba(90, 51, 26, 0.92) 100%);
    border: 2px solid rgba(217, 178, 111, 0.45);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-bounce);
    position: relative;
    overflow: hidden;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.mode-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transform: translate(-50%, -50%);
    transition: var(--transition-expand);
}

.mode-btn:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.45),
        0 0 40px rgba(217, 178, 111, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
    border-color: rgba(242, 208, 138, 0.6);
}

.mode-btn:hover::before {
    width: 400px;
    height: 400px;
}

.mode-btn.keyboard-nav-active,
.nav-back-btn.keyboard-nav-active,
.tutorial-btn.keyboard-nav-active {
    transform: translateY(-6px) scale(1.04);
    border-color: rgba(242, 208, 138, 0.9);
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.45),
        0 0 48px rgba(217, 178, 111, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.mode-btn.keyboard-nav-active::before {
    width: 400px;
    height: 400px;
}

.mode-btn:active {
    transform: translateY(-4px) scale(1.02);
}

.action-btn:disabled {
    cursor: not-allowed;
    transform: none;
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.action-btn:disabled::before {
    display: none;
}

.action-btn[data-state="empty"]:disabled {
    color: rgba(255, 240, 240, 0.82);
    border-color: rgba(248, 113, 113, 0.3);
    background:
        repeating-linear-gradient(
            -45deg,
            rgba(127, 29, 29, 0.22) 0,
            rgba(127, 29, 29, 0.22) 10px,
            rgba(68, 20, 20, 0.16) 10px,
            rgba(68, 20, 20, 0.16) 20px
        ),
        linear-gradient(135deg, rgba(86, 34, 34, 0.92) 0%, rgba(58, 22, 22, 0.94) 100%);
    opacity: 0.68;
}

.action-btn[data-state="locked"]:disabled {
    border-color: rgba(217, 178, 111, 0.2);
    background: linear-gradient(135deg, rgba(76, 58, 43, 0.88) 0%, rgba(53, 40, 29, 0.92) 100%);
    opacity: 0.56;
}

/* （ストーリーモードの「?」ヘルプは削除し、チュートリアルに置換済み） */

/* ========== 麻雀牌スタイル ========== */
.hand-tile {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 3px solid #d0d0d0;
    border-radius: 8px;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.2),
        inset 0 2px 4px rgba(255, 255, 255, 0.8),
        inset 0 -2px 4px rgba(0, 0, 0, 0.1);
    transition: var(--transition-soft);
}

.selectable-tile {
    background: linear-gradient(145deg, #ffffff, #f5f5f5);
    border: 3px solid rgba(217, 178, 111, 0.35);
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: var(--transition-bounce-fast);
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.15),
        inset 0 2px 4px rgba(255, 255, 255, 0.9);
}

/* PNG の麻雀牌画像 */
.tile-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none; /* クリックは牌コンテナ側で受ける */
}

.tile-inline-hand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 45px;
    margin-left: 0.4rem;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.selectable-tile::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 70%
    );
    transform: rotate(45deg);
    transition: all 0.5s;
}

.selectable-tile:hover {
    transform: translateY(-12px) scale(1.08);
    box-shadow: 
        0 16px 32px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(217, 178, 111, 0.35),
        inset 0 2px 4px rgba(255, 255, 255, 1);
    border-color: rgba(242, 208, 138, 0.6);
}

.selectable-tile:hover::before {
    left: 100%;
}

/* 選択された牌 */
.selected {
    background: linear-gradient(145deg, #ffffff, #f5f5f5) !important;
    border: 4px solid #ff1744 !important;
    transform: translateY(-8px) scale(1.12) !important;
    box-shadow: 
        0 0 40px rgba(255, 23, 68, 0.8),
        0 0 80px rgba(255, 23, 68, 0.4),
        0 12px 32px rgba(255, 23, 68, 0.5),
        inset 0 2px 8px rgba(255, 255, 255, 0.4) !important;
    animation: pulse-glow 1.5s ease-in-out infinite;
    z-index: 10;
}

@keyframes pulse-glow {
    0%, 100% { 
        box-shadow: 
            0 0 40px rgba(255, 23, 68, 0.8),
            0 0 80px rgba(255, 23, 68, 0.4),
            0 12px 32px rgba(255, 23, 68, 0.5),
            inset 0 2px 8px rgba(255, 255, 255, 0.4);
    }
    50% { 
        box-shadow: 
            0 0 60px rgba(255, 23, 68, 1),
            0 0 120px rgba(255, 23, 68, 0.6),
            0 12px 32px rgba(255, 23, 68, 0.7),
            inset 0 2px 8px rgba(255, 255, 255, 0.6);
    }
}

/* 正解の牌 */
.correct-selected {
    background: linear-gradient(145deg, #ffffff, #f5f5f5) !important;
    border: 4px solid #00c853 !important;
    transform: translateY(-10px) scale(1.12) !important;
    box-shadow: 
        0 0 18px rgba(0, 230, 118, 1),
        0 0 48px rgba(0, 230, 118, 0.72),
        0 0 96px rgba(0, 230, 118, 0.34),
        0 12px 32px rgba(0, 200, 83, 0.6) !important;
    animation: correct-bounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 11;
}

.correct-missed {
    background: linear-gradient(145deg, #ffffff, #f5f5f5) !important;
    border: 4px solid #ffa000 !important;
    box-shadow: 
        0 0 40px rgba(255, 193, 7, 0.9),
        0 0 80px rgba(255, 193, 7, 0.5) !important;
    animation: correct-bounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.incorrect-selected {
    background: linear-gradient(145deg, #ffffff, #f5f5f5) !important;
    border: 4px solid #d32f2f !important;
    box-shadow: 
        0 0 40px rgba(244, 67, 54, 0.9),
        0 0 80px rgba(244, 67, 54, 0.5) !important;
    animation: shake-wrong 0.6s ease-in-out;
}

@keyframes correct-bounce {
    0% { transform: scale(1) translateY(0); }
    30% { transform: scale(1.2) translateY(-20px); }
    50% { transform: scale(0.95) translateY(-10px); }
    70% { transform: scale(1.05) translateY(-15px); }
    100% { transform: scale(1) translateY(0); }
}

@keyframes shake-wrong {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px) rotate(-3deg); }
    20%, 40%, 60%, 80% { transform: translateX(8px) rotate(3deg); }
}

/* ========== タイマー ========== */
.timer-container {
    background: linear-gradient(135deg, rgba(22, 82, 58, 0.35), rgba(15, 59, 42, 0.25));
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 2px solid rgba(217, 178, 111, 0.35);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.timer-bar-container {
    width: 100%;
    height: 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
    position: relative;
}

.timer-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A, #CDDC39);
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
    transition: width 1s linear;
    border-radius: 12px;
    box-shadow: 
        0 0 20px rgba(76, 175, 80, 0.6),
        inset 0 1px 2px rgba(255, 255, 255, 0.5);
    position: relative;
    /* トランジションを外し、CSS 変数でアニメーションを制御 */
    will-change: width;
}

/* ========== Low Power / Reduced Motion (Mobile performance) ========== */
/* JS may add body.low-power automatically on mobile/save-data/reduced-motion.
   You can force it with ?lowpower=1 or disable with ?lowpower=0 */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

body.low-power::before,
body.low-power::after {
    animation: none !important;
}

body.low-power #header-title {
    animation: none !important;
    filter: none;
}

body.low-power .screen-container {
    backdrop-filter: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

body.low-power .timer-bar,
body.low-power .timer-bar-danger {
    animation: none !important;
}

body.low-power .timer-warning,
body.low-power .timer-danger {
    animation: none !important;
}

body.low-power .animate-bounce,
body.low-power .animate-pulse {
    animation: none !important;
}

/* Reduce expensive effects in-game */
body.low-power .screen-container::before {
    animation: none !important;
    opacity: 0 !important;
}

body.low-power #result-section,
body.low-power .victory-screen,
body.low-power .gameover-screen {
    backdrop-filter: none !important;
}

body.low-power .result-container {
    backdrop-filter: none !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

body.low-power .timer-container {
    backdrop-filter: none !important;
}

body.low-power .mode-btn,
body.low-power .hand-tile,
body.low-power .selectable-tile {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22) !important;
}

body.low-power .mode-btn:hover,
body.low-power .selectable-tile:hover {
    transform: none !important;
}

body.low-power .mode-btn.keyboard-nav-active,
body.low-power .nav-back-btn.keyboard-nav-active,
body.low-power .tutorial-btn.keyboard-nav-active {
    transform: none !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28) !important;
}

body.low-power .mode-btn::before,
body.low-power .selectable-tile::before {
    display: none !important;
}

body.low-power .selected,
body.low-power .correct-selected,
body.low-power .correct-missed,
body.low-power .incorrect-selected {
    animation: none !important;
}

body.low-power .selected {
    box-shadow:
        0 0 18px rgba(255, 23, 68, 0.45),
        0 10px 22px rgba(0, 0, 0, 0.22) !important;
}

body.low-power .timer-value,
body.low-power #timer-display,
body.low-power .text-shadow-glow {
    text-shadow: none !important;
}

body.low-power .boss-stage::before {
    animation: none !important;
    filter: none !important;
}

body.low-power .boss-title {
    animation: none !important;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45) !important;
    filter: none !important;
}

body.low-power .victory-content,
body.low-power .gameover-content {
    animation: none !important;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45) !important;
}

body.low-power .confetti {
    display: none !important;
}

/* Pause heavy animations when the game is paused (no visual impact while paused). */
body.effects-paused::before,
body.effects-paused::after {
    animation: none !important;
}

body.effects-paused #header-title,
body.effects-paused .timer-bar,
body.effects-paused .timer-bar-danger,
body.effects-paused .animate-bounce,
body.effects-paused .animate-pulse,
body.effects-paused .screen-container::before,
body.effects-paused .boss-stage::before,
body.effects-paused .confetti {
    animation: none !important;
}

.timer-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), transparent);
    border-radius: 12px 12px 0 0;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.timer-bar-warning {
    background: linear-gradient(90deg, #FFC107, #FFD54F, #FFEB3B) !important;
    box-shadow: 
        0 0 30px rgba(255, 193, 7, 0.8),
        inset 0 1px 2px rgba(255, 255, 255, 0.5) !important;
}

.timer-bar-danger {
    background: linear-gradient(90deg, #F44336, #E57373, #EF5350) !important;
    animation: pulse-danger 0.5s ease-in-out infinite, shimmer 2s linear infinite !important;
    box-shadow: 
        0 0 40px rgba(244, 67, 54, 1),
        inset 0 1px 2px rgba(255, 255, 255, 0.5) !important;
}

@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

#timer-display {
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 30px rgba(76, 175, 80, 0.8), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.timer-warning {
    color: #FFC107 !important;
    text-shadow: 0 0 40px rgba(255, 193, 7, 1), 0 4px 12px rgba(0, 0, 0, 0.4) !important;
    animation: pulse-scale 1.25s ease-in-out infinite;
}

.timer-danger {
    color: #F44336 !important;
    text-shadow: 0 0 50px rgba(244, 67, 54, 1), 0 4px 12px rgba(0, 0, 0, 0.4) !important;
    animation: pulse-scale 0.9s ease-in-out infinite;
}

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

/* ========== BOSS ステージ ========== */
.boss-stage {
    position: relative;
}

.boss-stage::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 50% 50%, rgba(220, 20, 60, 0.25) 0%, transparent 70%),
        radial-gradient(circle at 20% 80%, rgba(138, 43, 226, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 20, 147, 0.3) 0%, transparent 50%);
    animation: boss-pulse 2s ease-in-out infinite;
    z-index: -1;
    pointer-events: none;
}

@keyframes boss-pulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
        filter: brightness(1);
    }
    50% { 
        opacity: 0.85; 
        transform: scale(1.02);
        filter: brightness(1.2);
    }
}

.boss-title {
    animation: boss-shake 0.3s ease-in-out infinite, boss-glow 1.5s ease-in-out infinite;
    text-shadow: 
        0 0 30px rgba(220, 20, 60, 1),
        0 0 60px rgba(220, 20, 60, 0.9),
        0 0 90px rgba(220, 20, 60, 0.7),
        0 0 120px rgba(255, 0, 0, 0.5),
        0 4px 20px rgba(0, 0, 0, 0.6);
    transform-origin: center;
}

@keyframes boss-shake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(-2px) rotate(-1deg); }
    75% { transform: translateX(2px) rotate(1deg); }
}

@keyframes boss-glow {
    0%, 100% { 
        text-shadow: 
            0 0 30px rgba(220, 20, 60, 1),
            0 0 60px rgba(220, 20, 60, 0.9),
            0 0 90px rgba(220, 20, 60, 0.7),
            0 0 120px rgba(255, 0, 0, 0.5),
            0 4px 20px rgba(0, 0, 0, 0.6);
        filter: brightness(1);
    }
    50% { 
        text-shadow: 
            0 0 50px rgba(220, 20, 60, 1),
            0 0 100px rgba(220, 20, 60, 1),
            0 0 150px rgba(220, 20, 60, 0.9),
            0 0 200px rgba(255, 0, 0, 0.7),
            0 4px 20px rgba(0, 0, 0, 0.6);
        filter: brightness(1.3);
    }
}

/* ========== 勝利・敗北画面 ========== */
.victory-screen, .gameover-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background: rgba(6, 14, 10, 0.85);
    backdrop-filter: blur(10px);
}

.victory-content {
    background: linear-gradient(135deg, rgba(22, 82, 58, 0.95), rgba(15, 59, 42, 0.95));
    border-radius: 24px;
    padding: 4rem;
    text-align: center;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(217, 178, 111, 0.35);
    animation: victory-appear 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 3px solid rgba(217, 178, 111, 0.55);
}

@keyframes victory-appear {
    0% { opacity: 0; transform: scale(0.3) rotate(-10deg); }
    70% { transform: scale(1.1) rotate(5deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.gameover-content {
    background: linear-gradient(135deg, rgba(92, 40, 28, 0.95), rgba(60, 25, 18, 0.95));
    border-radius: 24px;
    padding: 4rem;
    text-align: center;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(217, 178, 111, 0.25);
    animation: gameover-appear 0.6s ease-out;
    border: 3px solid rgba(217, 178, 111, 0.45);
}

@keyframes gameover-appear {
    0% { opacity: 0; transform: translateY(-100px); }
    60% { transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* 紙吹雪 */
.confetti {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    animation: confetti-fall 3s linear forwards;
    z-index: 1001;
}

@keyframes confetti-fall {
    0% { 
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% { 
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ========== 結果表示 ========== */
.result-container {
    background: linear-gradient(135deg, rgba(11, 32, 22, 0.9), rgba(8, 21, 15, 0.8));
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 2rem;
    border: 2px solid rgba(217, 178, 111, 0.35);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

#correct-answer-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#hand-tiles {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

#possible-tiles {
    display: grid;
    justify-items: center;
    align-items: center;
}

/* ========== アニメーション ========== */
.fade-in {
    animation: fadeIn 0.6s ease-out;
}

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

.slide-down {
    animation: slideDown 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-50px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.text-shadow-glow {
    text-shadow: 
        0 0 40px rgba(255, 215, 0, 0.8),
        0 0 80px rgba(255, 215, 0, 0.6),
        0 4px 20px rgba(0, 0, 0, 0.4);
}

/* ========== 牌形解析 ========== */
#hand-breakdown {
    margin-top: 2rem;
}

.breakdown-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.breakdown-switch-btn {
    border: 1px solid rgba(217, 178, 111, 0.28);
    border-radius: 999px;
    padding: 0.55rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 244, 214, 0.92);
    cursor: pointer;
    transition: var(--transition-soft);
}

.breakdown-switch-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.breakdown-counter {
    min-width: 4.5rem;
    text-align: center;
    font-weight: 800;
    color: #f2d08a;
}

.breakdown-section {
    background: rgba(26, 26, 46, 0.6);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(138, 43, 226, 0.3);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.breakdown-section h3 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: #fbbf24;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
}

.breakdown-section.missed-tile {
    border-color: rgba(234, 179, 8, 0.5);
}

.breakdown-section.selected-tile {
    border-color: rgba(34, 197, 94, 0.5);
}

.breakdown-animation-hint {
    margin: -0.15rem 0 1.1rem;
    text-align: center;
    color: rgba(255, 244, 214, 0.74);
}

.breakdown-stage {
    position: relative;
    overflow: hidden;
}

.breakdown-bubble {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.breakdown-source-row,
.breakdown-target-row {
    display: flex;
    gap: 0.45rem;
    flex-wrap: nowrap;
}

.breakdown-source-row {
    justify-content: center;
    overflow: hidden;
    align-items: flex-start;
    width: 100%;
    min-width: 100%;
    padding-bottom: 0.2rem;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.breakdown-stage-complete .breakdown-source-row {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.breakdown-source-gap {
    flex: 0 0 1.1rem;
}

.breakdown-source-row > *,
.breakdown-target-board > *,
.breakdown-target-row > * {
    flex: 0 0 auto;
}

.breakdown-target-groups {
    display: flex;
    gap: 0.85rem;
    justify-content: flex-start;
    align-items: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    min-width: 100%;
    padding-bottom: 0.2rem;
    transform: translate(var(--breakdown-center-shift-x, 0px), var(--breakdown-center-shift-y, 0px));
    transition: none;
    will-change: transform;
}

.breakdown-stage-centering .breakdown-target-groups {
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.breakdown-target-group {
    position: relative;
    display: grid;
    gap: 0.45rem;
    justify-items: center;
}

.breakdown-target-group-label {
    font-size: 0.9rem;
    color: #5fd1a6;
    margin-bottom: 0.1rem;
    font-weight: 700;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease;
}

.breakdown-target-group.is-complete .breakdown-target-group-label {
    opacity: 1;
    visibility: visible;
}

.breakdown-target-board {
    display: flex;
    gap: 0.45rem;
}

.breakdown-target-slot {
    width: 48px;
    height: 68px;
    border-radius: 12px;
    border: 1px dashed rgba(114, 94, 55, 0.28);
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.breakdown-target-slot.is-filled {
    border-color: rgba(95, 209, 166, 0.45);
    background: rgba(95, 209, 166, 0.08);
    box-shadow: inset 0 0 0 1px rgba(95, 209, 166, 0.12);
}

.breakdown-target-row {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    justify-content: center;
    pointer-events: none;
}

.breakdown-tile {
    transition: opacity 0.28s ease, transform 0.28s ease, box-shadow 0.28s ease;
}

.breakdown-source-tile.is-dealt {
    opacity: 0;
    transform: translateY(-10px) scale(0.78);
    filter: saturate(0.6);
    visibility: hidden;
}

.breakdown-target-tile {
    opacity: 0;
    transform: translateY(-10px) scale(0.84);
    filter: saturate(0.8);
}

.breakdown-target-tile.is-arrived {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: saturate(1);
}

.breakdown-animation-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.breakdown-fly-tile {
    position: absolute;
    margin: 0;
    opacity: 0;
    z-index: 0;
    pointer-events: none;
}

.breakdown-winning-tile {
    border-color: rgba(255, 214, 102, 0.95) !important;
    box-shadow:
        0 0 24px rgba(255, 214, 102, 0.85),
        0 0 48px rgba(255, 214, 102, 0.28),
        0 8px 20px rgba(255, 214, 102, 0.24) !important;
}

.breakdown-section.selected-tile .breakdown-winning-tile {
    border-color: rgba(34, 197, 94, 0.95) !important;
    box-shadow:
        0 0 24px rgba(34, 197, 94, 0.78),
        0 0 48px rgba(34, 197, 94, 0.26),
        0 8px 20px rgba(34, 197, 94, 0.22) !important;
}

.tile-group {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin: 0.75rem 1rem 0.75rem 0;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    text-align: center;
}

.tile-group-label {
    font-size: 0.9rem;
    color: #5fd1a6;
    margin-right: 0;
    margin-bottom: 0.1rem;
    font-weight: 700;
    min-width: 0;
}

@media (max-width: 720px) {
    .breakdown-controls {
        flex-wrap: wrap;
    }

    .breakdown-bubble {
        padding: 0.8rem;
    }

    .breakdown-tile {
        width: 38px !important;
        height: 54px !important;
    }

    .breakdown-target-slot {
        width: 38px;
        height: 54px;
    }

    .breakdown-source-gap {
        flex-basis: 0.75rem;
    }
}

.tile-group .hand-tile {
    margin: 0 2px;
}

/* ========== ライフとコンティニュー選択肢 ========== */
#lives-display {
    font-size: 1.5rem;
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.continue-option {
    animation: slideIn 0.5s ease-out;
}

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

.continue-btn {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.5), rgba(22, 163, 74, 0.4)) !important;
    border-color: rgba(34, 197, 94, 0.5) !important;
}

.continue-btn:hover {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.7), rgba(22, 163, 74, 0.6)) !important;
    box-shadow: 0 16px 48px rgba(34, 197, 94, 0.4) !important;
}

.giveup-btn {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.5), rgba(220, 38, 38, 0.4)) !important;
    border-color: rgba(239, 68, 68, 0.5) !important;
}

.giveup-btn:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.7), rgba(220, 38, 38, 0.6)) !important;
    box-shadow: 0 16px 48px rgba(239, 68, 68, 0.4) !important;
}

/* ========== 時間延長（タイム延長）ボタン ========== */
.time-extension-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: 2px solid rgba(16, 185, 129, 0.3);
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-soft);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.time-extension-btn:disabled {
    opacity: 0.58;
    cursor: not-allowed;
    filter: saturate(0.85);
    transform: none;
}

.time-extension-main {
    display: inline-flex;
    align-items: baseline;
    gap: 0.45rem;
}

.time-extension-cooldown {
    font-size: 0.92em;
    font-weight: 900;
    opacity: 0.95;
    letter-spacing: 0.02em;
}

.time-extension-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.22rem 0.5rem;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    font-variant-numeric: tabular-nums;
}

.time-extension-badge-emoji {
    line-height: 1;
}

.time-extension-count {
    font-weight: 900;
    line-height: 1;
}

.time-extension-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.5);
    background: linear-gradient(135deg, #059669, #047857);
}

.time-extension-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* 残り時間が少ない時の注意喚起（延長が使える場合のみ JS で付与） */
.time-extension-btn.attention:not(:disabled) {
    transform-origin: center;
    animation: timeExtensionAttention 0.9s ease-in-out infinite;
}

.time-extension-btn.cooldown .time-extension-badge {
    animation: timeExtensionCooldownPulse 0.8s ease-in-out infinite;
}

@keyframes timeExtensionCooldownPulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.08); opacity: 1; }
}

.time-extension-btn.used:not(:disabled) {
    animation: timeExtensionUsePop 0.65s ease-out;
}

.time-extension-btn.used:not(:disabled) .time-extension-badge {
    animation: timeExtensionBadgePop 0.65s ease-out;
}

@keyframes timeExtensionUsePop {
    0% { transform: scale(1); box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3); }
    35% { transform: scale(1.07); box-shadow: 0 10px 36px rgba(16, 185, 129, 0.65); }
    100% { transform: scale(1); box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3); }
}

@keyframes timeExtensionBadgePop {
    0% { transform: scale(1); }
    35% { transform: scale(1.18); }
    100% { transform: scale(1); }
}

@keyframes timeExtensionAttention {
    0% { transform: scale(1) rotate(0deg); }
    18% { transform: scale(1.06) rotate(-1.6deg); }
    36% { transform: scale(1.12) rotate(1.6deg); }
    54% { transform: scale(1.06) rotate(-1.0deg); }
    72% { transform: scale(1.03) rotate(0.6deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.time-extended {
    animation: timeExtendPulse 1s ease-out;
}

@keyframes timeExtendPulse {
    0% { transform: scale(1); color: white; }
    50% { transform: scale(1.2); color: #10b981; text-shadow: 0 0 20px #10b981; }
    100% { transform: scale(1); color: white; }
}

/* ========== 一時停止オーバーレイ ========== */
.pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 39, 0.95);
    backdrop-filter: blur(20px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: fadeIn 0.3s ease-out;
}

/* Tailwind の .hidden は常に最優先にし、display:flex の規則で上書きされて重なるのを防ぐ */
.hidden {
    display: none !important;
}

/* 固定レイアウトで BOSS 表示の余白を少し詰める */
#boss-indicator {
    margin-bottom: 0.75rem;
}
