:root { 
    --main-brown: #8b4513; 
    --sub-brown: #5d2e0d;
    --soft-yellow: #fff9c4; 
    --accent-pink: #ff4081;
    --gauge-green: #00e676;
    --sky-blue: #81d4fa;
    --gold: #ffd700;
    --fragrance-blue: #00bcd4;
}

body { background: var(--sky-blue); font-family: 'Hiragino Kaku Gothic ProN', sans-serif; text-align: center; margin: 0; overflow: hidden; }
#game-outer { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; }
#game-container { position: relative; width: 900px; height: 600px; background: #fff; border: 12px solid var(--main-brown); border-radius: 40px; overflow: hidden; box-shadow: 0 20px 0 rgba(0,0,0,0.2); }

#fragrance-wall { 
    position: absolute; left: 0; top: 0; width: 150px; height: 100%; 
    background: linear-gradient(to right, rgba(0, 188, 212, 0.5), rgba(0, 188, 212, 0)); 
    z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.5s;
}
.wall-active #fragrance-wall { opacity: 1; animation: cloudMove 2s infinite alternate ease-in-out; }
@keyframes cloudMove { 0% { transform: translateX(-10px); filter: blur(10px); } 100% { transform: translateX(10px); filter: blur(20px); } }

.shake { animation: shake 0.2s ease-in-out; }
@keyframes shake { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(-10px, 10px); } 50% { transform: translate(10px, -10px); } 75% { transform: translate(-10px, -10px); } }

/* --- HUD (ヘッドアップディスプレイ) レイアウト修正版 --- */
#hud {
    position: absolute;
    top: 10px;
    left: 0;
    width: 100%;
    padding: 0 15px; /* 左右に余白 */
    box-sizing: border-box; /* パディングを幅に含める */
    display: flex;
    justify-content: space-between; /* 要素を均等に配置 */
    align-items: center; /* 垂直方向の中央揃え */
    z-index: 500;
    pointer-events: none; /* ゲーム操作の邪魔にならないように */
}
/* 各ステータスブロックの共通デザイン */
.hud-item {
    background: rgba(255,255,255,0.95);
    padding: 6px 12px;
    border-radius: 12px;
    border: 3px solid var(--main-brown);
    font-weight: 900;
    color: var(--main-brown);
    font-size: 16px; /* 少し小さくして横並びしやすく */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    white-space: nowrap; /* 折り返し防止 */
}
/* コンボ表示 */
#combo-container {
    width: 80px; /* ゲージ幅を調整 */
    height: 12px;
    background: #eee;
    border: 2px solid var(--main-brown);
    border-radius: 6px;
    overflow: hidden;
    margin-left: 8px;
    display: inline-block;
    vertical-align: middle;
}
#combo-gauge {
    width: 0%;
    height: 100%;
    background: var(--gauge-green);
    transition: width 0.2s;
}

