/* Copyright (c) 2026 Toby Tomlinson. All rights reserved. https://tippingdaily.com */

/* Fonts are served from this site (Latin character set only), so no visitor
   data goes to a font service. Both are under the SIL Open Font License. */
@font-face {
  font-family: 'Bungee';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/bungee-latin.woff2) format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/inter-latin.woff2) format('woff2');
}

:root {
  --bg: #0b0820;
  --panel: #1a1448;
  --panel-2: #241c62;
  --line: rgba(255, 255, 255, .1);
  --ink: #f5f2ff;
  --muted: #aaa3dc;
  --gold: #ffcc33;
  --gold-deep: #b3471d;
  --blue: #2f7bff;
  --good: #2fd27a;
  --bad: #ff4d6d;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse 120% 70% at 50% 0%, #33238a 0%, var(--bg) 65%) fixed, var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }

#app {
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 16px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "score" "machine";
  gap: 10px;
  /* machine width: as big as fits the screen height (canvas is 500x660) */
  --mw: min(100%, 640px, calc((100svh - 150px) * 0.758));
}

/* Header ------------------------------------------------------------------ */
header { grid-area: head; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.hbtns { display: flex; gap: 8px; }
.hbtns.end { justify-content: flex-end; }
#btn-sound .off, #btn-sound.muted .on { display: none; }
#btn-sound.muted .off { display: block; }
#btn-sound.muted { color: var(--muted); }
h1 {
  margin: 0;
  font-family: Bungee, Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(24px, 6vw, 34px);
  letter-spacing: .5px;
  color: var(--gold);
  text-shadow: 0 3px 0 var(--gold-deep), 0 0 22px rgba(255, 204, 51, .35);
  text-transform: uppercase;
}
h1 span { color: #fff; margin-left: .3em; text-shadow: 0 3px 0 #3d2fa8, 0 0 22px rgba(120, 140, 255, .4); }
.icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  font-weight: 800;
}
.icon:hover { background: var(--panel-2); }

/* Score bar --------------------------------------------------------------- */
#scorebar {
  grid-area: score;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "day money" "pips pips";
  align-items: center;
  gap: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.day { grid-area: day; color: var(--muted); font-weight: 600; font-size: 14px; }
.money {
  grid-area: money;
  justify-self: end;
  font-family: Bungee, Impact, sans-serif;
  font-size: 30px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  transition: transform .15s;
}
.money.flash { transform: scale(1.08); }
.pips { grid-area: pips; display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.pip {
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .07);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800;
  color: #fff;
}
.pip.current { outline: 2px solid var(--gold); outline-offset: -2px; }
.pip.pending { background: var(--blue); }
.pip.good { background: #1f8f57; }
.pip.good:not(:empty) { background: var(--good); color: #062a17; }
.pip.bad { background: var(--bad); }
.pip.jack { background: var(--gold); color: #4a2d00; }

/* Machine ----------------------------------------------------------------- */
#machine {
  grid-area: machine;
  justify-self: center;
  display: block;
  width: var(--mw);
  min-width: 260px;
  aspect-ratio: 500 / 660;
  height: auto;
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .06);
  touch-action: manipulation;
}

/* Question panel ---------------------------------------------------------- */
#panel {
  grid-area: panel;
  position: relative;
  z-index: 2;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: start;
}
#qmeta { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
#qtext { font-size: 19px; font-weight: 800; line-height: 1.3; min-height: 2.6em; }
#options { display: grid; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 12px;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-weight: 600;
  font-size: 16px;
  transition: background .15s, transform .08s;
}
.opt:hover:not(:disabled) { background: #30278a; }
.opt:active:not(:disabled) { transform: scale(.98); }
.opt:disabled { cursor: default; opacity: .6; }
.opt .key {
  flex: none;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, .1);
  font-size: 13px; font-weight: 800;
}
.opt.right { background: var(--good); color: #052414; opacity: 1; animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
.opt.wrong { animation: nope .35s ease-in-out; }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes nope { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) { .opt.right, .opt.wrong { animation: none; } }
.opt.wrong { background: var(--bad); opacity: 1; }
.opt.picked { opacity: 1; outline: 2px solid var(--gold); outline-offset: -2px; animation: checking .8s ease-in-out infinite; }
@keyframes checking { 50% { filter: brightness(1.25); } }

.chutes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chutes button {
  padding: 16px 0;
  border-radius: 12px;
  border: none;
  background: var(--gold);
  color: #2a1d6e;
  font-family: Bungee, Impact, sans-serif;
  font-size: 22px;
  box-shadow: 0 4px 0 var(--gold-deep);
  animation: pulse 1.4s ease-in-out infinite;
}
.chutes button:hover { filter: brightness(1.08); }
.chutes button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-deep); }
@keyframes pulse { 50% { box-shadow: 0 4px 0 var(--gold-deep), 0 0 18px rgba(255, 204, 51, .55); } }

