/* =========================================================
 * ロマ子様の激詰め道場 — スタイル
 * 姉妹作『ブラックホール・エスケープ』のガラスモルフィズムUIを継承
 * ========================================================= */

:root {
  --pink: #ff5fa2;
  --pink-soft: #ff9ac6;
  --purple: #8b5cf6;
  --blue: #2b2bd8;
  --bg-0: #17062e;
  --bg-1: #2a0b4a;
  --ok: #48e5a8;
  --ng: #ff4d6d;
  --text: #f4eaff;
  --dim: rgba(244, 234, 255, .45);
  --glass: rgba(255, 255, 255, .07);
  --glass-line: rgba(255, 255, 255, .18);
}

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

html, body {
  height: 100%;
  background: radial-gradient(ellipse at 50% -10%, var(--bg-1) 0%, var(--bg-0) 60%, #0b0218 100%);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  overflow-x: hidden;
}

body::before {
  /* 背景の淡い光 */
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 95, 162, .13), transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(139, 92, 246, .13), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hidden { display: none !important; }

/* ---------- ガラスパネル ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 20px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .38);
}

.screen { padding: 26px 22px; text-align: center; }

/* ---------- タイトル画面 ---------- */
.logo {
  font-size: 26px;
  line-height: 1.25;
  font-weight: 900;
  letter-spacing: .04em;
  background: linear-gradient(100deg, var(--pink) 0%, #ffb3d9 45%, var(--purple) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 16px rgba(255, 95, 162, .55));
  animation: glow 3.4s ease-in-out infinite;
}
.logo__big { font-size: 40px; }
@keyframes glow {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(255, 95, 162, .4)); }
  50%      { filter: drop-shadow(0 0 26px rgba(255, 95, 162, .8)); }
}

.tagline { margin-top: 8px; color: var(--dim); font-size: 13px; letter-spacing: .08em; }

.field { margin-top: 22px; }
.field__label { font-size: 12px; color: var(--dim); letter-spacing: .16em; margin-bottom: 8px; }
.field__note { margin-top: 8px; font-size: 12px; color: var(--dim); min-height: 1.2em; }

.btn-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.opt {
  flex: 1 1 0;
  min-width: 96px;
  padding: 11px 8px;
  border-radius: 13px;
  border: 1px solid var(--glass-line);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform .16s, box-shadow .16s, border-color .16s, background .16s;
}
.opt small { display: block; font-size: 10px; opacity: .6; margin-top: 2px; }
.opt:hover:not(:disabled) { transform: translateY(-2px); background: rgba(255, 255, 255, .1); }
.opt.is-on {
  border-color: var(--pink);
  background: rgba(255, 95, 162, .2);
  box-shadow: 0 0 18px rgba(255, 95, 162, .45);
  transform: scale(1.04);
}
.opt.is-disabled { opacity: .35; cursor: not-allowed; }

.cta {
  margin-top: 26px;
  padding: 14px 42px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(100deg, var(--pink), var(--purple));
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  font-family: inherit;
  letter-spacing: .06em;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(255, 95, 162, .42);
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s;
}
.cta:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 16px 34px rgba(255, 95, 162, .55); }
.cta:active { transform: translateY(0) scale(.98); }
.cta--sub {
  background: rgba(255, 255, 255, .1);
  border: 1px solid var(--glass-line);
  box-shadow: none;
}

.best { margin-top: 16px; font-size: 13px; color: var(--dim); }
.note { margin-top: 14px; font-size: 11px; color: var(--dim); line-height: 1.6; }

/* ---------- ミュートボタン ---------- */
.mute-btn {
  position: fixed;
  top: 12px; right: 12px;
  z-index: 40;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--glass-line);
  background: rgba(255, 255, 255, .08);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
}

/* ---------- IME警告 ---------- */
.ime-warning {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 2, 20, .82);
  backdrop-filter: blur(6px);
  padding: 20px;
  animation: imeIn .18s ease-out;
}
@keyframes imeIn { from { opacity: 0; } to { opacity: 1; } }