.unko { position: absolute; display: flex; flex-direction: column; align-items: center; z-index: 10; }
.word-box { background: white; padding: 10px 20px; border-radius: 20px; border: 4px solid var(--main-brown); min-width: 180px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.unko[data-attr="fragrance"] .word-box { border-color: var(--fragrance-blue); background: #e0f7fa; }
.kanji { font-size: 24px; font-weight: bold; color: #333; margin-bottom: 5px; display: block; }
.roma-text { font-family: 'Courier New', monospace; font-size: 22px; color: #bbb; letter-spacing: 1px; }
.typed { color: var(--accent-pink); font-weight: bold; }

#ippon-bonus-msg { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) scale(0); font-size: 50px; font-weight: 900; color: var(--gold); z-index: 3000; text-shadow: 3px 3px 0 var(--main-brown); pointer-events: none; white-space: nowrap;}
.ippon-anim { animation: ipponPop 1s forwards; }
@keyframes ipponPop { 0% { transform: translate(-50%, -50%) scale(0); opacity: 0; } 50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; } }

.overlay { position: absolute; inset: 0; background: var(--soft-yellow); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1000; }
.hidden { display: none !important; }
.btn-group { display: flex; gap: 10px; margin-top: 10px; }
.brown-btn { padding: 12px 25px; font-size: 18px; font-weight: bold; background: var(--main-brown); color: white; border: none; border-radius: 50px; cursor: pointer; box-shadow: 0 5px 0 #5d2e0d; }
.brown-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #5d2e0d; }
.flush-away { transform: translate(-400px, 600px) rotate(-90deg) scale(0); opacity: 0; transition: 0.7s; }

#ranking-modal { position: absolute; inset: 40px; background: white; border-radius: 30px; border: 8px solid var(--main-brown); z-index: 3000; padding: 20px; display: flex; flex-direction: column; }
.rank-scroll-area { width: 100%; height: 350px; overflow-y: scroll; margin-top: 15px; border: 2px solid #eee; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--main-brown); color: white; padding: 10px; position: sticky; top: 0; }
td { border-bottom: 1px solid #eee; padding: 10px; text-align: center; }

#esc-btn { position: absolute; bottom: 20px; right: 20px; z-index: 600; font-size: 12px; opacity: 0.7; }
.info-btn { background: #fff; color: var(--main-brown); border: 3px solid var(--main-brown); box-shadow: 0 4px 0 var(--main-brown); text-decoration: none; display: inline-block; text-align:center; padding: 10px 20px; border-radius: 50px; font-weight:bold;}

/* 設定トグル */
.setting-container { margin-bottom: 25px; display: flex; align-items: center; justify-content: center; gap: 15px; margin-top:15px; }
.setting-label { font-weight: bold; color: var(--main-brown); font-size: 18px; }
.toggle-switch { position: relative; width: 110px; height: 44px; }
.toggle-switch input { display: none; }
.toggle-switch label { display: block; width: 100%; height: 100%; background: #e0e0e0; border: 3px solid var(--main-brown); border-radius: 25px; position: relative; cursor: pointer; transition: background 0.3s; box-sizing: border-box; overflow: hidden; }
.toggle-text { position: absolute; top: 50%; transform: translateY(-50%); font-size: 15px; font-weight: 900; color: #999; transition: color 0.3s; z-index: 3; pointer-events: none; }
.toggle-text.small { left: 15px; }
.toggle-text.large { right: 15px; }
.toggle-ball { position: absolute; top: 3px; left: 4px; width: 48px; height: 32px; background: var(--main-brown); border-radius: 18px; transition: transform 0.3s, background-color 0.3s; box-shadow: 0 2px 4px rgba(0,0,0,0.2); z-index: 2; }
input:not(:checked) + label .toggle-text.small { color: #ffffff; }
input:checked + label { background: var(--soft-yellow); }
input:checked + label .toggle-ball { transform: translateX(51px); background: var(--accent-pink); }
input:checked + label .toggle-text.large { color: #ffffff; }

/* 芳香剤ゲージ */
#wall-gauge-container { position: absolute; bottom: 20px; left: 20px; width: 20px; height: 200px; background: rgba(255,255,255,0.3); border: 2px solid white; border-radius: 10px; overflow: hidden; }
#wall-gauge-fill { position: absolute; bottom: 0; width: 100%; height: 100%; background: var(--fragrance-blue); transition: height 0.1s linear; }

/* マーキー（神様帯） */
#god-marquee { position: absolute; top: 0; left: 0; width: 100%; height: 40px; background: linear-gradient(90deg, #ffd700, #fffacd, #ffd700); border-bottom: 3px solid orange; z-index: 1000; overflow: hidden; white-space: nowrap; box-shadow: 0 5px 15px rgba(255, 215, 0, 0.5); display: flex; align-items: center; }
.marquee-content { display: inline-block; padding-left: 100%; animation: marquee-scroll 10s linear infinite; font-size: 24px; font-weight: 900; color: #d84315; text-shadow: 1px 1px 0 #fff; }
@keyframes marquee-scroll { 0% { transform: translate(0, 0); } 100% { transform: translate(-100%, 0); } }

/* エフェクト */
.time-bonus-popup { position: absolute; color: var(--accent-pink); font-size: 32px; font-weight: 900; pointer-events: none; z-index: 2000; text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff; animation: time-float-up 1s ease-out forwards; }
@keyframes time-float-up { 0% { transform: translateY(0) scale(0.5); opacity: 0; } 20% { transform: translateY(-20px) scale(1.2); opacity: 1; } 100% { transform: translateY(-80px) scale(1); opacity: 0; } }

/* タイム表示（右端） */
#timer {
    display: inline-block;
    width: 50px;
    text-align: right;
    color: var(--accent-pink);
}

#timer.bonus-glow { animation: timer-flash 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); display: inline-block; }
@keyframes timer-flash { 0% { transform: scale(1); color: var(--accent-pink); } 50% { transform: scale(1.4); } 100% { transform: scale(1); color: inherit; } }

/* カットイン */
#god-cutin-msg { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0); font-size: 5em; font-weight: 900; color: gold; text-align: center; text-shadow: 3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 0 0 30px orange; white-space: nowrap; pointer-events: none; z-index: 3000; opacity: 0; }
.god-cutin-anim { animation: god-cutin-flash 2.5s ease-out forwards; }
@keyframes god-cutin-flash { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-10deg); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.2) rotate(0deg); } 25% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } }

.fever-active { animation: fever-glow 0.8s infinite alternate !important; border-color: gold !important; }
@keyframes fever-glow { from { box-shadow: inset 0 0 30px rgba(255,215,0,0.4); background-color: #fff; } to { box-shadow: inset 0 0 80px rgba(255,215,0,0.7); background-color: #fffacd; } }

/* トイレの神様：右上の常駐アイコン */
#toilet-god { position: absolute; top: 50px; right: 15px; font-size: 50px; z-index: 200; animation: god-float 2s ease-in-out infinite; text-shadow: 0 0 25px gold, 0 0 10px orange; text-align: center; line-height: 1.1; filter: drop-shadow(0 0 5px gold); }
@keyframes god-float { 0%, 100% { transform: translateY(0) rotate(3deg); } 50% { transform: translateY(-10px) rotate(-3deg); } }

/* 汚れエフェクト */
.miss-stain { position: absolute; width: 80px; height: 80px; background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" fill="%23654321"><path d="M50 35 C 35 35, 20 50, 20 65 C 20 80, 35 95, 50 95 C 65 95, 80 80, 80 65 C 80 50, 65 35, 50 35 Z M 50 25 C 45 20, 55 20, 50 15 C 40 20, 60 20, 50 25 Z" opacity="0.9"/><circle cx="30" cy="50" r="5" opacity="0.8"/><circle cx="70" cy="75" r="7" opacity="0.8"/><circle cx="40" cy="85" r="4" opacity="0.8"/></svg>'); background-size: contain; background-repeat: no-repeat; pointer-events: none; z-index: 1500; transform: scale(0); animation: stain-appear 3s ease-out forwards; }
@keyframes stain-appear { 0% { transform: scale(0) rotate(var(--rot)); opacity: 0.8; } 10% { transform: scale(1) rotate(var(--rot)); opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; transform: scale(1.1) rotate(var(--rot)); } }

/* 芳香結界 */
.fragrance-barrier-active { animation: barrier-glow 1s infinite alternate !important; border-color: cyan !important; }
@keyframes barrier-glow { from { box-shadow: inset 0 0 30px cyan, inset 0 0 10px lime; background-color: #e0ffff; } to { box-shadow: inset 0 0 80px cyan, inset 0 0 40px lime; background-color: #f0fff0; } }
.fragrance-barrier-active #wall-gauge-fill { background: linear-gradient(to top, cyan, lime, white); box-shadow: 0 0 10px cyan; }

/* ランキングフォーム・コレクション */
.ranking-form-area { margin-top: 20px; padding-top: 15px; border-top: 2px dashed #ccc; background: #fafafa; padding: 15px; border-radius: 10px; }
.rank-input { padding: 8px; font-size: 18px; border: 2px solid var(--main-brown); border-radius: 8px; width: 180px; text-align: center; outline: none; font-weight: bold; color: var(--sub-brown); }
.rank-input:focus { border-color: var(--accent-pink); background: #fff0f5; }

.skin-item { width: 50px; height: 50px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 30px; border: 3px solid #ccc; background: #eee; }
.skin-item.unlocked { border-color: var(--gold); background: #fff; cursor: help; }
.skin-item.locked { opacity: 0.6; filter: grayscale(100%); }


/* レベル表示（左端） */
#level-indicator {
    background: var(--soft-yellow); /* 黄色背景で強調 */
    color: #d84315;
    min-width: 120px;
}

/* リザルトカードの調整 */
#result-card {
    background: white;
    padding: 15px 30px;
    border: 4px solid var(--main-brown);
    border-radius: 20px;
    width: 85%;
    max-width: 450px;
    margin-bottom: 10px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* 印刷用設定 */
@media print {
    body * { visibility: hidden; }
    #game-container, #game-container * { visibility: visible; }
    #game-container { position: absolute; left: 0; top: 0; border: none; width: 100%; height: auto; box-shadow: none; }
    .no-print { display: none !important; }
    #end-screen { position: static; background: white; }
    #result-card { border: 2px solid #000; width: 100%; box-shadow: none; }
    h2 { color: black !important; }
}

/* スコア表示 */
#score {
    margin-left: 5px;
    font-size: 20px; /* 数字は大きく */
}

/* ガチャ・コレクション関連 */
.rarity-header {
    width: 100%;
    background: #5d2e0d;
    color: white;
    font-weight: bold;
    padding: 5px;
    margin-top: 10px;
    border-radius: 5px;
    font-size: 14px;
}

.collection-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 5px;
}

.skin-item { 
    width: 60px; height: 60px; 
    border-radius: 10px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 35px; 
    border: 3px solid #ccc; 
    background: #eee; 
    position: relative;
    overflow: hidden;
}
.skin-img {
    width: 100%; height: 100%; object-fit: contain;
}

/* レアリティ別スタイル */
.skin-item.unlocked.rarity-1 { border-color: #8d6e63; background: #fff; }
.skin-item.unlocked.rarity-2 { border-color: #2196f3; background: #e3f2fd; box-shadow: 0 0 5px #2196f3; }
.skin-item.unlocked.rarity-3 { border-color: #e91e63; background: #fce4ec; box-shadow: 0 0 8px #e91e63; }
.skin-item.unlocked.rarity-4 { border-color: #ffd700; background: #fffde7; box-shadow: 0 0 10px #ffd700; animation: glow 2s infinite; }
.skin-item.unlocked.rarity-5 { 
    border-color: #000; 
    background: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8f00ff);
    box-shadow: 0 0 15px #fff; 
    animation: rainbowGlow 1s infinite;
}

@keyframes glow { 50% { box-shadow: 0 0 20px #ffd700; } }
@keyframes rainbowGlow { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } }

.skin-item.locked { opacity: 0.5; filter: grayscale(100%); font-size: 20px; }

/* ガチャ排出結果のアニメーション */
.gacha-result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 5px;
    border-radius: 10px;
    border: 2px solid #ccc;
    width: 70px;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform: scale(0);
}
.appear-anim:nth-child(1) { animation-delay: 0.1s; }
.appear-anim:nth-child(2) { animation-delay: 0.2s; }
.appear-anim:nth-child(3) { animation-delay: 0.3s; }
.appear-anim:nth-child(4) { animation-delay: 0.4s; }
.appear-anim:nth-child(5) { animation-delay: 0.5s; }
.appear-anim:nth-child(6) { animation-delay: 0.6s; }
.appear-anim:nth-child(7) { animation-delay: 0.7s; }
.appear-anim:nth-child(8) { animation-delay: 0.8s; }
.appear-anim:nth-child(9) { animation-delay: 0.9s; }
.appear-anim:nth-child(10) { animation-delay: 1.0s; }

@keyframes popIn {
    to { opacity: 1; transform: scale(1); }
}

.gacha-result-item .char { font-size: 40px; line-height: 1; }
.gacha-result-item .name { font-size: 10px; font-weight: bold; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; text-align: center; }
.gacha-result-item .stars { font-size: 8px; color: gold; margin-bottom: 2px; }

/* レアリティ別の排出エフェクト */
.gacha-result-item.rarity-4 { box-shadow: 0 0 10px gold; border-color: gold; }
.gacha-result-item.rarity-5 { box-shadow: 0 0 15px purple; border-color: purple; background: #f3e5f5; }

/* --- うんこニュースコーナー（ソフトクリーム型ヘッダー版） --- */
#unko-news-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 300px;
    height: 240px; /* 高さを確保 */
    background: transparent;
    display: flex;
    flex-direction: column;
    z-index: 2000;
    text-align: left;
    animation: slideInUp 0.5s ease-out;
    filter: drop-shadow(5px 5px 10px rgba(0,0,0,0.3)); /* 全体に影 */
}

@keyframes slideInUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ヘッダー：1段目（土台・一番太い部分） */
.news-header {
    background: var(--main-brown);
    color: white;
    padding: 20px 15px 5px 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: flex-end; /* テキストを下揃え */
    height: 55px;
    
    /* 下膨れの形 */
    border-radius: 30px 30px 0 0;
    position: relative;
    margin-bottom: -1px; /* 隙間防止 */
    z-index: 10;
}

/* ヘッダー：2段目（中間・やや太い部分） */
.news-header::before {
    content: '';
    position: absolute;
    top: -20px; /* 上にずらす */
    left: 50%;
    transform: translateX(-50%);
    width: 85%; /* 土台より少し細く */
    height: 45px;
    background: var(--main-brown);
    border-radius: 25px; /* 丸みをつける */
    z-index: -1; /* 文字の後ろ */
}

/* ヘッダー：3段目（先端・ツノ部分） */
.news-header::after {
    content: '';
    position: absolute;
    top: -45px; /* さらに上に */
    left: 50%;
    transform: translateX(-50%);
    width: 50%; /* 一番細く */
    height: 45px;
    background: var(--main-brown);
    /* ソフトクリームの先端のような形（しずく型） */
    border-radius: 100% 100% 40% 40%;
    z-index: -2;
}

/* テキストと閉じるボタン */
.news-header span {
    position: relative;
    z-index: 10;
    font-size: 16px;
    margin-bottom: 2px;
}

.close-news-btn {
    background: none;
    border: none;
    color: var(--soft-yellow);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    font-weight: bold;
    position: relative;
    z-index: 10;
    transition: transform 0.2s;
}
.close-news-btn:hover {
    color: white;
    transform: scale(1.2) rotate(90deg);
}

/* ニュース本文（箱部分） */
#news-content {
    background: #fff8e1; /* 生成り色 */
    border: 4px solid var(--main-brown);
    border-top: none; /* 上の線は消してヘッダーと一体化 */
    border-radius: 0 0 20px 20px; /* 下部を丸く */
    padding: 15px;
    font-size: 14px;
    color: #5d2e0d;
    overflow-y: auto;
    white-space: pre-wrap;
    flex-grow: 1;
    font-family: 'Hiragino Kaku Gothic ProN', sans-serif;
    position: relative;
    z-index: 5;
}
/* --- ガチャ結果フェードアウトアニメーション --- */
.fade-out-anim {
    animation: fadeOut 1s forwards;
}

@keyframes fadeOut {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.5); }
}
/* ペナルティポップアップ（赤文字） */
.penalty-popup {
    position: absolute;
    color: red;
    font-size: 40px;
    font-weight: 900;
    pointer-events: none;
    z-index: 2000;
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff;
    animation: penalty-pop 0.5s ease-out forwards;
}

@keyframes penalty-pop {
    0% { transform: scale(0.5); opacity: 0; }
    30% { transform: scale(1.5); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}

/* 吹き出しアニメーション (fuwa-bubble) */
.btn-wrapper {
    position: relative;
    display: inline-block;
}

.fuwa-bubble {
    position: absolute;
    bottom: 110%; /* ボタンの上に配置 */
    left: -10px;  /* 少し左にずらす */
    background: #fff;
    border: 2px solid #8bc34a; /* ボタンと同じ緑色 */
    color: #555;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
    pointer-events: none; /* クリックを邪魔しない */
    animation: fuwafuwa 2s infinite ease-in-out;
}

/* 吹き出しのしっぽ */
.fuwa-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 20px;
    border: 6px solid transparent;
    border-top-color: #8bc34a;
}

/* ふわふわ動くアニメーション定義 */
@keyframes fuwafuwa {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* --- ふりがな（ルビ）のスタイル --- */
.furigana {
    font-size: 14px;         /* 小さめの文字 */
    color: #8b4513;          /* メインカラーと同じ茶色 */
    font-weight: bold;       /* 太字で見やすく */
    display: block;          /* 改行して上に表示 */
    margin-bottom: -2px;     /* 下の漢字との隙間を詰める */
    line-height: 1;          /* 行間を詰める */
}