/* ===============================
   基本設定（全要素に適用）
   =============================== */

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html {
  margin: 0;
  height: 100%;
}

body {
  margin: 0;
  height: 100vh;          /* 画面の高さを使う */

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    "Meiryo",
    sans-serif;
  background: #f2f2f2;

  display: flex;          /* 中央配置 */
  justify-content: center;
  align-items: center;
}

/* ===============================
   外枠（ゲーム全体）
   高さ540px固定レイアウト
   =============================== */

.container {
  margin: 0 auto;         /* 中央寄せ */
  background: #ffffff;
  border: 2px solid #333;

  width: 100%;
  max-width: 1196px;
  height: 540px;          /* ゲーム総高さ固定 */

  display: flex;          /* 縦レイアウトを作るための土台 */
  flex-direction: column; /* 子要素を縦に並べる */
}


/* ===============================
   ヘッダー（高さ固定）
   =============================== */

.game-header {
  height: 50px;           /* 見た目の高さ */
  padding:5px 10px;
  background-color:#f5f0e8;
  background-image:
    linear-gradient(rgba(200,190,170,0.25) 1px,transparent 1px),
    linear-gradient(90deg,rgba(200,190,170,0.25) 1px,transparent 1px);
  background-size:60px 60px;
  border-bottom:4px solid #a07840;
  box-shadow:0 3px 10px rgba(80,55,25,0.18);

  /* flex: grow shrink basis
     grow:広がらない
     shrink:縮まない
     basis:50px固定 */
  flex: 0 0 50px;

  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items: center;    /* 縦中央 */
  gap:12px;
}

.header-score {
  justify-self:start;
  color:#7a5520;
  font-size:17px;
  font-weight:bold;
  white-space:nowrap;
}

#header-stars {
  letter-spacing:2px;
}

.header-title {
  justify-self:center;
  color:#1a6b3c;
  font-size:20px;
  font-weight:bold;
  letter-spacing:1px;
  text-shadow:0 1px 0 #fff;
  white-space:nowrap;
}

.header-actions {
  justify-self:end;
}


/* ===============================
   メインゲームエリア
   残り高さすべて使う
   =============================== */

.game-main {
  position: relative;     /* absolute配置の基準になる */
  background: #ffffff;

  flex: 1;

  overflow: hidden;       /* はみ出し防止 */

  display: grid;
  place-items: center;    /* 中央配置のショート記法 */
}


#game-wrapper {
  font-family: 'Hiragino Maru Gothic Pro', 'BIZ UDPGothic', sans-serif;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ===== 背景：キッチン / 研究室の室内 ===== */