.ime-warning__box {
  max-width: 440px;
  padding: 30px 26px;
  border-radius: 22px;
  border: 2px solid var(--ng);
  background: linear-gradient(160deg, rgba(255, 77, 109, .22), rgba(40, 6, 24, .9));
  box-shadow: 0 0 60px rgba(255, 77, 109, .45);
  text-align: center;
  animation: imeShake .45s;
}
@keyframes imeShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-9px); }
  75% { transform: translateX(9px); }
}
.ime-warning__icon { font-size: 40px; }
.ime-warning__title { margin-top: 10px; font-size: 21px; font-weight: 900; color: #ffd9e2; }
.ime-warning__body { margin-top: 14px; font-size: 14px; line-height: 1.85; }
kbd {
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .4);
  background: rgba(255, 255, 255, .14);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
}

/* ---------- HUD ---------- */
.hud { padding: 12px 14px; }

.hud__bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
}
.hud__fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ok), #9df5cf);
  transform-origin: left center;
  transition: background .3s;
}
.hud__fill.is-danger {
  background: linear-gradient(90deg, var(--ng), #ff9aae);
  animation: pulse .5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.hud__row {
  display: flex;
  gap: 6px 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: .06em;
}
.hud__item b { color: var(--text); font-size: 15px; margin-left: 3px; }

/* ---------- プレイ画面 ---------- */
.stage-area {
  margin-top: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.romako-wrap {
  flex: 0 0 118px;
  /* Phase4で scaleX 最大1.44倍に膨らむため、はみ出せるよう余白を確保 */
  padding: 0 14px;
  overflow: visible;
}
.romako {
  width: 100%;
  display: block;
  transform-origin: bottom center;
  transition: transform .6s cubic-bezier(.34, 1.56, .64, 1);
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .5));
}
.romako--ed { width: 150px; margin: 0 auto; }
.romako.is-hit { animation: bob .18s; }
@keyframes bob { 50% { transform: translateY(-5px); } }

.bubble {
  flex: 1 1 auto;
  padding: 20px 18px;
  text-align: left;
  min-height: 168px;
}

.bubble__text {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.55;
  letter-spacing: .02em;
}

.bubble__kana {
  margin-top: 14px;
  font-size: 21px;
  line-height: 1.75;
  letter-spacing: .04em;
  word-break: break-all;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", monospace;
}
/* 入力済み＝ピンク、未入力＝グレー（設計書1-2節） */
.bubble__kana .done { color: var(--pink); text-shadow: 0 0 12px rgba(255, 95, 162, .6); }
.bubble__kana .todo { color: rgba(244, 234, 255, .38); }

.bubble__romaji {
  margin-top: 12px;
  font-family: "Consolas", "SF Mono", monospace;
  font-size: 15px;
  letter-spacing: .09em;
  color: rgba(244, 234, 255, .5);
  word-break: break-all;
  min-height: 1.4em;
}
.bubble__romaji .typed { color: var(--ok); }

/* ---------- フリック（OS標準IME）入力欄 ---------- */
.flick-area { margin-top: 16px; }

.flick-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--glass-line);
  background: rgba(255, 255, 255, .08);
  color: var(--text);
  /* 16px未満だとiOSがフォーカス時に勝手にズームするので下げないこと */
  font-size: 20px;
  font-family: inherit;
  letter-spacing: .04em;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.flick-input::placeholder { color: rgba(244, 234, 255, .3); }
.flick-input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 18px rgba(255, 95, 162, .4);
}
/* 猶予を過ぎても直っていない＝本当に間違えている */
.flick-input.is-wrong {
  border-color: var(--ng);
  box-shadow: 0 0 18px rgba(255, 77, 109, .5);
}

.flick-hint { margin-top: 8px; font-size: 12px; color: var(--dim); }
.flick-hint b { color: var(--pink-soft); }

.flick-refocus {
  margin-top: 10px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--pink);
  background: rgba(255, 95, 162, .18);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