#status { min-height: 1.4em; color: var(--muted); font-size: 15px; line-height: 1.4; }
#status.good { color: var(--good); }
#status.bad { color: #ff9aac; }
#status.jack { color: var(--gold); font-size: 17px; }

/* Dialogs ----------------------------------------------------------------- */
dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  padding: 22px 20px 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(5, 3, 20, .7); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 12px; font-family: Bungee, Impact, sans-serif; font-weight: 400; color: var(--gold); font-size: 22px; padding-right: 28px; }
dialog ol { padding-left: 20px; margin: 0 0 12px; line-height: 1.5; }
dialog li { margin-bottom: 6px; }
.close {
  position: absolute; top: 10px; right: 12px;
  width: 32px; height: 32px;
  border: none; border-radius: 50%;
  background: transparent;
  font-size: 24px; line-height: 1;
  color: var(--muted);
}
.close:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.primary {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--gold);
  color: #2a1d6e;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 4px 0 var(--gold-deep);
}
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-deep); }
.small { color: var(--muted); font-size: 14px; line-height: 1.45; }
.center { text-align: center; }
.chip { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; }
.chip.silver { background: radial-gradient(circle at 35% 35%, #ffffff, #c4c9d2 50%, #6f7783); }
.chip.gold { background: radial-gradient(circle at 35% 35%, #fff6c4, #ffcf3f 50%, #b07a0a); }

#end-result { text-align: center; }
.bigmoney { font-family: Bungee, Impact, sans-serif; font-size: 46px; color: var(--gold); text-shadow: 0 3px 0 var(--gold-deep); }
.jackbanner { font-weight: 800; color: var(--gold); margin-bottom: 4px; }
.grid { font-size: 22px; letter-spacing: 2px; margin: 10px 0 4px; white-space: pre-wrap; word-break: break-word; }
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.stats b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

#legal {
  max-width: 780px;
  margin: 0 auto;
  padding: 4px 16px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  opacity: .7;
}

#toast {
  position: fixed; left: 50%; top: 18px;
  transform: translate(-50%, -20px);
  background: #fff; color: #1a1448;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: 10px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 10;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Phones: the question card sits over the drop zone, and shrinks to a status
   strip at the bottom of the machine while a counter is in play. ----------- */
@media (max-width: 819px) {
  #panel {
    grid-area: machine;
    justify-self: center;
    width: calc(var(--mw) - 20px);
    margin-top: 10px;
    padding: 12px;
    gap: 8px;
    background: rgba(26, 20, 72, .95);
    backdrop-filter: blur(6px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
  }
  #qtext { font-size: 17px; min-height: 0; }
  .opt { padding: 9px 12px; font-size: 15px; }
  #status { font-size: 14px; }
  #panel.compact {
    align-self: end;
    margin: 0 0 12px;
    padding: 8px 12px;
    background: rgba(8, 5, 28, .82);
    text-align: center;
  }
  #panel.compact > :not(#status) { display: none; }
}

/* Desktop: one centred column, with the question bar under the machine like
   the TV show: the question across the top, the three answers side by side. */
@media (min-width: 820px) {
  #app {
    max-width: 780px;
    grid-template-areas: "head" "score" "machine" "panel";
    row-gap: 12px;
    --mw: min(640px, calc((100vh - 330px) * 0.758));
  }
  #scorebar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "day pips money";
    gap: 16px;
    padding: 8px 16px;
  }
  .money { font-size: 26px; }

  #panel {
    background: none;
    border: none;
    padding: 0;
    gap: 8px;
  }
  #qmeta { text-align: center; font-size: 12px; }
  #qtext {
    min-height: 0;
    padding: 14px 20px;
    text-align: center;
    font-size: 20px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: linear-gradient(180deg, #2c2668 0%, #17123f 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 10px 24px rgba(0, 0, 0, .35);
  }
  #options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .opt {
    justify-content: center;
    text-align: center;
    padding: 12px 10px;
    border-radius: 12px;
    background: linear-gradient(180deg, #2a2363 0%, #1d1850 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
  }
  .opt:hover:not(:disabled) { background: linear-gradient(180deg, #3a3190 0%, #262070 100%); }
  .opt .key { width: 24px; height: 24px; font-size: 12px; }
  .opt.right { background: linear-gradient(180deg, #4be08f 0%, #22b066 100%); }
  .opt.wrong { background: linear-gradient(180deg, #ff6b85 0%, #d83355 100%); }
  .chutes button { padding: 12px 0; }
  #status { text-align: center; min-height: 1.4em; }
}
