/* ============ FABLE寿司 — 回転タイピング ============ */

:root {
  --ink: #16110d;          /* 漆黒 */
  --ink-2: #211a14;
  --paper: #f3e9d4;        /* 生成り */
  --paper-dim: #d8c9a8;
  --shu: #c0392b;          /* 朱 */
  --shu-deep: #8e2418;
  --gold: #d4af37;
  --wood: #6b4a2e;
  --wood-dark: #4a3120;
  --belt: #2e2620;
  --font-display: 'Yuji Syuku', serif;
  --font-body: 'Zen Kaku Gothic New', sans-serif;
  --font-mono: 'M PLUS 1 Code', monospace;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--paper);
  background:
    radial-gradient(ellipse 120% 70% at 50% -10%, #2c2218 0%, transparent 60%),
    radial-gradient(ellipse 80% 50% at 50% 110%, #241c12 0%, transparent 55%),
    var(--ink);
  overflow: hidden;
}

/* 青海波風の薄い文様 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image:
    radial-gradient(circle at 50% 130%, transparent 38px, var(--gold) 39px, transparent 41px),
    radial-gradient(circle at 0% 130%, transparent 38px, var(--gold) 39px, transparent 41px),
    radial-gradient(circle at 100% 130%, transparent 38px, var(--gold) 39px, transparent 41px);
  background-size: 90px 60px;
}

/* 画面端のビネット */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 180px rgba(0, 0, 0, 0.85);
}

#stage {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
}

/* ============ 暖簾 ============ */
#noren {
  display: flex;
  justify-content: center;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.6));
}

.noren-cloth {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: linear-gradient(180deg, var(--shu) 0%, var(--shu-deep) 100%);
  border-bottom: 4px solid var(--shu-deep);
  padding: 18px 42px 22px;
  clip-path: polygon(0 0, 100% 0, 100% 88%, 92% 100%, 84% 88%, 76% 100%, 68% 88%, 60% 100%, 52% 88%, 44% 100%, 36% 88%, 28% 100%, 20% 88%, 12% 100%, 4% 88%, 0 100%);
  animation: sway 6s ease-in-out infinite;
  transform-origin: top center;
}

@keyframes sway {
  0%, 100% { transform: skewX(0deg); }
  50% { transform: skewX(0.8deg); }
}

.noren-slit { width: 2px; background: rgba(0, 0, 0, 0.25); margin: 0 26px; }

#noren h1 {
  font-family: var(--font-display);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--paper);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.noren-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  font-size: 34px;
  line-height: 1;
}

.noren-name { font-size: 36px; letter-spacing: 0.12em; }

/* ============ 画面切替 ============ */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding-bottom: 40px;
}
.screen.active { display: flex; }

/* ============ スタート画面 ============ */
.tagline {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--paper-dim);
  letter-spacing: 0.25em;
  animation: fadein 0.8s ease both;
}

.lantern-row { display: flex; gap: 26px; animation: fadein 0.8s 0.15s ease both; }

.lantern {
  display: grid;
  place-items: center;
  width: 64px;
  height: 84px;
  border-radius: 50% / 46%;
  background: radial-gradient(ellipse at 50% 38%, #e8643c 0%, var(--shu-deep) 75%);
  border-top: 5px solid #2b2118;
  border-bottom: 5px solid #2b2118;
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--paper);
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.6);
  box-shadow: 0 0 34px rgba(232, 110, 60, 0.35);
  animation: lantern-glow 3s ease-in-out infinite;
}
.lantern:nth-child(2) { animation-delay: 0.7s; }
.lantern:nth-child(3) { animation-delay: 1.4s; }

@keyframes lantern-glow {
  0%, 100% { box-shadow: 0 0 30px rgba(232, 110, 60, 0.3); }
  50% { box-shadow: 0 0 48px rgba(232, 110, 60, 0.55); }
}

#courses { display: flex; gap: 20px; animation: fadein 0.8s 0.3s ease both; }

.course {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 220px;
  padding: 26px 18px 22px;
  background: linear-gradient(170deg, var(--ink-2), #1a140e);
  border: 1px solid #4d3d28;
  border-radius: 6px;
  color: var(--paper);
  font-family: var(--font-body);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.course:hover {
  transform: translateY(-5px);
  border-color: var(--gold);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 18px rgba(212, 175, 55, 0.15);
}
.course.recommended { border-color: #7a6230; }

.course-badge {
  position: absolute;
  top: -12px;
  background: var(--shu);
  color: var(--paper);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 99px;
  letter-spacing: 0.1em;
}

.course-key {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--paper-dim);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--paper-dim);
}

.course-name { font-family: var(--font-display); font-size: 23px; letter-spacing: 0.06em; }
.course-price { color: var(--gold); font-weight: 700; font-size: 15px; }
.course-desc { color: var(--paper-dim); font-size: 13px; }

.hint { color: #7d6f57; font-size: 13px; letter-spacing: 0.08em; animation: fadein 0.8s 0.45s ease both; }

@keyframes fadein { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ============ プレイ画面 ============ */
#screen-play { justify-content: flex-start; gap: 0; padding-top: 26px; }

#hud {
  display: flex;
  align-items: center;
  gap: 34px;
  width: 100%;
  max-width: 860px;
  padding: 14px 22px;
  background: rgba(22, 17, 13, 0.7);
  border: 1px solid #3c2f1f;
  border-radius: 8px;
}

.hud-block { display: flex; align-items: center; gap: 10px; }
.hud-block:first-child { flex: 1; }

.hud-label { font-size: 12px; color: var(--paper-dim); letter-spacing: 0.15em; white-space: nowrap; }
.hud-num { font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: var(--gold); }

#timebar {
  flex: 1;
  height: 10px;
  background: #0d0a07;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid #3c2f1f;
}
#timebar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--shu), #e8814c);
  transform-origin: left;
  transition: transform 1s linear;
}
#time-num { font-family: var(--font-mono); font-size: 22px; font-weight: 700; min-width: 56px; text-align: right; }

