/* ===== 基本スタイル ===== */
:root {
    --color-bg: #2c1810;
    --color-bg-dark: #1a0f0a;
    --color-table: #4a3228;
    --color-table-light: #5d4037;
    --color-shoyu: #1a0a00;
    --color-shoyu-light: #2a1505;
    --color-shoyu-drop: #0a0300;
    --color-text: #f5e6c8;
    --color-text-dim: #a89070;
    --color-danger: #cc4444;
    --color-safe: #88cc88;
    --color-gold: #d4a840;
    --color-accent: #c45a30;
    --font-main: 'Noto Serif JP', serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
}

body {
    font-family: var(--font-main);
    background: var(--color-bg-dark);
    color: var(--color-text);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* フェードオーバーレイ（ゲーム開始時） */
.fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.fade-overlay.active {
    opacity: 1;
}

/* ===== ゲームコンテナ ===== */
#game-container {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    max-height: 900px;
    position: relative;
    background:
        repeating-linear-gradient(90deg,
            var(--color-table) 0px,
            var(--color-table) 50px,
            var(--color-table-light) 50px,
            var(--color-table-light) 100px);
    overflow: hidden;
}

#game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.2) 30%, rgba(0, 0, 0, 0.2) 70%, rgba(0, 0, 0, 0.5) 100%);
    pointer-events: none;
    z-index: 1;
}

/* ===== 画面切り替え ===== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.screen.active {
    display: flex;
}

/* ===== タイトル画面 ===== */
#title-screen {
    position: relative;
    overflow: hidden;
    background: #0a0500;
}

/* 最背面：背景画像（ぼかし・ゆっくり動く） */
.title-bg {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background: url('assets/title_bg.webp') center/cover no-repeat;
    filter: blur(3px);
    animation: bg-slow-move 20s ease-in-out infinite alternate;
    z-index: 1;
}

@keyframes bg-slow-move {
    0% {
        transform: translate(0, 0) scale(1.05);
    }

    100% {
        transform: translate(-3%, -3%) scale(1.1);
    }
}

/* 背景オーバーレイ（暗くする） */
#title-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2;
}

/* 中間：パーティクルエフェクト */
.title-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.shoyu-particle {
    position: absolute;
    width: 8px;
    height: 12px;
    background: linear-gradient(180deg, #2a1a0a 0%, #0a0400 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    opacity: 0.6;
    animation: particle-fall linear infinite;
}

@keyframes particle-fall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.6;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(100vh) rotate(180deg);
        opacity: 0;
    }
}

/* 前面：タイトルロゴコンテナ */
.title-logo-container {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

/* タイトルロゴ画像 */
.title-logo {
    width: 100%;
    max-height: 60vh;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(139, 69, 19, 0.8)) drop-shadow(0 0 40px rgba(0, 0, 0, 0.9));
}

.fade-in-up {
    animation: fade-in-up 1.5s ease-out forwards;
}

@keyframes fade-in-up {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 最前面：UI */
.title-ui {
    position: absolute;
    bottom: 4rem;
    left: 0;
    width: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 20;
}

.start-text {
    font-size: 1.8rem;
    color: #fff;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    writing-mode: horizontal-tb;
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

.title-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.sound-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 30;
}

.sound-toggle:hover {
    background: rgba(0, 0, 0, 0.8);
}

.version-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
}

/* 旧タイトル用（互換性のため残す） */
.title-content {
    display: none;
}

/* ===== ゲーム画面 ===== */
#game-screen {
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, transparent 20%, transparent 80%, rgba(0, 0, 0, 0.5) 100%),
        url('assets/background.webp') center/cover no-repeat;
    justify-content: flex-start;
    padding-top: 1rem;
}

/* 失敗理由のスタイル */
.failure-reason {
    font-size: 1rem;
    color: #ffcccc;
    margin-top: 0.5rem;
    font-weight: 400;
    opacity: 0.9;
}

/* ゲーム画面ヘッダー */
#game-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
    box-sizing: border-box;
    pointer-events: none;
}

#stage-indicator {
    padding: 1rem;
    background: url('assets/stage_label_bg.webp') center/cover no-repeat;
    border: none;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stage-label {
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    writing-mode: vertical-rl;
    text-orientation: upright;
    color: #000;
    font-family: 'Shippori Mincho', 'Noto Serif JP', serif;
    margin-bottom: 0;
}

#stage-label {
    font-size: 1.7rem;
    font-weight: 800;
    color: #000;
    text-shadow: none;
    font-family: 'Shippori Mincho', 'Noto Serif JP', serif;
}

.timer-container {
    background: rgba(0, 0, 0, 0.8);
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    border: 2px solid var(--color-danger);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.timer-label {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text-dim);
    margin-right: 0;
    margin-bottom: 0.2rem;
}

.timer-value {
    font-size: 3.5rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    font-family: 'Courier New', monospace;
}

.timer-value.warning {
    color: var(--color-danger);
    animation: blink 0.5s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ===== ゲームエリア ===== */
.game-area {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
}

/* 醤油差し */
#shoyu-bottle-container {
    position: relative;
    width: 280px;
    height: 350px;
    cursor: grab;
    z-index: 10;
    margin-top: 140px;
    margin-left: 290px;
}

