@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@400;700;800&display=swap');

/* =====================================================================
 * Pastel Light Blue & Pop Cute — デザイントークン
 * ===================================================================== */
:root {
    --bg-base: #FAF7F2;
    --bg-blue: #E0F7FF;
    --card-bg: #FFFFFF;
    --primary: #B3F5FF;            /* ミントブルー */
    --primary-deep: #7FE0F2;
    --primary-fg: #1F6B7A;
    --secondary: #FFC2D4;          /* サクラピンク */
    --secondary-fg: #9E3B5C;
    --accent: #FFEFA6;             /* レモンイエロー */
    --accent-deep: #FFD54F;
    --text: #5A6472;
    --border: #BFE9F2;
    --fever: #FFB74D;
    --danger: #FF8FA3;
    --shadow-dark: #C7E8F0;
    --shadow-light: #FFFFFF;
    --anim-dur: 1s;
    --barista-dur: 0.5s;
}

body.fever {
    --anim-dur: 0.4s;
    --barista-dur: 0.2s;
}

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

body {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    color: var(--text);
    background-color: var(--bg-base);
    background-image:
        radial-gradient(circle at 12% 18%, rgba(179, 245, 255, 0.55) 0, transparent 32%),
        radial-gradient(circle at 88% 12%, rgba(255, 194, 212, 0.45) 0, transparent 30%),
        radial-gradient(circle at 50% 95%, rgba(255, 239, 166, 0.45) 0, transparent 38%);
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    padding: 16px;
    min-height: 100vh;
    transition: background-color 0.4s;
}

body.fever {
    background-color: #FFF8E1;
}

#app {
    width: 100%;
    max-width: 880px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---------- クレイ調共通 ---------- */
.clay-card {
    background: var(--card-bg);
    border: 2.5px solid var(--border);
    border-radius: 26px;
    padding: 18px;
    box-shadow:
        8px 8px 18px var(--shadow-dark),
        -6px -6px 16px var(--shadow-light),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.clay-btn {
    background: var(--primary);
    color: var(--primary-fg);
    border: 2.5px solid var(--primary-deep);
    border-radius: 18px;
    padding: 12px 18px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s;
    box-shadow:
        inset 3px 3px 6px rgba(255, 255, 255, 0.7),
        inset -3px -3px 6px rgba(0, 0, 0, 0.06),
        4px 5px 12px rgba(127, 224, 242, 0.45);
}
.clay-btn:hover:not(:disabled) { transform: translateY(-2px) scale(1.03); }
.clay-btn:active:not(:disabled) { transform: scale(0.94); }
.clay-btn:disabled {
    background: #E6EBEE;
    color: #A9B4BD;
    border-color: #D5DCE1;
    cursor: not-allowed;
    box-shadow: none;
}

/* =====================================================================
 * ヘッダー
 * ===================================================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.title-block { display: flex; flex-direction: column; gap: 4px; }
.app-header h1 {
    font-size: 1.35rem;
    color: var(--primary-fg);
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7);
}
.stage-chip {
    align-self: flex-start;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--secondary-fg);
    background: var(--secondary);
    border: 2px solid #F2A8BF;
    border-radius: 12px;
    padding: 2px 10px;
}
.back-btn { padding: 10px 14px; text-decoration: none; font-size: 1.2rem; line-height: 1; }
.stats { display: flex; align-items: center; gap: 10px; }
.mute-btn { padding: 10px 12px; font-size: 1.1rem; line-height: 1; }

.gold-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--accent);
    border: 2.5px solid var(--accent-deep);
    border-radius: 18px;
    padding: 8px 18px;
    box-shadow: inset 2px 2px 5px rgba(255, 255, 255, 0.7), 3px 4px 10px rgba(255, 213, 79, 0.4);
}
.gold-box .stat-icon { font-size: 1.6rem; }
.gold-box .stat-text { display: flex; flex-direction: column; line-height: 1.1; }
#gold-display { font-size: 1.5rem; font-weight: 800; color: #8A6D00; }
#rate-display { font-size: 0.72rem; color: #B08900; font-weight: 700; }

/* =====================================================================
 * カフェエリア（ステージテーマ）
 * ===================================================================== */
#cafe-area {
    position: relative;
    min-height: 330px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    transition: background 0.6s;
}
/* stage 0: 屋台（あたたかいベージュ） */
#cafe-area.stage-0 { background: linear-gradient(180deg, #FFF8EC 0%, #FFFFFF 55%, #FFF2DC 100%); }
/* stage 1: 街角（ミントブルー） */
#cafe-area.stage-1 { background: linear-gradient(180deg, #F2FCFF 0%, #FFFFFF 55%, #E4F8FD 100%); }
/* stage 2: おしゃれ（ラベンダー） */
#cafe-area.stage-2 { background: linear-gradient(180deg, #F8F3FF 0%, #FFFFFF 55%, #EFE4FD 100%); }
/* stage 3: リゾート（トロピカル） */
#cafe-area.stage-3 { background: linear-gradient(180deg, #EAFCF3 0%, #FFFDF3 55%, #D9F7FF 100%); }

