/* hotcake/hotcake.css — ぷるぷるホットケーキ・タイピング */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  overflow: hidden;
  user-select: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(ellipse at 50% 20%, #ffe9c2 0%, #ffcf8a 40%, #f2a950 100%);
  overflow: hidden;
  transition: filter .4s;
}
#app.fever {
  background: radial-gradient(ellipse at 50% 20%, #ffdf9e 0%, #ffb45e 40%, #e8862a 100%);
}

.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: block; }

/* ---------- ボタン共通 ---------- */
.btn {
  font-family: inherit;
  font-size: 18px;
  padding: 12px 28px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-weight: bold;
  transition: transform .1s, box-shadow .1s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: #ff8c42; color: #fff; box-shadow: 0 4px 0 #d96a20; }
.btn-secondary { background: #fff3e0; color: #8a5a2b; box-shadow: 0 4px 0 #d8b98e; }
.btn-mute { background: rgba(255,255,255,.7); color: #8a5a2b; font-size: 14px; padding: 8px 18px; }

/* ---------- スタート画面 ---------- */
.start-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}
.title-logo {
  margin: 0;
  font-size: clamp(40px, 7vw, 72px);
  line-height: 1.15;
  color: #7a4a1d;
  text-shadow: 3px 3px 0 #ffe3b3, 6px 6px 0 rgba(0,0,0,.08);
}
.subtitle { margin: 0; color: #9c6b33; font-size: 18px; }

.mode-grid { display: flex; gap: 20px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.mode-card {
  font-family: inherit;
  width: 250px;
  padding: 22px 18px;
  border: 3px solid #e8b06a;
  border-radius: 20px;
  background: rgba(255,255,255,.85);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  transition: transform .12s, box-shadow .12s;
}
.mode-card:hover { transform: translateY(-4px) scale(1.03); box-shadow: 0 10px 24px rgba(160,90,20,.25); }
.mode-icon { font-size: 40px; }

/* ---------- フッター (トップへ戻る・著作表示) ---------- */
.site-footer {
  display: flex;
  gap: 20px;
  align-items: center;
  font-size: 13px;
  color: #9c6b33;
  margin-top: 4px;
}
.site-footer .back-link {
  color: #8a5a2b;
  font-weight: bold;
  text-decoration: none;
  background: rgba(255,255,255,.7);
  padding: 6px 14px;
  border-radius: 999px;
  transition: transform .1s;
}
.site-footer .back-link:hover { transform: translateY(-2px); text-decoration: underline; }
.mode-name { font-size: 22px; font-weight: bold; color: #7a4a1d; }
.mode-desc { font-size: 13px; color: #9c6b33; }
.mode-highscore { font-size: 13px; color: #c98a3d; font-weight: bold; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 14px;
  z-index: 20;
}
.hud-item {
  background: rgba(255,255,255,.8);
  border-radius: 12px;
  padding: 6px 18px;
  text-align: center;
  min-width: 90px;
  box-shadow: 0 2px 8px rgba(160,90,20,.15);
}
.hud-label { display: block; font-size: 11px; color: #9c6b33; }
.hud-value { display: block; font-size: 22px; font-weight: bold; color: #7a4a1d; font-variant-numeric: tabular-nums; }
#hud-time.warning { color: #e04b3a; animation: blink .5s infinite alternate; }
@keyframes blink { from { opacity: 1; } to { opacity: .4; } }

/* ---------- フィーバーバナー ---------- */
#fever-banner {
  display: none;
  position: fixed;
  top: 80px; left: 50%;
  transform: translateX(-50%);
  z-index: 21;
  font-size: 26px;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(90deg, #e8862a, #ff5e3a, #e8862a);
  padding: 8px 30px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(200,60,0,.4);
  animation: fever-pulse .6s infinite alternate;
}
#app.fever #fever-banner { display: block; }
@keyframes fever-pulse { from { transform: translateX(-50%) scale(1); } to { transform: translateX(-50%) scale(1.08); } }

/* ==================================================== */
/* ホットケーキ本体 (CSS描画)                             */
/* ==================================================== */
#hotcake {
  position: fixed;
  left: 50%;
  top: 44%;
  width: 340px;
  height: 260px;
  transform: translate(-50%, -50%);
  z-index: 5;
  transform-origin: 50% 90%;
}
/* 積み上げ用の内側ラッパー(縮小はこちらに掛ける) */
#hotcake-inner {
  position: absolute;
  inset: 0;
  transform-origin: 50% 100%;
  transition: transform .35s ease-out;
}
.cake.cake-extra {
  transition: bottom .3s;
}

/* ぷるぷる (1キーごと・3種をランダム再生) */
#hotcake.jiggle { animation: jiggle .18s ease-out; }
@keyframes jiggle {
  0%   { transform: translate(-50%, -50%) scale(1, 1); }
  30%  { transform: translate(-50%, -50%) scale(1.08, 0.90); }
  60%  { transform: translate(-50%, -50%) scale(0.94, 1.07); }
  100% { transform: translate(-50%, -50%) scale(1, 1); }
}
#hotcake.jiggle2 { animation: jiggle2 .2s ease-out; }
@keyframes jiggle2 {
  0%   { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
  30%  { transform: translate(-50%, -50%) rotate(-2.5deg) scale(1.05, 0.93); }
  65%  { transform: translate(-50%, -50%) rotate(2deg) scale(0.96, 1.05); }
  100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
}
#hotcake.jiggle3 { animation: jiggle3 .2s ease-out; }
@keyframes jiggle3 {
  0%   { transform: translate(-50%, -50%) scale(1); }
  30%  { transform: translate(-50.8%, -50%) scale(0.94, 1.07); }
  65%  { transform: translate(-49.2%, -50%) scale(1.06, 0.94); }
  100% { transform: translate(-50%, -50%) scale(1); }
}
/* 長文完成: 笑顔で飛び跳ねる (2回ホップ) */
#hotcake.jump { animation: jump .85s cubic-bezier(.3,.6,.4,1); }
@keyframes jump {
  0%   { transform: translate(-50%, -50%) scale(1, 1); }
  12%  { transform: translate(-50%, -50%) scale(1.18, 0.78); }
  32%  { transform: translate(-50%, -80%) scale(0.94, 1.12) rotate(-4deg); }
  50%  { transform: translate(-50%, -50%) scale(1.12, 0.88); }
  66%  { transform: translate(-50%, -70%) scale(0.96, 1.08) rotate(3deg); }
  84%  { transform: translate(-50%, -50%) scale(1.07, 0.94); }
  100% { transform: translate(-50%, -50%) scale(1, 1); }
}
/* 単語完成の大きなバウンド */
#hotcake.bounce { animation: bounce .45s ease-out; }
@keyframes bounce {
  0%   { transform: translate(-50%, -50%) scale(1, 1); }
  25%  { transform: translate(-50%, -50%) scale(1.18, 0.8); }
  50%  { transform: translate(-50%, -56%) scale(0.92, 1.12); }
  75%  { transform: translate(-50%, -50%) scale(1.06, 0.95); }
  100% { transform: translate(-50%, -50%) scale(1, 1); }
}
/* ミス時の小さな首ふり */
#hotcake.shake { animation: shake .25s ease-out; }
@keyframes shake {
  0% { transform: translate(-50%, -50%) rotate(0); }
  25% { transform: translate(-52%, -50%) rotate(-3deg); }
  75% { transform: translate(-48%, -50%) rotate(3deg); }
  100% { transform: translate(-50%, -50%) rotate(0); }
}

.plate {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 340px; height: 56px;
  background: linear-gradient(#ffffff, #dfe6ee);
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(120,70,20,.3);
}

.cake {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 260px; height: 74px;
  background: linear-gradient(#f4b04f 0%, #eda23e 55%, #c97a26 100%);
  border-radius: 46% 46% 40% 40% / 60% 60% 46% 46%;
  box-shadow: inset 0 -10px 14px rgba(140,80,20,.35);
}
.cake3 { bottom: 26px; }
.cake2 { bottom: 72px; }
.cake1 { bottom: 118px; }

.syrup {
  position: absolute;
  top: 2px; left: 50%;
  transform: translateX(-50%);
  width: 220px; height: 40px;
  background: linear-gradient(#a3541c, #8a4515);
  border-radius: 48% 48% 42% 42% / 70% 70% 50% 50%;
  opacity: .9;
}
.syrup::before, .syrup::after {
  content: "";
  position: absolute;
  top: 24px;
  width: 22px; height: 34px;
  background: #8a4515;
  border-radius: 0 0 50% 50%;
}
.syrup::before { left: 26px; }
.syrup::after { right: 40px; height: 26px; }

/* シロップあふれモーション (めーぷる/しろっぷ系の単語完成時) */
.syrup.pour { animation: syrup-pour 1.5s ease-out; }
@keyframes syrup-pour {
  0%   { transform: translateX(-50%) scale(1, 1); }
  30%  { transform: translateX(-50%) scale(1.24, 1.5); }
  60%  { transform: translateX(-50%) scale(1.12, 1.25); }
  100% { transform: translateX(-50%) scale(1, 1); }
}
.syrup-drip {
  position: absolute;
  width: 13px; height: 0;
  background: linear-gradient(#a3541c, #7a3b10);
  border-radius: 0 0 8px 8px;
  z-index: 7;
  animation: drip-fall 1.6s ease-in forwards;
}
@keyframes drip-fall {
  0%   { height: 0;     opacity: .95; }
  65%  { height: 115px; opacity: .95; }
  100% { height: 140px; opacity: 0; }
}

.butter {
  position: absolute;
  top: -8px; left: 50%;
  transform: translateX(-50%) rotate(-4deg);
  width: 56px; height: 26px;
  background: linear-gradient(#fff6b8, #ffe36e);
  border-radius: 6px;
  box-shadow: 0 3px 4px rgba(120,70,20,.3);
}

/* 顔 */
.face { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); width: 200px; height: 60px; z-index: 6; }
.eye {
  position: absolute;
  top: 14px;
  width: 14px; height: 18px;
  background: #4a2c12;
  border-radius: 50%;
}
.eye-l { left: 48px; }
.eye-r { right: 48px; }
.mouth {
  position: absolute;
  top: 30px; left: 50%;
  transform: translateX(-50%);
  width: 26px; height: 13px;
  border: 3px solid #4a2c12;
  border-top: none;
  border-radius: 0 0 26px 26px;
}
.cheek {
  position: absolute;
  top: 28px;
  width: 20px; height: 10px;
  background: rgba(255,120,90,.45);
  border-radius: 50%;
}
.cheek-l { left: 22px; }
.cheek-r { right: 22px; }

/* にっこり顔 (単語完成時) */
.face.happy .eye {
  height: 10px; width: 18px;
  background: transparent;
  border-top: 4px solid #4a2c12;
  border-radius: 50% 50% 0 0;
  top: 18px;
}
.face.happy .mouth {
  width: 34px; height: 18px;
  background: #7a3b2e;
  border: 3px solid #4a2c12;
  border-top: none;
  border-radius: 0 0 34px 34px;
}
.face.happy .cheek { background: rgba(255,120,90,.75); }

/* 湯気 */
.steam {
  position: absolute;
  bottom: 210px;
  width: 14px; height: 44px;
  background: rgba(255,255,255,.55);
  border-radius: 999px;
  filter: blur(3px);
  animation: steam 2.4s infinite ease-in-out;
}
.steam.s1 { left: 110px; animation-delay: 0s; }
.steam.s2 { left: 160px; animation-delay: .8s; }
.steam.s3 { left: 210px; animation-delay: 1.6s; }
@keyframes steam {
  0%   { transform: translateY(0) scaleX(1); opacity: 0; }
  30%  { opacity: .8; }
  100% { transform: translateY(-46px) scaleX(1.6); opacity: 0; }
}

/* ==================================================== */
/* 出題エリア — 画面中央に固定 (②)                        */
/* ==================================================== */
#word-area {
  position: fixed;
  left: 50%;
  top: 72%;
  transform: translate(-50%, -50%);
  z-index: 15;
  text-align: center;
  background: rgba(255,255,255,.88);
  border-radius: 20px;
  padding: 18px 44px;
  min-width: 420px;
  max-width: 92vw;
  box-shadow: 0 6px 24px rgba(150,80,20,.25);
}
#word-area.miss-flash { animation: miss-flash .2s; }
@keyframes miss-flash {
  0% { box-shadow: 0 0 0 4px rgba(224,75,58,.7); }
  100% { box-shadow: 0 6px 24px rgba(150,80,20,.25); }
}

#word-display { font-size: 34px; font-weight: bold; color: #5c3a16; }
#word-kana { font-size: 17px; color: #a9824f; margin-top: 2px; }

/* 影文字 (③): 未入力=薄いゴースト、入力済み=濃くなぞられる */
#word-romaji {
  margin-top: 8px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 30px;
  letter-spacing: 3px;
  white-space: nowrap;
}
#romaji-typed { color: #ff7a1a; font-weight: bold; }
#romaji-ghost { color: #d8c3a5; }

/* ==================================================== */
/* ぬいぐるみ応援団 (animation.html 由来のSVGキャラ)      */
/* ==================================================== */
@keyframes om-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-18px); } }
@keyframes om-jiggle { 0%,100% { transform: rotate(-1.4deg) scale(1,1); } 25% { transform: rotate(0deg) scale(1.025,0.975); } 50% { transform: rotate(1.4deg) scale(1,1); } 75% { transform: rotate(0deg) scale(0.98,1.02); } }
@keyframes om-blink { 0%, 90%, 100% { transform: scaleY(1); } 94% { transform: scaleY(0.06); } }

.plush { pointer-events: none; }
.plush-left  { position: fixed; left: 3%;  bottom: 14px; z-index: 4; }
.plush-right { position: fixed; right: 3%; bottom: 14px; z-index: 4; }
.plush-star  { position: absolute; right: 5%; bottom: 8%; z-index: 1; }
#screen-start { position: relative; }

/* 応援ジャンプ (フィーバー突入・長文完成時) */
.plush.cheer { animation: plush-cheer .9s ease-out; transform-origin: 50% 100%; }
@keyframes plush-cheer {
  0%   { transform: translateY(0) scale(1, 1); }
  15%  { transform: translateY(0) scale(1.1, 0.85); }
  35%  { transform: translateY(-46px) scale(0.95, 1.08) rotate(-5deg); }
  55%  { transform: translateY(0) scale(1.08, 0.9); }
  72%  { transform: translateY(-30px) scale(0.97, 1.05) rotate(5deg); }
  88%  { transform: translateY(0) scale(1.04, 0.96); }
  100% { transform: translateY(0) scale(1, 1); }
}
/* フィーバー中は踊るように速く揺れる */
#app.fever .plush div { animation-duration: 1.1s !important; }

/* 画面が狭いときは応援団を隠す(出題エリア優先) */
@media (max-width: 1080px) {
  .plush-left, .plush-right { display: none; }
}

/* ---------- フィーバーの落ち葉 ---------- */
#fever-leaves { position: fixed; inset: 0; pointer-events: none; z-index: 8; overflow: hidden; }
.leaf {
  position: absolute;
  top: -40px;
  font-size: 28px;
  animation: leaf-fall linear forwards;
}
@keyframes leaf-fall {
  from { transform: translateY(0) rotate(0deg); opacity: 1; }
  to   { transform: translateY(110vh) rotate(360deg); opacity: .6; }
}

/* ---------- スコアポップアップ ---------- */
#popups { position: fixed; inset: 0; pointer-events: none; z-index: 25; }
.popup {
  position: absolute;
  font-size: 26px;
  font-weight: bold;
  color: #ff7a1a;
  text-shadow: 2px 2px 0 #fff;
  animation: pop-up .8s ease-out forwards;
}
@keyframes pop-up {
  0%   { transform: translateY(0) scale(.7); opacity: 0; }
  20%  { transform: translateY(-14px) scale(1.15); opacity: 1; }
  100% { transform: translateY(-60px) scale(1); opacity: 0; }
}

/* キラキラ (長文完成時) */
.sparkle {
  position: absolute;
  font-size: 24px;
  animation: sparkle-pop .9s ease-out forwards;
}
@keyframes sparkle-pop {
  0%   { transform: scale(.4) translateY(0); opacity: 0; }
  25%  { transform: scale(1.25) translateY(-12px); opacity: 1; }
  100% { transform: scale(.9) translateY(-75px); opacity: 0; }
}

/* ---------- オーバーレイ / 結果 ---------- */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(60,30,0,.45);
  z-index: 40;
  align-items: center;
  justify-content: center;
}
.overlay.active { display: flex; }

.panel {
  background: #fffaf2;
  border-radius: 24px;
  padding: 34px 48px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(80,40,0,.35);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.panel h2 { margin: 0 0 6px; color: #7a4a1d; }

#screen-result { align-items: center; justify-content: center; }
#screen-result.active { display: flex; }

.result-rank {
  font-size: 72px;
  font-weight: bold;
  line-height: 1;
  text-shadow: 3px 3px 0 rgba(0,0,0,.08);
}
.rank-S { color: #ffb300; animation: fever-pulse2 .5s infinite alternate; }
.rank-A { color: #ff7a1a; }
.rank-B { color: #4caf7d; }
.rank-C { color: #9c6b33; }

.result-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px 32px; }
.result-stat { display: flex; flex-direction: column; min-width: 120px; }
.rs-label { font-size: 13px; color: #9c6b33; }
.rs-value { font-size: 34px; font-weight: bold; color: #7a4a1d; font-variant-numeric: tabular-nums; }

.new-record { display: none; color: #e8862a; font-weight: bold; font-size: 20px; animation: fever-pulse2 .5s infinite alternate; }
.new-record.show { display: block; }
@keyframes fever-pulse2 { from { transform: scale(1); } to { transform: scale(1.1); } }

.result-buttons { display: flex; gap: 16px; margin-top: 6px; }