/* ---------- 掛け声 ---------- */
.shout {
  margin-top: 14px;
  min-height: 30px;
  font-size: 15px;
  font-weight: 800;
  color: var(--pink-soft);
  opacity: 0;
  transition: opacity .2s;
}
.shout.is-on { opacity: 1; animation: shoutIn .3s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes shoutIn { from { transform: scale(.7); } to { transform: scale(1); } }

/* ---------- 問題結果フラッシュ ---------- */
.qresult {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 900;
  pointer-events: none;
}
.qresult.is-on { display: flex; animation: qr .6s ease-out; }
@keyframes qr {
  0% { transform: scale(.6); opacity: 0; }
  25% { transform: scale(1.08); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}
.qresult.ok { color: var(--ok); text-shadow: 0 0 30px rgba(72, 229, 168, .8); }
.qresult.ng { color: var(--ng); text-shadow: 0 0 30px rgba(255, 77, 109, .8); }

/* ミス時の赤フラッシュ＋画面揺れ */
body.is-miss::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255, 77, 109, .3);
  pointer-events: none;
  z-index: 25;
}
body.is-miss .wrap { animation: shake .16s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  33% { transform: translateX(-7px); }
  66% { transform: translateX(7px); }
}

/* ---------- スタンプ ---------- */
.stamp {
  display: inline-block;
  padding: 10px 26px;
  border-radius: 10px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: .18em;
  transform: rotate(-8deg);
  animation: stampIn .4s cubic-bezier(.34, 1.8, .64, 1);
}
@keyframes stampIn {
  0% { transform: rotate(-8deg) scale(2.6); opacity: 0; }
  70% { transform: rotate(-8deg) scale(.92); opacity: 1; }
  100% { transform: rotate(-8deg) scale(1); }
}
.stamp--clear { color: var(--ok); border: 4px double var(--ok); }
.stamp--shipped { color: var(--ng); border: 4px double var(--ng); }

/* ---------- ステージクリア ---------- */
.sc__stage { margin-top: 16px; font-size: 17px; font-weight: 800; letter-spacing: .1em; }
.sc__placeholder {
  margin-top: 16px;
  padding: 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .05);
  border: 1px dashed var(--glass-line);
}
.sc__food { font-size: 48px; display: block; animation: bob .8s ease-in-out infinite; }
.sc__note { margin-top: 8px; font-size: 11px; color: var(--dim); }
.sc__quote { margin-top: 18px; font-size: 15px; font-weight: 700; color: var(--pink-soft); line-height: 1.7; }
.sc__stats {
  margin-top: 14px;
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--dim);
}
.sc__stats b { color: var(--text); font-size: 15px; }

/* ---------- 結果表示 ---------- */
.go__rank, .ed__rank {
  margin-top: 18px;
  font-size: 27px;
  font-weight: 900;
  background: linear-gradient(100deg, var(--pink), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.go__quote, .ed__quote {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.85;
  color: var(--pink-soft);
  font-weight: 700;
}

.result {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
}
.result > div {
  padding: 12px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--glass-line);
}
.result dt { font-size: 10px; color: var(--dim); letter-spacing: .08em; }
.result dd { margin-top: 5px; font-size: 20px; font-weight: 800; }

.btn-row--end { margin-top: 8px; gap: 12px; }
.btn-row--end .cta { flex: 0 1 auto; padding: 13px 26px; font-size: 15px; }

.ed__title {
  font-size: 25px;
  font-weight: 900;
  letter-spacing: .1em;
  background: linear-gradient(100deg, #ffd76f, var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ed__romako { margin-top: 16px; }
.ed__note { margin-top: 14px; font-size: 13px; color: #ffd76f; font-weight: 700; min-height: 1.3em; }

/* ---------- 打鍵受け用の隠しinput ---------- */
.sink {
  position: fixed;
  top: -100px; left: -100px;
  width: 1px; height: 1px;
  opacity: 0;
  border: 0;
  pointer-events: none;
}

/* ---------- スマホ ---------- */
@media (max-width: 560px) {
  .logo { font-size: 21px; }
  .logo__big { font-size: 32px; }
  .stage-area { flex-direction: column; align-items: center; }
  .romako-wrap { flex: none; width: 92px; }
  .bubble { width: 100%; min-height: auto; }
  .bubble__text { font-size: 17px; }
  .bubble__kana { font-size: 18px; }
  .hud__item--acc { display: none; }
  .result dd { font-size: 17px; }
}