.cafe-bg-deco {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle, rgba(179, 245, 255, 0.4) 2px, transparent 3px);
    background-size: 28px 28px;
    opacity: 0.5;
    pointer-events: none;
}

.combo-meter {
    position: absolute;
    top: 10px;
    right: 14px;
    z-index: 30;
    font-size: 0.82rem;
    font-weight: 800;
    color: #E4572E;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #FFCBA6;
    border-radius: 14px;
    padding: 3px 12px;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
}
.combo-meter.combo-active {
    opacity: 1;
    transform: scale(1);
    animation: comboPulse 0.6s infinite alternate;
}
@keyframes comboPulse { from { transform: scale(1); } to { transform: scale(1.06); } }

.counter-area {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    height: 92px;
    z-index: 2;
}
.coffee-machine {
    font-size: 2.6rem;
    background: var(--secondary);
    border: 2.5px solid #F2A8BF;
    border-radius: 18px;
    padding: 6px 12px;
    box-shadow: inset 2px 2px 5px rgba(255, 255, 255, 0.6), 3px 4px 8px rgba(255, 194, 212, 0.5);
}
.baristas-container { display: flex; gap: 6px; align-items: flex-end; }
.barista {
    font-size: 2.6rem;
    position: relative;
    transition: transform var(--barista-dur) ease-in-out;
    will-change: transform;
}
.barista.at-machine { transform: translateX(-12px) scale(1.05); }
.barista-bubble {
    position: absolute;
    top: -12px; right: -10px;
    background: white;
    border-radius: 50%;
    padding: 2px 4px;
    font-size: 0.95rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    animation: popIn 0.3s ease-out;
}