.bg {
  position: absolute;
  inset: 0;
  /* 壁 */
  background: #f5f0e8;
}
/* タイル壁模様 */
.bg::before {
  content:'';
  position:absolute;
  inset:0;
  background-image:
    linear-gradient(rgba(200,190,170,0.25) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200,190,170,0.25) 1px, transparent 1px);
  background-size: 60px 60px;
}
/* 床 */
.bg::after {
  content:'';
  position:absolute;
  bottom:0; left:0; right:0;
  height: 120px;
  background: linear-gradient(180deg, #c8b89a 0%, #b8a080 100%);
}

/* 棚 */
.shelf {
  position:absolute;
  top:22px; left:0; right:0;
  height:18px;
  background: #a07840;
  border-bottom: 4px solid #7a5520;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

/* 窓 */
.window {
  position:absolute;
  top:28px; right:60px;
  width:130px; height:110px;
  background: linear-gradient(135deg,#b8e8ff 0%,#e0f6ff 60%,#c8eeff 100%);
  border: 6px solid #c8a060;
  border-radius: 6px;
  overflow:hidden;
  box-shadow: inset 0 0 20px rgba(255,255,255,0.6), 0 4px 12px rgba(0,0,0,0.15);
}
.window::before { /* 縦桟 */
  content:'';
  position:absolute;
  top:0; left:50%; width:4px; height:100%;
  background: #c8a060;
  transform:translateX(-50%);
}
.window::after { /* 横桟 */
  content:'';
  position:absolute;
  top:48%; left:0; width:100%; height:4px;
  background: #c8a060;
}
.window-sun {
  position:absolute;
  top:8px; right:14px;
  font-size:26px;
}

/* ===== スクリーン共通 ===== */
.screen {
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  transition: opacity 0.35s;
}
.screen.hidden { opacity:0; pointer-events:none; }

/* ===== タイトル画面 ===== */
#screen-title { gap:20px; }

.title-card {
  background: rgba(255,255,255,0.92);
  border-radius: 28px;
  padding: 28px 70px;
  text-align:center;
  box-shadow: 0 6px 0 #d4a840, 0 10px 30px rgba(0,0,0,0.15);
  border: 5px solid #f0c040;
}
.title-card h1 {
  font-size:40px;
  color:#1a6b3c;
  text-shadow: 2px 3px 0 #a8e080;
  line-height:1.35;
  letter-spacing:3px;
}
.title-card p {
  font-size:16px;
  color:#666;
  margin-top:8px;
}
.title-vegs {
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.15));
}
.title-vegs img {
  width:52px;
  height:52px;
  object-fit:contain;
}

.btn-start {
  font-family:inherit;
  font-size:28px;
  background: linear-gradient(135deg,#ff8c42,#ff5f1f);
  color:#fff;
  border:none;
  border-radius:50px;
  padding:16px 70px;
  cursor:pointer;
  box-shadow: 0 6px 0 #b83a00, 0 10px 24px rgba(255,95,31,0.35);
  transition: transform 0.1s, box-shadow 0.1s;
  letter-spacing:3px;
}
.btn-start:hover { transform:translateY(-2px); box-shadow:0 8px 0 #b83a00,0 12px 28px rgba(255,95,31,0.4); }
.btn-start:active { transform:translateY(4px); box-shadow:0 2px 0 #b83a00; }

/* ===== クイズ画面 ===== */
#screen-quiz {
  flex-direction:column;
  justify-content:flex-start;
  padding-top:6px;
  gap:0;
}

.quiz-header {
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  padding:0 24px;
  margin-bottom:4px;
  position:relative;
}

.progress-wrap {
  display:flex;
  align-items:center;
}
.progress-dots {
  display:flex;
  gap:6px;
}
.dot {
  width:14px; height:14px;
  border-radius:50%;
  background:rgba(255,255,255,0.35);
  border:2px solid rgba(255,255,255,0.6);
  transition:background 0.3s;
}
.dot.done { background:#FFD600; border-color:#FFA000; }

.btn-quit {
  position:relative;
  top:-2px;
  font-family:inherit;
  font-size:16px;
  background: #ff4444;
  color:#fff;
  border:none;
  border-radius:30px;
  padding:6px 20px;
  cursor:pointer;
  box-shadow:0 3px 0 #aa0000;
  transition:transform 0.1s,box-shadow 0.1s;
}
.btn-quit:active { transform:translateY(3px); box-shadow:0 1px 0 #aa0000; }

.question-box {
  background:rgba(255,255,255,0.88);
  border:4px solid #f0c040;
  border-radius:18px;
  padding:6px 36px;
  text-align:center;
  font-size:23px;
  font-weight:bold;
  color:#333;
  margin-bottom:5px;
  box-shadow:0 3px 0 #c89000, 0 5px 16px rgba(0,0,0,0.1);
}

/* 選択ボタン */
.choice-area {
  display:flex;
  gap:48px;
  justify-content:center;
  margin-bottom:4px;
}
.choice-btn {
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:3px;
  background: rgba(255,255,255,0.95);
  border:5px solid #4CAF50;
  border-radius:22px;
  padding:8px 40px;
  cursor:pointer;
  font-family:inherit;
  font-size:20px;
  font-weight:bold;
  color:#1a6b3c;
  box-shadow:0 6px 0 #2E7D32,0 8px 20px rgba(0,0,0,0.15);
  transition:transform 0.12s,box-shadow 0.12s,opacity 0.3s;
  min-width:200px;
  position:relative;
  overflow:visible;
}
.choice-btn:hover:not(:disabled) {
  transform:translateY(-3px);
  box-shadow:0 9px 0 #2E7D32,0 12px 24px rgba(0,0,0,0.2);
}
.choice-btn:active:not(:disabled) { transform:translateY(4px); box-shadow:0 2px 0 #2E7D32; }
.choice-btn:disabled { cursor:default; }
.choice-image {
  width:60px;
  height:60px;
  object-fit:contain;
}

/* 正解・不正解マーク */
.mark-overlay {
  position:absolute;
  inset:-5px;
  border-radius:22px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:96px;
  line-height:1;
  opacity:0;
  transition:opacity 0.35s;
  pointer-events:none;
  background:rgba(255,255,255,0.62);
  z-index:5;
}
.mark-overlay.show { opacity:1; }

/* ===== ガラス水槽 ===== */
.tank-wrap {
  width:72%;
  margin:0 auto;
  display:none;
  position:relative;
}
.tank-wrap.show { display:block; }

/* 水槽の枠（外側）*/
.tank-outer {
  position:relative;
  border:10px solid rgba(180,225,250,0.7);
  border-bottom-width:14px;
  border-radius:4px 4px 10px 10px;
  background: transparent;
  overflow:hidden;
  height:190px;
  box-shadow:
    inset 2px 2px 8px rgba(255,255,255,0.6),
    inset -2px -2px 8px rgba(100,180,230,0.3),
    0 6px 24px rgba(0,100,180,0.18);
}
/* 水 */
.tank-water {
  position:absolute;
  bottom:0; left:0; right:0;
  height:140px;
  background: linear-gradient(180deg,
    rgba(40,160,220,0.35) 0%,
    rgba(20,120,200,0.55) 100%);
}
/* 水面のキラキラ */
.tank-surface {
  position:absolute;
  top:0; left:0; right:0;
  height:6px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.7) 20%,
    rgba(255,255,255,0.4) 40%,
    rgba(255,255,255,0.8) 65%,
    rgba(255,255,255,0.3) 85%,
    transparent 100%);
  border-radius:3px;
  animation: shimmer 2.5s ease-in-out infinite;
}
@keyframes shimmer {
  0%,100% { opacity:0.8; }
  50%      { opacity:0.3; }
}
/* 水中の光の筋 */
.tank-ray {
  position:absolute;
  top:6px; width:14px;
  background:rgba(255,255,255,0.12);
  border-radius:10px;
  transform-origin:top center;
}
/* 水槽の底の砂利（細かい点線） */
.tank-gravel {
  position:absolute;
  bottom:0; left:0; right:0;
  height:14px;
  background: radial-gradient(circle at 50% 50%, #c8b870 1.5px, transparent 1.5px),
              radial-gradient(circle at 20% 80%, #d4c080 1.5px, transparent 1.5px),
              radial-gradient(circle at 80% 30%, #b8a860 1.5px, transparent 1.5px);
  background-size:10px 10px, 14px 14px, 8px 8px;
  background-color:#c8b870;
}
/* ガラスの反射 */
.tank-glare {
  position:absolute;
  top:10px; left:8px;
  width:8px; bottom:10px;
  background:rgba(255,255,255,0.28);
  border-radius:4px;
  pointer-events:none;
}
/* 水槽の上フチ */
.tank-rim {
  height:14px;
  background: linear-gradient(180deg,rgba(210,240,255,0.95),rgba(170,220,248,0.9));
  border-radius:4px 4px 0 0;
  border-bottom:2px solid rgba(140,200,240,0.7);
  box-shadow: 0 2px 6px rgba(100,180,230,0.2);
}

/* 野菜スプライト */
.veg-sprite {
  position:absolute;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:2px;
  line-height:1;
  transition:top 1s cubic-bezier(0.4,0,0.2,1);
  z-index:10;
}
.sprite-image {
  width:62px;
  height:62px;
  object-fit:contain;
}
.veg-label {
  font-size:13px;
  font-weight:bold;
  color:#fff;
  background:rgba(0,0,0,0.55);
  border-radius:10px;
  padding:1px 8px;
  white-space:nowrap;
}

/* ===== 回答パネル ===== */
#answer-panel {
  width:100%;
  display:none;
  flex-direction:row;
  justify-content:center;
  align-items:center;
  gap:22px;
  padding:10px 16px 14px;
  flex-shrink:0;
  position:relative;
  top:8px;
}
#answer-panel.show { display:flex; }

#hint-banner {
  font-size:17px;
  font-weight:bold;
  color:#1565C0;
  background:#e8f4ff;
  border:2px solid #90CAF9;
  border-radius:12px;
  padding:8px 24px;
  opacity:0;
  transition:opacity 0.4s;
  display:none;
  text-align:center;
  white-space:nowrap;
}
#hint-banner.show { opacity:1; }

#btn-next {
  font-family:inherit;
  font-size:22px;
  background:linear-gradient(135deg,#42A5F5,#1976D2);
  color:#fff;
  border:none;
  border-radius:40px;
  padding:12px 52px;
  cursor:pointer;
  box-shadow:0 5px 0 #0d47a1,0 8px 18px rgba(25,118,210,0.3);
  display:none;
  transition:transform 0.1s,box-shadow 0.1s;
  letter-spacing:2px;
  flex-shrink:0;
  white-space:nowrap;
}
#btn-next:hover { transform:translateY(-2px); box-shadow:0 7px 0 #0d47a1,0 10px 22px rgba(25,118,210,0.4); }
#btn-next:active { transform:translateY(4px); box-shadow:0 1px 0 #0d47a1; }

/* ===== 結果画面 ===== */
#screen-result { gap:0; }

/* 全画面を覆うグラデ */
.result-bg {
  position:absolute;
  inset:0;
  background:linear-gradient(135deg,#1a237e 0%,#283593 40%,#1565C0 70%,#0288D1 100%);
  z-index:0;
}
/* キラキラ星を散らす */
.result-stars-bg {
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
  overflow:hidden;
}
.star-particle {
  position:absolute;
  border-radius:50%;
  background:#FFD700;
  animation:twinkle var(--dur,2s) ease-in-out infinite var(--delay,0s);
}
@keyframes twinkle {
  0%,100% { opacity:0.1; transform:scale(0.8); }
  50%      { opacity:1;   transform:scale(1.2); }
}

.result-content {
  position:relative;
  z-index:2;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:18px;
  width:100%;
}

/* スコアバナー */

.result-score-row {
  display:flex;
  align-items:center;
  gap:30px;
}

.result-summary {
  display:flex;
  flex-direction:column;
  gap:12px;
  align-items:flex-start;
}

.result-banner {
  text-align:center;
}
.result-banner .congrats {
  font-size:30px;
  color:#FFD700;
  text-shadow:0 0 20px rgba(255,215,0,0.7),0 2px 0 #b8860b;
  letter-spacing:3px;
  animation:popIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes popIn {
  from { transform:scale(0.4); opacity:0; }
  to   { transform:scale(1);   opacity:1; }
}

/* スコアサークル */
.score-circle {
  width:150px; height:150px;
  border-radius:50%;
  background:rgba(255,255,255,0.12);
  border:6px solid rgba(255,255,255,0.35);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  box-shadow:0 0 40px rgba(255,215,0,0.3),inset 0 0 30px rgba(255,255,255,0.08);
  animation:popIn 0.6s 0.2s cubic-bezier(0.34,1.56,0.64,1) both;
}
.score-num {
  font-size:62px;
  font-weight:bold;
  color:#fff;
  line-height:1;
  text-shadow:0 2px 10px rgba(0,0,0,0.3);
}
.score-denom {
  font-size:17px;
  color:rgba(255,255,255,0.75);
}

/* 星列 */
.score-stars {
  display:flex;
  gap:8px;
  animation:popIn 0.5s 0.4s both;
}
.score-stars .s {
  font-size:36px;
  filter:drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.score-stars .s.lit { animation:starPop 0.4s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes starPop {
  from { transform:scale(0); }
  to   { transform:scale(1); }
}

/* メッセージ */
.result-msg-box {
  background:rgba(255,255,255,0.15);
  border:2px solid rgba(255,255,255,0.3);
  border-radius:50px;
  padding:10px 36px;
  font-size:22px;
  color:#fff;
  font-weight:bold;
  letter-spacing:2px;
  text-shadow:0 1px 4px rgba(0,0,0,0.3);
  animation:popIn 0.5s 0.5s both;
}

/* ボタン行 */
.result-btns {
  display:flex;
  gap:20px;
  animation:popIn 0.5s 0.7s both;
}
.btn-retry {
  font-family:inherit;
  font-size:22px;
  background:linear-gradient(135deg,#66BB6A,#2E7D32);
  color:#fff;
  border:none;
  border-radius:50px;
  padding:13px 48px;
  cursor:pointer;
  box-shadow:0 6px 0 #1b5e20,0 10px 24px rgba(46,125,50,0.4);
  transition:transform 0.1s,box-shadow 0.1s;
  letter-spacing:3px;
}
.btn-retry:hover { transform:translateY(-2px); }
.btn-retry:active { transform:translateY(4px); box-shadow:0 2px 0 #1b5e20; }

.btn-title {
  font-family:inherit;
  font-size:22px;
  background:rgba(255,255,255,0.18);
  color:#fff;
  border:3px solid rgba(255,255,255,0.45);
  border-radius:50px;
  padding:13px 36px;
  cursor:pointer;
  transition:transform 0.1s,background 0.2s;
  letter-spacing:2px;
}
.btn-title:hover { background:rgba(255,255,255,0.28); }
.btn-title:active { transform:translateY(3px); }
