/* Scripture Soup - styles */

:root {
  --ink: #3b2a20;
  --cream: #fff4dc;
  --tomato: #e2553d;
  --tomato-dark: #b73a26;
  --broth: #f0a93b;
  --broth-deep: #c77d1a;
  --tile: 58px;
  --rim: 104px;
  --font: "Baloo 2", "Fredoka", "Trebuchet MS", "Comic Sans MS", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (min-width: 700px) and (min-height: 640px) {
  :root { --tile: 70px; --rim: 124px; }
}
@media (max-height: 520px) {
  :root { --tile: 46px; --rim: 74px; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  touch-action: manipulation;
  overscroll-behavior: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; }

.screen { position: fixed; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- shared buttons ---------- */
.btn {
  display: block; width: 100%;
  padding: 12px 18px; margin-top: 10px;
  font-size: 18px; font-weight: 800;
  background: #fff; border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--tomato); color: #fff; text-shadow: 0 2px 0 var(--tomato-dark); }

.icon-btn {
  flex: none; width: 46px; height: 46px; padding: 0;
  display: grid; place-items: center;
  background: #fff; border: 3px solid var(--ink); border-radius: 50%;
  box-shadow: 0 3px 0 var(--ink);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

#mute-btn {
  position: fixed; z-index: 60;
  top: calc(8px + env(safe-area-inset-top)); right: 10px;
  width: 46px; height: 46px; padding: 0;
  display: grid; place-items: center;
  background: #fff; border: 3px solid var(--ink); border-radius: 50%;
  box-shadow: 0 3px 0 var(--ink);
}
#mute-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- story list ---------- */
#screen-menu {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: radial-gradient(circle at 20% 0%, #fff9ec 0%, var(--cream) 60%);
}
.menu-head { text-align: center; padding: calc(22px + env(safe-area-inset-top)) 60px 4px; }
.logo {
  margin: 0; font-size: clamp(34px, 9vw, 60px); line-height: 1; letter-spacing: 1px;
  color: var(--tomato);
  text-shadow: 3px 0 var(--ink), -3px 0 var(--ink), 0 3px var(--ink), 0 -3px var(--ink),
    2px 2px var(--ink), -2px 2px var(--ink), 2px -2px var(--ink), -2px -2px var(--ink), 0 7px 0 var(--ink);
}
.tagline { margin: 16px 0 0; font-size: clamp(15px, 4vw, 20px); font-weight: 700; }
.how {
  max-width: 620px; margin: 14px auto 18px; padding: 0 20px;
  text-align: center; font-size: clamp(14px, 3.6vw, 17px); line-height: 1.35; font-weight: 600;
}
.story-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px;
  width: 100%; max-width: 1000px; margin: 0 auto; padding: 4px 16px calc(28px + env(safe-area-inset-bottom));
}
.card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 12px 14px; background: #fff;
  border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 5px 0 var(--ink);
}
.card:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.card h2 { margin: 0; font-size: 18px; line-height: 1.15; }
.ref { font-size: 13px; font-weight: 700; opacity: .7; }
.card-text { min-width: 0; }
.rounds-row { display: flex; gap: 6px; margin-top: 7px; }
.rd {
  width: 24px; height: 24px; display: grid; place-items: center;
  font-size: 13px; font-weight: 800; background: #fff;
  border: 2px solid var(--ink); border-radius: 50%;
}
.rd.done { background: var(--broth); }

.mini-bowl { position: relative; flex: none; width: 66px; height: 54px; }
.mini-bowl::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 28px; z-index: 2;
  border-radius: 50%; border: 3px solid var(--ink);
  background: radial-gradient(ellipse at 50% 25%, var(--broth), var(--broth-deep));
}
.mini-bowl::after {
  content: ""; position: absolute; left: 4px; right: 4px; top: 13px; bottom: 0; z-index: 1;
  background: linear-gradient(#fbeed3, #e7cfa5);
  border: 3px solid var(--ink); border-top: none; border-radius: 0 0 60px 60px / 0 0 50px 50px;
}

/* ---------- round picker sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; display: none;
  align-items: flex-end; justify-content: center; background: rgba(59, 42, 32, .55);
}
.sheet-backdrop.open { display: flex; }
.sheet {
  width: min(520px, 100%); background: var(--cream);
  border: 3px solid var(--ink); border-bottom: none; border-radius: 24px 24px 0 0;
  padding: 18px 18px calc(16px + env(safe-area-inset-bottom));
  animation: slideup .22s ease-out;
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 24px; border-bottom: 3px solid var(--ink); }
}
.sheet-top { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.sheet h2 { margin: 0; font-size: 21px; line-height: 1.15; }
.round-btn {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; margin-top: 10px; padding: 14px 16px;
  font-size: 18px; font-weight: 800; text-align: left;
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink);
}
.round-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.rb-best { font-size: 14px; font-weight: 700; opacity: .7; }

/* ---------- game screen ---------- */
#screen-game {
  background: #fff7e6;
  background: linear-gradient(180deg, #fff7e6 0%, color-mix(in srgb, var(--broth) 30%, #fff7e6) 100%);
}
.game-head {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 62px 2px 10px;
}
.titles { flex: 1; min-width: 0; text-align: center; }
.titles h1 { margin: 0; font-size: clamp(16px, 4.6vw, 27px); line-height: 1.1; }
.titles .ref { font-size: clamp(12px, 3.3vw, 15px); }

.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; }
.peas { display: flex; gap: 3px; }
.pea {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--ink); background: rgba(255, 255, 255, .7);
}
.pea.done { background: radial-gradient(circle at 35% 30%, #d4f59c, #7cc242 65%); }
@media (max-width: 400px) { .pea { width: 11px; height: 11px; } }
.hud-right { display: flex; align-items: center; gap: 8px; }
.chip {
  padding: 6px 12px; font-size: 16px; font-weight: 800; line-height: 1.2;
  background: #fff; border: 3px solid var(--ink); border-radius: 999px;
}
.timer { font-variant-numeric: tabular-nums; min-width: 62px; text-align: center; }
.hint { box-shadow: 0 3px 0 var(--ink); }
.hint:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.hint:disabled { opacity: .45; cursor: default; }

#field { position: relative; flex: 1; min-height: 100px; overflow: hidden; touch-action: none; }
#ingredients { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
#letters { position: absolute; inset: 0; z-index: 2; }

.ing {
  position: absolute; opacity: var(--o, .45);
  animation: bob var(--d, 8s) ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
}
.ing svg { display: block; width: 100%; height: 100%; }
@keyframes bob {
  from { transform: translate(0, 0) rotate(var(--r0, -10deg)); }
  to   { transform: translate(var(--dx, 14px), var(--dy, -16px)) rotate(var(--r1, 12deg)); }
}

/* noodle letter tiles */
.tile {
  position: absolute; left: 0; top: 0;
  width: var(--tile); height: var(--tile);
  cursor: pointer; will-change: transform; touch-action: none;
}
.face {
  width: 100%; height: 100%; display: grid; place-items: center;
  border-radius: 28%;
  background: radial-gradient(circle at 35% 28%, #fffaf0 0%, #ffe9b8 60%, #f3d08a 100%);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink), inset 0 -4px 0 rgba(200, 140, 50, .35);
  font-size: calc(var(--tile) * .58); font-weight: 900; line-height: 1;
  color: var(--ink); user-select: none; -webkit-user-select: none;
}
.tile.hint .face { animation: hintPulse .7s ease-in-out infinite; }
@keyframes hintPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 0 var(--ink), 0 0 0 0 rgba(255, 216, 77, .9); }
  50% { transform: scale(1.16); box-shadow: 0 4px 0 var(--ink), 0 0 18px 8px rgba(255, 216, 77, .95); }
}

/* toast */
#toast {
  position: absolute; z-index: 5; left: 50%; top: 10px;
  max-width: min(92%, 470px); padding: 8px 16px;
  transform: translateX(-50%); opacity: 0; pointer-events: none;
  text-align: center; font-size: clamp(14px, 3.9vw, 19px); font-weight: 800; line-height: 1.2;
  background: #fff; border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 4px 0 var(--ink);
}
#toast.good { background: #d9f5a8; }
#toast.show { animation: toastPop 2.1s ease forwards; }
@keyframes toastPop {
  0%   { opacity: 0; transform: translateX(-50%) scale(.7); }
  9%   { opacity: 1; transform: translateX(-50%) scale(1.07); }
  15%  { opacity: 1; transform: translateX(-50%) scale(1); }
  82%  { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(1); }
}