#tables-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-bottom: 8px;
    z-index: 2;
}
.table {
    width: 76px; height: 76px;
    background: radial-gradient(circle at 35% 30%, #FFE9C7, #F6C98A);
    border: 2.5px solid #EBB877;
    border-radius: 50%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 3px 3px 7px rgba(255, 255, 255, 0.6), inset -3px -3px 7px rgba(0, 0, 0, 0.12), 3px 5px 10px rgba(0,0,0,0.08);
    transition: transform 0.2s;
}
.table-top { font-size: 1.6rem; opacity: 0.85; }
.pop-bounce { animation: popBounce 0.45s cubic-bezier(0.25, 1.5, 0.5, 1); }

.customer {
    position: absolute;
    font-size: 2.4rem;
    bottom: 46px;
    left: 0; right: 0;
    text-align: center;
    z-index: 5;
    pointer-events: none;
}
.customer.vip {
    filter: drop-shadow(0 0 8px rgba(255, 213, 79, 0.95)) drop-shadow(0 0 16px rgba(255, 213, 79, 0.6));
}
.customer-idle { animation: bobble var(--anim-dur) infinite alternate ease-in-out; }
.customer-slide-in { animation: slideIn var(--anim-dur) forwards; }
.customer-slide-out { animation: slideOut var(--anim-dur) forwards; }

.order-bubble {
    position: absolute;
    top: -22px; right: -16px;
    background: white;
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 2px 8px;
    font-size: 1rem;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
    animation: popIn 0.3s cubic-bezier(0.25, 1.5, 0.5, 1);
    z-index: 10;
    pointer-events: none;
}
.order-bubble.vip-bubble {
    border-color: var(--accent-deep);
    box-shadow: 0 0 10px rgba(255, 213, 79, 0.7);
}
.table-dish {
    position: absolute;
    top: 18px;
    left: 0; right: 0;
    text-align: center;
    font-size: 1.8rem;
    animation: popIn 0.3s cubic-bezier(0.25, 1.5, 0.5, 1);
    z-index: 6;
    pointer-events: none;
}

/* ---------- FXレイヤー ---------- */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.fx-layer > * { pointer-events: auto; }

.floating-gold {
    position: absolute;
    transform: translateX(-50%);
    color: #C79A00;
    font-weight: 800;
    font-size: 1.4rem;
    text-shadow: 0 0 8px #FFE082, 0 2px 0 #fff;
    pointer-events: none;
    animation: floatUpBounce 1.1s cubic-bezier(0.25, 1.5, 0.5, 1) forwards;
}
.floating-gold.vip-gold {
    font-size: 1.7rem;
    color: #E4890C;
    text-shadow: 0 0 14px #FFD54F, 0 2px 0 #fff;
}

.serve-sparkle {
    position: absolute;
    font-size: 1rem;
    pointer-events: none;
    animation: sparkleUp 0.9s ease-out forwards;
}
@keyframes sparkleUp {
    0% { transform: translateY(0) scale(0.4); opacity: 0; }
    30% { transform: translateY(-14px) scale(1.15); opacity: 1; }
    100% { transform: translateY(-34px) scale(0.7); opacity: 0; }
}

.heart-float {
    position: absolute;
    font-size: 1.1rem;
    pointer-events: none;
    animation: heartUp 1.2s ease-out forwards;
}
@keyframes heartUp {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    25% { transform: translateY(-12px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-46px) scale(0.9) rotate(12deg); opacity: 0; }
}

.steam {
    position: absolute;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    animation: steamRise 1.8s ease-out forwards;
}
@keyframes steamRise {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    30% { opacity: 0.8; }
    100% { transform: translateY(-34px) scale(1.15); opacity: 0; }
}

.confetti {
    position: absolute;
    width: 9px; height: 9px;
    border-radius: 3px;
    pointer-events: none;
    animation: confettiFall linear forwards;
}
@keyframes confettiFall {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    100% { transform: translate(var(--drift, 20px), 320px) rotate(540deg); opacity: 0; }
}

.floating-bonus {
    position: absolute;
    font-size: 2rem;
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 8.5s linear;
    filter: drop-shadow(0 0 8px rgba(255, 213, 79, 0.8));
    animation: bonusWobble 1.2s infinite ease-in-out;
}
.bonus-bean { filter: drop-shadow(0 0 10px rgba(255, 213, 79, 0.95)); }
.bonus-bubble { filter: drop-shadow(0 0 10px rgba(179, 245, 255, 0.95)); }
.floating-bonus:hover { animation-play-state: paused; }

.sparkle-burst {
    position: absolute;
    transform: translate(-50%, -50%);
    font-weight: 800;
    color: var(--secondary-fg);
    font-size: 1.3rem;
    text-shadow: 0 0 8px #fff;
    animation: sparklePop 1.2s ease-out forwards;
}

/* ---------- カットイン ---------- */
.cutin {
    position: fixed;
    top: 38%;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 200;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary-fg);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.95) 20%, rgba(255,255,255,0.95) 80%, transparent);
    padding: 14px 0;
    text-shadow: 0 2px 0 #fff, 0 0 18px rgba(255, 213, 79, 0.8);
    pointer-events: none;
    animation: cutinSlide 2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes cutinSlide {
    0% { transform: translateX(-100%); opacity: 0; }
    18% { transform: translateX(0); opacity: 1; }
    78% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(100%); opacity: 0; }
}

/* =====================================================================
 * パネル
 * ===================================================================== */
