/* Timpla! — a warm café look in El Kape's colors (ink, cream and caramel from the POS), with
   a jeepney-signboard title in red, yellow and blue. */
:root {
  --ink: #2b1d14;
  --ink-2: #5b4636;
  --bg: #f6efe4;
  --cream: #fffaf2;
  --card: #fff;
  --caramel: #a5552b;
  --gold: #ffb020;
  --red: #c8352b;
  --red-dark: #8e1f18;
  --blue: #1d4f9c;
  --yellow: #f6c21c;
  --green: #1f7a4a;
  --line: #e6dccd;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --display: 'Arial Black', 'Segoe UI Black', 'Helvetica Neue', Impact, system-ui, sans-serif;
  --outline: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 0 4px 0 var(--ink);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--ink);
  font: 16px/1.4 var(--font);
  /* a faint banig (woven mat) pattern */
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(45deg, rgb(165 85 43 / 0.05) 0 10px, transparent 10px 20px),
    repeating-linear-gradient(-45deg, rgb(29 79 156 / 0.04) 0 10px, transparent 10px 20px);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.screen {
  position: relative;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
}

/* ---------- buttons ---------- */
.btn-primary {
  appearance: none;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 14px 34px;
  font: 900 21px/1 var(--font);
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--red);
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 0.06s, box-shadow 0.06s;
}
.btn-primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn-ghost {
  appearance: none;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 12px 22px;
  font: 800 17px/1 var(--font);
  background: var(--card);
  box-shadow: 0 5px 0 var(--ink);
}
.btn-ghost:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.icon-btn {
  appearance: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--card);
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 2px 0 var(--ink);
}
.corner { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 16px; z-index: 2; }