/* ---------- the bowl ---------- */
.bowl-zone {
  position: relative; z-index: 3; flex: none;
  display: flex; justify-content: center;
  padding: 0 8px calc(10px + env(safe-area-inset-bottom));
}
.bowl { position: relative; width: min(100%, 560px); }
.rim {
  position: relative; z-index: 2; height: var(--rim);
  border-radius: 50%; border: 4px solid var(--ink);
  background: linear-gradient(#fffaf0, #f1dcb4);
}
.broth {
  position: absolute; inset: 11% 3.5%; border-radius: 50%;
  border: 3px solid var(--ink);
  background: radial-gradient(ellipse at 50% 25%, var(--broth) 0%, var(--broth-deep) 100%);
}
.broth::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background:
    radial-gradient(circle at 12% 62%, rgba(255,255,255,.35) 0 4px, transparent 5px),
    radial-gradient(circle at 86% 38%, rgba(255,255,255,.3) 0 5px, transparent 6px),
    radial-gradient(circle at 70% 78%, rgba(255,255,255,.25) 0 3px, transparent 4px),
    radial-gradient(circle at 30% 22%, rgba(255,255,255,.25) 0 3px, transparent 4px);
}
#slots {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 5px;
}
.slot {
  width: var(--slot, 34px); height: var(--slot, 34px);
  display: grid; place-items: center;
  font-size: calc(var(--slot, 34px) * .62); font-weight: 900; line-height: 1;
  border: 2px dashed rgba(59, 42, 32, .55); border-radius: 28%;
  background: rgba(255, 255, 255, .28);
}
.slot.next { border-color: #fff; background: rgba(255, 255, 255, .5); animation: nextPulse 1.2s ease-in-out infinite; }
@keyframes nextPulse { 50% { background: rgba(255, 255, 255, .22); } }
.slot.filled {
  border: 2px solid var(--ink); animation: none;
  background: radial-gradient(circle at 35% 28%, #fffaf0 0%, #ffe9b8 60%, #f3d08a 100%);
  box-shadow: 0 2px 0 var(--ink);
}
.slot.complete { background: radial-gradient(circle at 35% 28%, #f2ffd9 0%, #c5ee8a 70%, #9fd45c 100%); }
.slot.plop { animation: plop .26s ease-out; }
@keyframes plop { 0% { transform: scale(1.5); } 60% { transform: scale(.9); } 100% { transform: scale(1); } }

.bowl-body {
  position: relative; z-index: 1; overflow: hidden;
  height: calc(var(--rim) * .8); margin: calc(var(--rim) * -.46) 4% 0;
  background: linear-gradient(#fbeed3 0%, #e9d0a4 100%);
  border: 4px solid var(--ink); border-top: none; border-radius: 0 0 50% 50% / 0 0 100% 100%;
}
.bowl-body::after {
  content: ""; position: absolute; left: 0; right: 0; top: 40%; height: 12px;
  background: var(--broth-deep); border-top: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
}
.bowl-foot {
  position: relative; width: 34%; height: 12px; margin: -2px auto 0;
  background: linear-gradient(#e3c896, #cfae78);
  border: 4px solid var(--ink); border-top: none; border-radius: 0 0 12px 12px;
}
.bowl.bounce { animation: bowlBounce .5s ease; }
@keyframes bowlBounce {
  0% { transform: scale(1); } 30% { transform: scale(1.05, .93); }
  60% { transform: scale(.98, 1.04); } 100% { transform: scale(1); }
}

.steam {
  position: absolute; left: 0; right: 0; top: calc(var(--rim) * .2); height: 0; z-index: 4;
  display: flex; justify-content: center; gap: 26px; pointer-events: none;
}
.steam i {
  display: block; width: 10px; height: 38px; border-radius: 10px; opacity: 0; filter: blur(1px);
  background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,.9));
  animation: steam 3.2s ease-in infinite;
}
.steam i:nth-child(2) { animation-delay: 1s; margin-top: -8px; }
.steam i:nth-child(3) { animation-delay: 2s; }
@keyframes steam {
  0%   { transform: translateY(0) scaleY(.6); opacity: 0; }
  25%  { opacity: .85; }
  100% { transform: translateY(-64px) scaleY(1.2); opacity: 0; }
}
@media (max-height: 520px) { .steam { display: none; } }

/* ---------- effects layer ---------- */
#fx { position: fixed; inset: 0; z-index: 70; pointer-events: none; overflow: hidden; }
.carry { position: absolute; left: 0; top: 0; will-change: transform; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 90; pointer-events: none; }

/* ---------- round finished ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 80; display: none;
  align-items: center; justify-content: center; padding: 16px;
  background: rgba(59, 42, 32, .5);
}
.overlay.open { display: flex; }
.result-card {
  width: 100%; max-width: 420px; padding: 22px 20px 20px; text-align: center;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 26px;
  animation: pop .38s cubic-bezier(.2, 1.6, .4, 1);
}
.result-title {
  font-size: clamp(32px, 9vw, 44px); font-weight: 900; line-height: 1.05; color: var(--tomato);
  text-shadow: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink),
    1px 1px var(--ink), -1px 1px var(--ink), 1px -1px var(--ink), -1px -1px var(--ink), 0 5px 0 var(--ink);
}
.result-title.big { font-size: clamp(44px, 14vw, 68px); animation: wobble 1.2s ease-in-out infinite; }
.result-sub { margin: 14px 0 10px; font-size: 16px; font-weight: 700; line-height: 1.3; }
.stats { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }
.stat {
  flex: 1; padding: 8px 4px; display: flex; flex-direction: column; gap: 2px;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px;
}
.stat .k { font-size: 12px; font-weight: 800; opacity: .65; text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.newbest {
  display: inline-block; margin: 4px 0 2px; padding: 4px 14px;
  font-weight: 900; background: #ffd84d; border: 3px solid var(--ink); border-radius: 999px;
  animation: wobble 1s ease-in-out infinite;
}
.result-btns { margin-top: 8px; }

@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes wobble { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }

@media (prefers-reduced-motion: reduce) {
  .ing, .steam i, .result-title.big, .newbest { animation: none; }
}
