/* By My Heart — candlelit restaurant look */

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

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: radial-gradient(120% 90% at 50% 30%, #3a2418 0%, #241511 70%, #180d0a 100%);
  color: #f3e9d6;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  max-width: 560px;
  margin: 0 auto;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
}

#levelBadge {
  font-size: 13px;
  letter-spacing: .08em;
  background: rgba(255, 210, 122, .14);
  border: 1px solid rgba(255, 210, 122, .35);
  color: #ffd27a;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

#hudTitle {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-style: italic;
  opacity: .55;
  letter-spacing: .04em;
}

.hudBtn {
  flex: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(243, 233, 214, .3);
  background: rgba(243, 233, 214, .08);
  color: #f3e9d6;
  font-family: inherit;
  font-size: 17px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.hudBtn:active { background: rgba(243, 233, 214, .22); }

/* drawn rather than typed: a house glyph would depend on the system font */
.hudBtn svg { width: 15px; height: 15px; fill: currentColor; }

/* ---------- table-name banner (fixed at top for the whole level) ---------- */

#captionBar {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 19;
  max-width: 92%;
  text-align: center;
  background: rgba(36, 21, 17, .72);
  border: 1px solid rgba(255, 210, 122, .35);
  border-radius: 999px;
  color: #ffd27a;
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.3;
  padding: 7px 16px;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}
#captionBar.shown { opacity: 1; }

/* ---------- dialogue bubble (below the table) ---------- */

#dialogue {
  position: absolute;
  bottom: max(110px, calc(env(safe-area-inset-bottom) + 96px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(92%, 420px);
  background: rgba(252, 248, 240, .96);
  color: #3a2418;
  border-radius: 16px;
  border-top-left-radius: 4px;
  padding: 9px 14px;
  font-size: 15.5px;
  line-height: 1.35;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}
#dialogue.shown { opacity: 1; }
#dlgSpeaker { font-size: 24px; font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif; }

/* ---------- stage / scene ---------- */

#stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#scene {
  width: 100%;
  height: 100%;
  display: block;
}

#scene text {
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
}

/* characters */
.char {
  transition: transform .95s cubic-bezier(.45, .05, .35, 1);
  will-change: transform;
}
.char.noTrans { transition: none; }
.charShadow { fill: rgba(0, 0, 0, .35); }
.charFace { font-size: 34px; }
.stranger .charFace { font-size: 30px; }

.char.walking .charBody { animation: waddle .32s ease-in-out infinite alternate; }
@keyframes waddle {
  from { transform: rotate(-4deg) translateY(0); }
  to   { transform: rotate(4deg)  translateY(-2px); }
}
.charBody { transform-box: fill-box; transform-origin: center 80%; }

.char.wobble .charBody { animation: wobble .5s ease-in-out 2; }
@keyframes wobble {
  0%   { transform: rotate(0); }
  25%  { transform: rotate(-9deg); }
  75%  { transform: rotate(9deg); }
  100% { transform: rotate(0); }
}

/* scale lives on .charInner so it can't clobber the position on .char */
.char.popIn .charInner {
  animation: popIn .4s cubic-bezier(.2, 1.6, .4, 1) backwards;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.3); }
  to   { opacity: 1; transform: scale(1); }
}

/* whoever is talking breathes, so the bubble at the bottom of the screen has
 * a visible owner; two beats and it settles (see markSpeaking) */