/* ---------- start screen ---------- */
#start, #over {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  overflow-x: hidden; /* the title's sunburst reaches past the edges */
}
.hero { position: relative; margin: 18px 0 8px; isolation: isolate; }
.sun {
  position: absolute;
  inset: -70px -60px;
  z-index: -1;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgb(246 194 28 / 0.35) 0 9deg, transparent 9deg 18deg);
  -webkit-mask-image: radial-gradient(circle, #000 25%, transparent 68%);
  mask-image: radial-gradient(circle, #000 25%, transparent 68%);
  animation: spin 50s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.sign {
  padding: 10px 24px 12px;
  background: linear-gradient(180deg, #fff 0%, #f1e7d8 100%);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 0 0 4px var(--yellow), 0 0 0 7px var(--red), 0 0 0 10px var(--blue), 0 18px 26px -8px rgb(43 29 20 / 0.45);
}
.sign h1 {
  margin: 0;
  font: 900 clamp(46px, 15vw, 70px)/0.95 var(--display);
  letter-spacing: 0.04em;
  color: var(--red);
  text-shadow: 3px 3px 0 var(--blue), 5px 5px 0 rgb(43 29 20 / 0.25);
}
.sign-top, .sign-route { margin: 0; font: 800 11px/1.6 var(--font); letter-spacing: 0.24em; text-transform: uppercase; }
.sign-top { color: var(--ink-2); }
.sign-route { color: var(--blue); margin-top: 4px; }
.lead { margin: 4px 0 0; max-width: 340px; font-size: 17px; }
.lead span { display: block; margin-top: 4px; font-size: 14px; color: var(--ink-2); }
.demo { width: min(210px, 52vw); aspect-ratio: 1 / 1.1; }
.how {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 400px;
}
.how li {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 8px 4px;
  font-size: 13px;
  line-height: 1.25;
  box-shadow: 0 3px 0 var(--ink);
}
.how span { display: block; font-size: 22px; margin-bottom: 2px; }
.best { margin: 0; font-weight: 800; color: var(--caramel); }
.fact {
  max-width: 400px;
  padding: 10px 14px;
  background: var(--card);
  border: 2px dashed var(--caramel);
  border-radius: 14px;
  font-size: 14px;
  text-align: left;
}
.fact b { display: block; margin-bottom: 2px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--caramel); }

/* ---------- game screen ---------- */
#game {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.hud { display: flex; align-items: center; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  font: 900 18px/1.2 var(--font);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 0 var(--ink);
}
.chip.time b { min-width: 2ch; text-align: right; }
.chip.time.low { background: var(--red); color: #fff; animation: throb 0.5s ease-in-out infinite alternate; }
.chip.pesos { color: var(--green); }
.chip.combo { background: var(--gold); }
.hud .icon-btn { margin-left: auto; width: 40px; height: 40px; font-size: 18px; }
@keyframes throb { to { transform: scale(1.08); } }

.customer { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.avatar {
  position: relative;
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--cream);
  font-size: 34px;
  line-height: 1;
}
.suki-badge {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  font: 800 10px/1.3 var(--font);
  white-space: nowrap;
}
.bubble {
  position: relative;
  min-height: 56px;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
}
.bubble::before, .bubble::after {
  content: '';
  position: absolute;
  top: 18px;
  border: 8px solid transparent;
  border-left: 0;
}
.bubble::before { left: -10px; border-right-color: var(--ink); }
.bubble::after { left: -7px; border-right-color: var(--card); }
.bubble b { display: block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--caramel); }
.bubble p { margin: 0; font-weight: 700; font-size: 15px; line-height: 1.25; }
.bubble.said { animation: said 0.3s ease-out; }
.bubble.happy { background: #e7f6ec; }
.bubble.happy::after { border-right-color: #e7f6ec; }
.bubble.sad { background: #fde9e6; }
.bubble.sad::after { border-right-color: #fde9e6; }
@keyframes said { from { transform: scale(0.94); } }
.queue { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 20px; opacity: 0.7; }

.patience { height: 12px; border: 2px solid var(--ink); border-radius: 999px; background: #eadfcd; overflow: hidden; }
.patience i { display: block; height: 100%; transform-origin: left center; background: hsl(120 62% 42%); }

.order {
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--ink);
}
.order-name { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 6px; font-size: 16px; }
.order-name span { font-weight: 800; color: var(--green); }
.recipe { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.recipe li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}
.recipe li.now { border-color: var(--ink); background: var(--gold); }
.recipe li.done { color: var(--ink-2); background: #f4efe7; }
.recipe .sw { width: 18px; height: 18px; border: 2px solid rgb(43 29 20 / 0.45); border-radius: 50%; }

.pour-zone { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.stage {
  position: relative;
  flex: 1;
  min-height: 150px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: radial-gradient(ellipse at 45% 35%, #fffdf8 0%, #f4e9d9 75%);
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hint {
  position: absolute;
  left: 50%;
  bottom: 10%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 92%;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  font-size: 14px;
  text-align: center;
  animation: nudge 1s ease-in-out infinite alternate;
  pointer-events: none;
}
.hint b { color: var(--gold); }
@keyframes nudge { to { transform: translate(-50%, 4px); } }
.pour-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  min-height: 70px;
  border: 3px solid var(--ink);
  border-radius: 20px;
  background: var(--ink);
  color: var(--cream);
  text-align: left;
  box-shadow: 0 5px 0 #000;
  touch-action: none;
  transition: transform 0.06s, box-shadow 0.06s, background 0.1s, opacity 0.15s;
}
.pour-btn b { display: block; font: 900 20px/1.1 var(--font); letter-spacing: 0.05em; }
.pour-btn small { display: block; margin-top: 2px; font-size: 14px; opacity: 0.85; }
.pour-btn .dot { flex: none; width: 32px; height: 32px; border: 3px solid var(--cream); border-radius: 50%; }
.pour-btn.pouring { background: var(--caramel); transform: translateY(4px); box-shadow: 0 1px 0 #000; }
.pour-btn.waiting { opacity: 0.55; }
.rush .pour-btn:not(.pouring) { background: var(--red-dark); }

/* grades, pesos and banners pop up over the cup */
.pops { position: absolute; inset: 0; display: grid; place-items: start center; padding-top: 12%; pointer-events: none; }
.pop { grid-area: 1 / 1; text-align: center; animation: pop 1.15s ease-out forwards; }
.pop b { display: block; font: 900 clamp(30px, 10vw, 44px)/1 var(--display); color: #fff; text-shadow: var(--outline); }
.pop small {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  font: 800 13px/1.4 var(--font);
}
.pop-perfect b { color: var(--gold); }
.pop-sakto b { color: #5ccf8a; }
.pop-pwede b { color: #ffe08a; }
.pop-sayang b { color: #ff7a6b; }
.pop-cash { margin-top: 26%; }
.pop-cash b { color: #8fe9a0; font-size: clamp(34px, 12vw, 52px); }
@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  14% { transform: scale(1.12); opacity: 1; }
  28% { transform: scale(1); }
  72% { opacity: 1; }
  100% { transform: translateY(-36px); opacity: 0; }
}
.banner {
  position: absolute;
  left: -10%;
  right: -10%;
  top: 40%;
  padding: 8px 0 6px;
  border-block: 3px solid var(--ink);
  background: var(--red);
  color: var(--yellow);
  font: 900 26px/1.1 var(--display);
  text-align: center;
  pointer-events: none;
  animation: banner 1.9s ease-in-out forwards;
}
.banner small { display: block; font: 800 12px/1.5 var(--font); letter-spacing: 0.1em; text-transform: uppercase; color: #fff; }
@keyframes banner {
  0% { transform: translateX(-110%) rotate(-4deg); }
  16%, 82% { transform: translateX(0) rotate(-4deg); }
  100% { transform: translateX(110%) rotate(-4deg); }
}
.brownout {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: radial-gradient(circle at var(--bx, 50%) var(--by, 60%), rgb(255 190 90 / 0.1) 0, rgb(12 7 3 / 0.25) 80px, rgb(12 7 3 / 0.9) 190px);
  animation: flicker 0.45s steps(2) 2;
}
.brownout p {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 8px 18px;
  border-radius: 16px;
  background: rgb(12 7 3 / 0.85);
  color: var(--yellow);
  font: 900 26px/1.2 var(--display);
  text-align: center;
  text-shadow: 0 0 14px rgb(255 160 40 / 0.8);
}
.brownout small { display: block; font: 700 14px var(--font); color: var(--cream); }
@keyframes flicker { 50% { opacity: 0.2; } }

/* ---------- results ---------- */
#over h2 { margin: 8px 0 0; font: 900 clamp(28px, 9vw, 38px)/1.1 var(--display); color: var(--red); }
#over h2:focus { outline: none; }
.earn { margin: 0; }
.earn span { display: block; font-weight: 700; color: var(--ink-2); }
.earn b { display: block; font: 900 clamp(54px, 18vw, 80px)/1 var(--display); color: #8fe9a0; text-shadow: var(--outline); }
.newbest {
  margin: -4px 0 0;
  padding: 4px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--gold);
  font-weight: 900;
  animation: said 0.5s ease-out;
}
.rank {
  display: grid;
  justify-items: center;
  margin: 0;
  padding: 10px 22px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--ink);
}
.rank-emoji { font-size: 34px; line-height: 1.1; }
.rank b { font: 900 22px/1.2 var(--font); }
.rank small { color: var(--ink-2); font-weight: 600; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 400px; margin: 0; }
.stats div { padding: 8px; border: 2px solid var(--ink); border-radius: 12px; background: var(--card); }
.stats dt { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.stats dd { margin: 0; font: 900 24px/1.2 var(--font); }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.ready { margin: 0; font-weight: 700; color: var(--ink-2); }

.paused {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgb(43 29 20 / 0.6);
  text-align: center;
}
.paused p { margin: 0 0 14px; font: 900 32px var(--display); color: var(--cream); }
.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 11;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--cream);
  font-weight: 700;
}

/* a phone held sideways is too short for the cup and the button, so ask for portrait */
.rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  .rotate {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background: var(--bg);
    text-align: center;
  }
  .rotate p { margin: 0; font: 900 22px/1.3 var(--font); }
  .rotate span { display: block; font-size: 48px; animation: turn 1.6s ease-in-out infinite; }
  .rotate small { display: block; font: 600 15px var(--font); color: var(--ink-2); }
}
@keyframes turn { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0); } }

/* short phones: drop the demo cup and tighten up */
@media (max-height: 700px) {
  .demo { display: none; }
  #start, #over { gap: 10px; }
  .hero { margin: 10px 0 2px; }
}
@media (max-height: 640px) {
  #game { gap: 6px; }
  .avatar { width: 48px; height: 48px; font-size: 26px; }
  .bubble { min-height: 48px; }
  .bubble p { font-size: 14px; }
  .pour-btn { min-height: 60px; }
  .fact { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sun, .hint, .chip.time.low, .rotate span { animation: none; }
  .brownout { animation: none; }
  .banner { animation: fade 1.9s ease-in-out forwards; transform: rotate(-4deg); }
  @keyframes fade { 0%, 100% { opacity: 0; } 12%, 85% { opacity: 1; } }
}
