/* ==========================================================================
   Malt Shop Games — shared design system
   "Calm vintage diner": cream paper, soft cherry & mint, sign-painter
   lettering, chunky menu-board edges. Built for aging eyes & hands:
   big type, big targets, high contrast, calm motion.
   ========================================================================== */

:root {
  /* The diner is always lit: this is a light-only design. Declaring it
     stops browsers from auto-darkening the page or using dark scrollbars
     and form controls when the device is in dark mode. */
  color-scheme: light;

  /* Palette — calm diner: cream, soft cherry, mint, butterscotch */
  --paper:        #FBF3E2;
  --paper-deep:   #F3E7CC;
  --card-face:    #FFFDF4;
  --ink:          #3A2E28;
  --ink-soft:     #6E5C50;
  --green:        #4E8A81;   /* diner mint — primary action color */
  --green-deep:   #3C6E66;
  --green-felt:   #567A50;   /* solitaire table keeps its classic felt */
  --terracotta:   #B5544C;   /* soft cherry — warm accent */
  --terracotta-deep: #94423B;
  --gold:         #D9A441;   /* butterscotch */
  --blue:         #4A6FA5;
  --red-suit:     #B23A2B;
  --line:         #DACBAC;

  /* Type — Pacifico for sign-script moments, Alfa Slab for headings,
     Atkinson Hyperlegible (designed for low vision) for everything read */
  --font-script: "Pacifico", "Brush Script MT", cursive;
  --font-display: "Alfa Slab One", Georgia, serif;
  --font-body: "Atkinson Hyperlegible", "Helvetica Neue", sans-serif;

  /* Shape & shadow — chunky, friendly, hand-built */
  --radius: 20px;
  --radius-sm: 14px;
  --shadow-soft: 4px 4px 0 rgba(58, 46, 40, 0.14);
  --shadow-lift: 7px 7px 0 rgba(58, 46, 40, 0.18);

  /* Minimum comfortable touch target */
  --touch: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--paper);
  /* gentle warmth + paper grain */
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(217, 164, 65, 0.12), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.23 0 0 0 0 0.18 0 0 0 0 0.16 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  min-height: 100vh;
}

/* Diner floor trim — use sparingly (home page top & bottom) */
.checker {
  height: 20px;
  background:
    repeating-conic-gradient(rgba(58, 46, 40, 0.78) 0% 25%, var(--paper) 0% 50%)
    0 0 / 20px 20px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  flex-wrap: wrap;
}

.topbar .bar-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 27px;
  letter-spacing: 0.5px;
  margin: 0 auto 0 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.topbar .bar-title small {
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 400;
  color: var(--ink-soft);
}

/* ---------- Buttons — menu-board chunky ---------- */
.btn {
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  background: var(--card-face);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-sm);
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 10px 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 3px 3px 0 rgba(58, 46, 40, 0.22);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 rgba(58, 46, 40, 0.22); }

.btn.primary {
  background: var(--green);
  border-color: var(--green-deep);
  color: #FFFDF4;
}

.btn.warm {
  background: var(--terracotta);
  border-color: var(--terracotta-deep);
  color: #FFFDF4;
}

.btn:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 2px;
}

.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ---------- Settings sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(58, 46, 40, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 80;
}

.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 105%);
  width: min(680px, 96vw);
  background: var(--card-face);
  border: 3px solid var(--ink);
  border-bottom: none;
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-lift);
  padding: 26px 28px 34px;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 90;
  max-height: 85vh;
  overflow-y: auto;
}

.sheet.open { transform: translate(-50%, 0); }

.sheet h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  margin: 0 0 18px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.setting-row:last-of-type { border-bottom: none; }

.setting-row .label { font-size: 21px; font-weight: 700; }
.setting-row .hint-text { font-size: 16px; color: var(--ink-soft); width: 100%; margin-top: -6px; }

/* Segmented choice — big tappable pills */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;       /* rows of pills wrap when there are many choices */
  justify-content: center;
  background: var(--paper-deep);
  border: 2px solid var(--ink);
  border-radius: 26px;
  padding: 4px;
  gap: 4px;
}

.segmented button {
  font-family: var(--font-body);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  border-radius: 999px;
  min-height: 52px;
  padding: 8px 22px;
  cursor: pointer;
}

.segmented button.on {
  background: var(--green);
  color: #FFFDF4;
  box-shadow: 2px 2px 0 rgba(58, 46, 40, 0.25);
}

/* Toggle switch — oversized */
.toggle {
  position: relative;
  width: 86px;
  height: 48px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--paper-deep);
  cursor: pointer;
  transition: background 0.2s ease;
  flex: none;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #FFFDF4;
  box-shadow: 0 2px 5px rgba(58, 46, 40, 0.3);
  transition: left 0.2s ease;
}

.toggle.on { background: var(--green); border-color: var(--green-deep); }
.toggle.on::after { left: 42px; }

/* ---------- Win overlay ---------- */
.win-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(58, 46, 40, 0.45);
  z-index: 100;
}

.win-overlay.show { display: flex; }

.win-card {
  background: var(--card-face);
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: var(--shadow-lift);
  text-align: center;
  padding: 40px 52px 44px;
  max-width: min(560px, 92vw);
  animation: pop-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.win-card h2 {
  font-family: var(--font-script);
  font-weight: 400;
  font-size: 52px;
  margin: 0 0 12px;
  color: var(--terracotta);
  text-shadow: 2px 2px 0 rgba(217, 164, 65, 0.55);
}

.win-card p { font-size: 22px; color: var(--ink-soft); margin: 0 0 28px; }

.win-card .btn-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* Confetti canvas sits above everything but ignores touches */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 110;
}

/* ---------- Toast (gentle, non-blocking message) ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 200%);
  background: var(--ink);
  color: var(--paper);
  font-size: 20px;
  font-weight: 700;
  padding: 16px 28px;
  border-radius: 999px;
  box-shadow: var(--shadow-lift);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 70;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.toast.show { transform: translate(-50%, 0); }

/* Phones are narrower than our iPad-first targets — trim the page chrome so
   the fixed-bottom game layouts still fit. Buttons stay generously sized. */
@media (max-width: 520px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .topbar .bar-title { font-size: 22px; gap: 8px; }
  .topbar .bar-title small { font-size: 15px; }
  .btn { font-size: 18px; padding: 8px 14px; min-height: 56px; min-width: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