.panels {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.panel { display: flex; flex-direction: column; gap: 12px; }
.panel h2 { font-size: 1.1rem; color: var(--primary-fg); }
.panel-note { font-size: 0.8rem; color: #8C97A3; line-height: 1.4; }
.panel-divider { border: none; border-top: 2px dashed var(--border); margin: 4px 0; }

/* ---------- メニュー ---------- */
.menu-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}
.menu-list::-webkit-scrollbar { width: 8px; }
.menu-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
.menu-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 14px;
    background: #F6FCFE;
    border: 2px solid #E3F4F9;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.menu-row.locked { opacity: 0.6; }
.menu-row.next { background: #FFF9E6; border-color: var(--accent-deep); }
.menu-emoji { font-size: 1.4rem; }
.menu-name { flex: 1; font-weight: 700; }
.menu-price { font-size: 0.78rem; color: #8C97A3; font-weight: 700; }
.menu-req { font-size: 0.7rem; color: #B48EAD; font-weight: 700; }

/* ---------- アップグレード ---------- */
.upgrade-list { display: flex; flex-direction: column; gap: 8px; }
.upgrade-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 9px 12px;
    width: 100%;
}
.up-icon { font-size: 1.5rem; }
.up-body { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.up-label { font-size: 0.88rem; }
.up-label small { font-weight: 700; opacity: 0.7; }
.up-desc { font-size: 0.72rem; opacity: 0.8; font-weight: 700; }
.up-cost { font-size: 0.8rem; font-weight: 800; white-space: nowrap; }

.mini-btn { padding: 6px 10px; font-size: 0.76rem; border-radius: 12px; }

/* ---------- 店舗拡張 ---------- */
.stage-info {
    background: #F6FCFE;
    border: 2px solid #E3F4F9;
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stage-current { font-size: 1.05rem; color: var(--primary-fg); }
.stage-caps { font-size: 0.76rem; color: #8C97A3; font-weight: 700; }
.expand-btn {
    background: #C9F7D4;
    border-color: #8FE0A4;
    color: #1F7A3D;
    box-shadow: inset 3px 3px 6px rgba(255, 255, 255, 0.7), 4px 5px 12px rgba(143, 224, 164, 0.5);
}

/* ---------- ブースト＆連携 ---------- */
.fever-btn {
    background: var(--accent);
    border-color: var(--accent-deep);
    color: #8A6D00;
    box-shadow: inset 3px 3px 6px rgba(255, 255, 255, 0.7), 4px 5px 12px rgba(255, 213, 79, 0.5);
}
.exchange-btn {
    background: var(--secondary);
    border-color: #F2A8BF;
    color: var(--secondary-fg);
    box-shadow: inset 3px 3px 6px rgba(255, 255, 255, 0.6), 4px 5px 12px rgba(255, 194, 212, 0.5);
}
.btn-main { display: block; }
.btn-sub { display: block; font-size: 0.72rem; opacity: 0.85; font-weight: 700; }

.fever-status {
    text-align: center;
    font-weight: 800;
    color: var(--fever);
    padding: 6px;
}
.fever-hidden { display: none; }
.fever-active { display: block; animation: blink 0.6s infinite alternate; }

.msg-hidden { display: none; }
.msg-active {
    display: block;
    font-size: 0.82rem;
    text-align: center;
    color: var(--danger);
    font-weight: 700;
    padding: 4px;
    animation: popIn 0.3s;
}
.msg-active.success { color: var(--primary-fg); }

/* =====================================================================
 * フッター
 * ===================================================================== */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0 8px;
    font-size: 0.76rem;
    color: #A9B4BD;
}
.footer-stats { display: flex; gap: 14px; font-weight: 700; }
.text-btn {
    background: none;
    border: none;
    color: #A9B4BD;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.76rem;
}
.text-btn:hover { color: var(--danger); }
.save-indicator { transition: color 0.3s; }
.save-indicator.saving { color: var(--primary-deep); font-weight: 700; }

/* =====================================================================
 * モーダル
 * ===================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(90, 120, 140, 0.35);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: fadeIn 0.25s;
}
.modal-hidden { display: none; }
.modal-card {
    max-width: 360px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: popBounce 0.45s cubic-bezier(0.25, 1.5, 0.5, 1);
}
.modal-card h2 { color: var(--primary-fg); }
.modal-sub { font-size: 0.85rem; color: #8C97A3; }
.welcome-amount { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px; }
.welcome-emoji { font-size: 2.2rem; }
#welcome-gold { font-size: 2rem; font-weight: 800; color: #C79A00; text-shadow: 0 0 10px #FFE082; }
.welcome-detail { font-size: 0.8rem; color: #8C97A3; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .clay-btn { flex: 1; }
.ghost-btn { background: #EEF4F6; color: var(--text); border-color: #DCE6E9; box-shadow: none; }
.danger-btn { background: var(--danger); border-color: #F26B85; color: #fff; box-shadow: inset 3px 3px 6px rgba(255,255,255,0.3), 4px 5px 12px rgba(255, 143, 163, 0.5); }

/* =====================================================================
 * キーフレーム
 * ===================================================================== */
@keyframes slideIn { from { transform: translateX(-220px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(220px); opacity: 0; } }
@keyframes bobble { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-6px) rotate(3deg); } }
@keyframes popIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes popBounce { 0% { transform: scale(0.8); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes blink { from { opacity: 1; } to { opacity: 0.5; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes bonusWobble { 0%,100% { translate: 0 0; } 50% { translate: 0 -8px; } }
@keyframes floatUpBounce {
    0% { transform: translateX(-50%) translateY(0) scale(0.5); opacity: 0; }
    20% { transform: translateX(-50%) translateY(-22px) scale(1.4); opacity: 1; }
    100% { transform: translateX(-50%) translateY(-64px) scale(0.8); opacity: 0; }
}
@keyframes sparklePop {
    0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
    30% { transform: translate(-50%, -70%) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -120%) scale(1); opacity: 0; }
}

/* =====================================================================
 * レスポンシブ（スマホ）
 * ===================================================================== */
@media (max-width: 720px) {
    .panels { grid-template-columns: 1fr; }
    .app-header h1 { font-size: 1.05rem; }
    #cafe-area { min-height: 290px; }
    .cutin { font-size: 1.2rem; }
}
@media (max-width: 420px) {
    body { padding: 10px; }
    .table { width: 64px; height: 64px; }
    .customer { font-size: 2rem; }
    .barista, .coffee-machine { font-size: 2.2rem; }
}