.charFace.speaking {
  transform-box: fill-box;
  transform-origin: center;
  animation: breathe 1.7s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

/* selectable seat pulse ring */
.pulseRing {
  fill: none;
  stroke: #ffd27a;
  stroke-width: 3;
  transform-box: fill-box;
  transform-origin: center;
  animation: pulse 1.15s ease-out infinite;
  pointer-events: none;
}
@keyframes pulse {
  0%   { transform: scale(.75); opacity: .95; }
  70%  { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

.seatHit { fill: transparent; cursor: pointer; }

/* floating fx (hearts, kiss) */
.fx {
  transform-box: fill-box;
  transform-origin: center;
  animation: floatUp 1.4s ease-out forwards;
  pointer-events: none;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translateY(6px) scale(.6); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-46px) scale(1.15); }
}

.debugLabel { font-size: 11px; fill: #7fd4ff; font-family: monospace; }
.debugArrow { stroke: #7fd4ff; stroke-width: 1.5; fill: none; marker-end: url(#dbgArrowHead); }

/* finale: water bottle + wrong-tap wiggle + heart zoom */
.bottleTip {
  transform-box: fill-box;
  transform-origin: center bottom;
  transition: transform .7s cubic-bezier(.6, -0.15, .85, 1);
}
/* +55deg swings the neck toward the fries plate (up and to the right) */
.bottleTip.tipped { transform: rotate(55deg); }

.wiggle {
  transform-box: fill-box;
  transform-origin: center;
  animation: wobble .5s ease-in-out 1;
}

/* finale: the 2s crowning — glow peaks at 50%, where the face is swapped */
.charFace.crowning {
  transform-box: fill-box;
  transform-origin: center;
  animation: crowning 2s ease-in-out forwards;
}
@keyframes crowning {
  0%   { transform: scale(1); filter: none; }
  50%  { transform: scale(1.45); filter: drop-shadow(0 0 10px #ffd27a) drop-shadow(0 0 22px #fff6e0); }
  100% { transform: scale(1); filter: drop-shadow(0 0 7px rgba(255, 210, 122, .9)); }
}

.crownHalo {
  fill: none;
  stroke: #ffd27a;
  stroke-width: 2.5;
  transform-box: fill-box;
  transform-origin: center;
  animation: crownHalo 2s ease-out backwards;
}
@keyframes crownHalo {
  0%   { opacity: 0; transform: scale(.35); }
  25%  { opacity: .9; }
  100% { opacity: 0; transform: scale(2.5); }
}

#heartZoom {
  position: absolute;
  inset: 0;
  z-index: 38;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 110px;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
  pointer-events: none;
}
#heartZoom.zooming { animation: heartZoom 2.4s cubic-bezier(.45, 0, .8, .3) forwards; }
@keyframes heartZoom {
  0%   { opacity: 0; transform: scale(.05); }
  12%  { opacity: 1; }
  100% { opacity: 1; transform: scale(32); }
}

/* ---------- next button ---------- */

#nextBtn {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  animation: btnIn .35s cubic-bezier(.2, 1.4, .4, 1) backwards;
}
@keyframes btnIn {
  from { opacity: 0; transform: translateX(-50%) translateY(14px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#nextBtn, .ovBtn {
  font-family: inherit;
  font-size: 17px;
  background: #c94f4f;
  color: #fff8f0;
  border: none;
  border-radius: 999px;
  padding: 12px 30px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}
#nextBtn:active, .ovBtn:active { transform: translateX(-50%) scale(.96); }
.ovBtn:active { transform: scale(.96); }

/* ---------- title / end overlay ---------- */

#overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 90% at 50% 30%, #3a2418 0%, #241511 70%, #180d0a 100%);
  transition: opacity .4s ease;
}
#overlay.fadeOut { opacity: 0; pointer-events: none; }

#ovInner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  max-width: 420px;
}

#ovArt {
  font-size: 58px;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
  animation: artBeat 2.2s ease-in-out infinite;
}
@keyframes artBeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

#ovTitle {
  font-size: 40px;
  line-height: 1.1;
  font-weight: normal;
  font-style: italic;
  color: #ffd27a;
  text-shadow: 0 3px 18px rgba(0, 0, 0, .6);
}

#ovSub { font-size: 16px; opacity: .8; line-height: 1.5; }

/* The ending is a few short paragraphs, which wrap into ragged lines with a
 * lone word stranded at the bottom. `balance` evens the lines out; `pretty`
 * is the fallback for browsers that only shipped that one, and browsers with
 * neither just wrap normally. */
#ovSub p {
  text-wrap: pretty;
  text-wrap: balance;
  margin-bottom: 1.1em;
}
#ovSub p:last-child { margin-bottom: 0; }

.ovBtn { margin-top: 6px; min-width: 170px; }

/* level picker */
#levelPicker {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#pickerLabel {
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .5;
}
/* fixed four-per-row grid: eight dinners read as 1234 / 5678, never 7 + 1 */
#pickerRow {
  display: grid;
  grid-template-columns: repeat(4, 42px);
  gap: 8px;
  justify-content: center;
}
.chip {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 210, 122, .45);
  background: rgba(255, 210, 122, .1);
  color: #ffd27a;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
}
.chip:active { background: rgba(255, 210, 122, .3); }
#version {
  margin-top: 20px;
  font-size: 11px;
  letter-spacing: .16em;
  color: rgba(243, 233, 214, .3);
}

.chip.locked {
  border-color: rgba(243, 233, 214, .15);
  background: transparent;
  color: rgba(243, 233, 214, .22);
  cursor: default;
}
#continueBtn { background: transparent; border: 1.5px solid #c94f4f; color: #f0b1b1; box-shadow: none; }