#shoyu-bottle-container:active {
    cursor: grabbing;
}

#shoyu-bottle-wrapper {
    width: 100%;
    height: 100%;
    transition: transform 0.05s ease-out;
    transform-origin: center center;
}

#shoyu-bottle {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.6));
    transform-origin: center 80%;
}

/* 醤油のしずく */
#shoyu-stream {
    position: absolute;
    top: 25%;
    left: 40px;
    width: 50px;
    height: 200px;
    pointer-events: none;
    transform: translateY(0);
}

.shoyu-drop {
    position: absolute;
    width: 14px;
    height: 20px;
    background: linear-gradient(180deg, #1a0800 0%, #050100 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: drop-fall 0.4s ease-in forwards;
    box-shadow:
        inset 1px 1px 3px rgba(80, 50, 20, 0.3),
        0 2px 6px rgba(0, 0, 0, 0.7);
    left: 10px;
}

.shoyu-drop.overflow {
    width: 20px;
    height: 30px;
    background: linear-gradient(180deg, #0d0400 0%, #000 100%);
}

@keyframes drop-fall {
    0% {
        top: 0;
        opacity: 1;
        transform: translateX(0);
    }

    100% {
        top: 300px;
        opacity: 0;
        transform: translateX(-20px);
    }
}

/* カウンターテーブル（非表示） */
.counter-table {
    display: none;
}

#sushi-container {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    width: 250px;
    height: 250px;
    z-index: 2;
}

#sushi-plate {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

/* 醤油プール */
#shoyu-pool-container {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 80px;
}

#shoyu-pool {
    position: absolute;
    bottom: 70px;
    /* 少し上に */
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    background: radial-gradient(ellipse, #030100 0%, #0a0400 50%, transparent 70%);
    border-radius: 50%;
    opacity: 0.95;
    transition: width 0.15s, height 0.15s;
}

#shoyu-pool.overflow {
    background: radial-gradient(ellipse, #000 0%, #050200 40%, transparent 70%);
}

/* ===== ステータスエリア ===== */
.status-area {
    position: absolute;
    top: 15%;
    left: 0;
    width: 100%;
    text-align: center;
    pointer-events: none;
    z-index: 20;
}

.status-message {
    font-size: 2.5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.9);
    display: inline-block;
    animation: fadePulse 2s infinite;
}

@keyframes fadePulse {

    0%,
    100% {
        opacity: 0.8;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

.pouring-indicator {
    background: var(--color-safe);
    color: #1a1a1a;
    font-weight: 700;
    padding: 0.8rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1.3rem;
    display: inline-block;
}

.pouring-indicator.danger {
    background: var(--color-danger);
    color: #fff;
}

.hidden {
    display: none !important;
}

/* ===== 結果画面 ===== */
.result-screen {
    background: rgba(0, 0, 0, 0.92);
}

.result-content {
    text-align: center;
    padding: 2rem;
    animation: result-appear 0.4s ease-out;
}

@keyframes result-appear {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.result-image {
    max-width: 280px;
    max-height: 220px;
    object-fit: contain;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.success-image {
    animation: success-appear 0.4s ease-out;
}

@keyframes success-appear {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.failure-image {
    animation: failure-appear 0.4s ease-out;
}

@keyframes failure-appear {
    0% {
        transform: translateY(-20px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.success-dish-name {
    font-size: 2.5rem;
    color: var(--color-gold);
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-weight: 900;
}

.result-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.success-title {
    color: var(--color-gold);
}

.failure-title {
    color: var(--color-danger);
}

.timeout-title {
    color: var(--color-text-dim);
}

.timeout-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.result-message {
    font-size: 1rem;
    color: var(--color-text-dim);
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* クリア画面タイトル */
.clear-title {
    font-size: 2.2rem;
    color: var(--color-gold);
    font-weight: 900;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 0.5rem;
}

.clear-subtitle {
    font-size: 1.4rem;
    color: #fff;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

/* 認定証スタイル */
.certificate-container {
    position: relative;
    width: 280px;
    height: 200px;
    margin-bottom: 1rem;
}

.certificate-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.certificate-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 100%;
}

.certificate-title {
    font-size: 1.2rem;
    color: #3e2723;
    font-family: 'Shippori Mincho', 'Noto Serif JP', serif;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.certificate-rank {
    font-size: 2.5rem;
    color: #8b0000;
    font-family: 'Shippori Mincho', 'Noto Serif JP', serif;
    font-weight: 900;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    margin: 0.3rem 0;
}

.certificate-label {
    font-size: 1rem;
    color: #3e2723;
    font-family: 'Shippori Mincho', 'Noto Serif JP', serif;
    font-weight: 600;
}

/* 失敗サブテキスト */
.failure-subtext {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0.3rem 0 0.5rem 0;
}

.tap-to-continue {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

.quote-message {
    font-size: 1.5rem;
    color: var(--color-text);
    font-style: italic;
}

.game-clear-label {
    font-size: 1.2rem;
    color: var(--color-gold);
    margin-bottom: 0.5rem;
}

.instruction-hint {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 0.9rem;
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    z-index: 30;
}