#mute {
  background: none;
  border: 1px solid #3c2f1f;
  border-radius: 6px;
  font-size: 16px;
  padding: 6px 10px;
  cursor: pointer;
  filter: grayscale(0.3);
}
#mute:hover { border-color: var(--gold); }

/* ---- レーン ---- */
#belt-area {
  position: relative;
  width: 100vw;
  max-width: 1080px;
  height: 190px;
  margin-top: 46px;
}

#belt {
  position: absolute;
  inset: 36px 0 0;
  background: linear-gradient(180deg, var(--wood) 0%, var(--wood-dark) 100%);
  border-top: 6px solid #7d5a38;
  border-bottom: 6px solid #33220f;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.6);
}

.belt-strip {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 44px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, var(--belt) 0 70px, #382e26 70px 72px);
  border-top: 2px solid #14100c;
  border-bottom: 2px solid #14100c;
  animation: belt-move 1.1s linear infinite;
}

@keyframes belt-move {
  from { background-position-x: 0; }
  to { background-position-x: -72px; }
}

#plate {
  position: absolute;
  top: 6px;
  left: 100%;
  width: 150px;
  text-align: center;
  will-change: left;
}
#plate.hidden { visibility: hidden; }

#sushi {
  position: relative;
  z-index: 2;
  font-size: 58px;
  display: block;
  line-height: 1;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.45));
}

.dish {
  position: relative;
  margin: -14px auto 0;
  width: 130px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 35%, #fdfaf2 0%, #ddd5c4 70%);
  box-shadow: 0 8px 10px rgba(0, 0, 0, 0.5);
}
.dish-rim {
  position: absolute;
  inset: 4px 10px;
  border-radius: 50%;
  background: #4a7ec2;
  opacity: 0.85;
}

#plate.eaten { animation: eat 0.22s ease-in forwards; }
@keyframes eat {
  to { transform: translateY(-46px) scale(0.55); opacity: 0; }
}

/* ---- ワード表示 ---- */
#word-card {
  margin-top: 40px;
  width: 100%;
  max-width: 760px;
  text-align: center;
  background: linear-gradient(180deg, rgba(243, 233, 212, 0.04), rgba(243, 233, 212, 0.01));
  border: 1px solid #3c2f1f;
  border-radius: 10px;
  padding: 30px 28px 34px;
}

#word-display {
  font-family: var(--font-display);
  font-size: clamp(26px, 4.2vw, 44px);
  letter-spacing: 0.05em;
  min-height: 1.3em;
}
#word-display.shake { animation: shake 0.32s ease; color: #e07050; }
@keyframes shake {
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

#word-kana { color: var(--paper-dim); font-size: 16px; margin-top: 8px; letter-spacing: 0.1em; }

#word-romaji {
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: clamp(18px, 2.6vw, 27px);
  letter-spacing: 0.06em;
  word-break: break-all;
}
#romaji-done { color: var(--gold); }
#romaji-rest { color: #8d8170; }
#romaji-rest.flash-miss { color: #e05540; }

/* ---- カウントダウン ---- */
#countdown {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 7, 5, 0.55);
  z-index: 50;
}
#countdown.hidden { display: none; }
#countdown span {
  font-family: var(--font-display);
  font-size: 130px;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(212, 175, 55, 0.4);
}
#countdown span.pop { animation: pop 0.75s ease both; }
@keyframes pop {
  0% { transform: scale(1.6); opacity: 0; }
  30% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.92); opacity: 0.9; }
}

/* ============ 結果画面 ============ */
.result-title {
  font-family: var(--font-display);
  font-size: 42px;
  letter-spacing: 0.3em;
  color: var(--gold);
}

#result-verdict { font-size: 20px; }
#result-verdict em { font-style: normal; color: var(--gold); font-weight: 700; font-size: 26px; }
#result-verdict em.loss { color: #e07050; }

#result-grid {
  display: grid;
  grid-template-columns: repeat(3, 200px);
  gap: 14px;
}

.r-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 10px;
  background: rgba(22, 17, 13, 0.7);
  border: 1px solid #3c2f1f;
  border-radius: 8px;
}
.r-label { font-size: 12px; color: var(--paper-dim); letter-spacing: 0.15em; }
.r-val { font-family: var(--font-mono); font-size: 24px; font-weight: 700; }

.result-actions { display: flex; gap: 16px; margin-top: 8px; }

.result-actions button, .result-actions a {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  padding: 12px 26px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.result-actions button {
  background: var(--shu);
  color: var(--paper);
  border: none;
}
.result-actions a {
  background: transparent;
  color: var(--paper);
  border: 1px solid #4d3d28;
}
.result-actions button:hover, .result-actions a:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

/* ============ レスポンシブ ============ */
@media (max-width: 760px) {
  .noren-name { font-size: 26px; }
  .noren-mark { width: 44px; height: 44px; font-size: 26px; }
  #courses { flex-direction: column; }
  .course { width: 280px; padding: 18px; }
  #result-grid { grid-template-columns: repeat(2, 1fr); width: 100%; }
  #hud { gap: 16px; flex-wrap: wrap; }
}
