/* Layout: one centered column; the restaurant photo stays visible behind an ivory card with a double gold hairline.
   Single committed look (the photo is the ground on any host theme). */
:root {
  --night: #1a0d06;            /* fallback behind the photo */
  --ivory: rgba(252, 248, 241, 0.95);
  --ink: #2a1408;              /* text */
  --muted: #7a5a40;
  --gold: #b8873b;             /* accent */
  --gold-soft: rgba(184, 135, 59, 0.35);
  --brown: #331807;
  --pine: #1c4137;
  --ember: #e8924b;
  --error: #b3261e;
  --display: "Suez One", "Frank Ruhl Libre", Georgia, serif;
  --body: "Assistant", "Rubik", Arial, sans-serif;
  --ui: "Rubik", "Assistant", Arial, sans-serif;
  color-scheme: light;
}

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

html { background: var(--night); }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--body);
  font-size: 17px;
  color: var(--ink);
  background: var(--night);
  -webkit-font-smoothing: antialiased;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(rgba(20, 10, 5, 0.42), rgba(20, 10, 5, 0.58)),
    url("restaurant-background.jpeg") center / cover no-repeat,
    var(--night);
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: grid;
  align-items: center;
  padding-block: 20px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.screen {
  display: none;
  background: var(--ivory);
  border-radius: 28px;
  padding: 30px 22px 26px;
  text-align: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  /* double gold hairline inside the card */
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px var(--gold-soft),
    inset 0 0 0 7px rgba(252, 248, 241, 0.6),
    inset 0 0 0 8px rgba(184, 135, 59, 0.22);
}

.screen.active {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: rise 0.45s cubic-bezier(.2, .8, .2, 1);
}

.logo {
  display: block;
  width: min(200px, 70%);
  margin: 0 auto 6px;
}
.logo.small { width: min(130px, 50%); }

.eyebrow {
  margin: 0;
  font-family: var(--ui);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--gold);
}

h1, h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.15;
  color: var(--brown);
  text-wrap: balance;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }

.lead {
  margin: 0 auto 6px;
  max-width: 34ch;
  color: var(--muted);
  line-height: 1.55;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
  text-align: right;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-family: var(--ui);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
}

input[type="text"],
.pin-input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid #e2d3bd;
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
.pin-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(184, 135, 59, 0.18);
}

.pin-input {
  text-align: center;
  font-family: var(--ui);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.5em;
  padding-inline-start: calc(16px + 0.5em);
  direction: ltr;
}
.pin-input::placeholder { color: #cdbba3; }
.pin-input.shake { animation: shake 0.42s; border-color: var(--error); }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
  cursor: pointer;
}
.check a { color: var(--brown); font-weight: 700; text-underline-offset: 3px; }
.disabled-msg { color: var(--brown); font-weight: 600; font-size: 1.1rem; margin-top: 8px; }

.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brown); flex: none; }

.error {
  margin: 0;
  color: var(--error);
  font-size: 0.95rem;
  text-align: center;
}

.btn {
  width: 100%;
  font-family: var(--ui);
  font-weight: 700;
  font-size: 1.05rem;
  border-radius: 16px;
  padding: 15px 18px;
  cursor: pointer;
  border: 0;
  transition: transform 0.15s ease, filter 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn.primary {
  color: #f8e9d0;
  background: linear-gradient(180deg, #4d2610, #2a1206);
  border: 1px solid rgba(217, 176, 106, 0.6);
  box-shadow: 0 10px 24px rgba(51, 24, 7, 0.28), inset 0 1px 0 rgba(255, 231, 176, 0.25);
}
.btn.primary:not(:disabled):hover { filter: brightness(1.12); }

.btn.big { font-size: 1.2rem; padding: 17px 18px; }
.btn.big:not(:disabled) { animation: glow 2.2s ease-in-out infinite; }

.btn.ghost {
  color: var(--brown);
  background: transparent;
  border: 1px solid var(--gold-soft);
  margin-top: 6px;
}

.welcome { font-size: 1.6rem; }

/* ---------- wheel ---------- */
.wheel-stage {
  position: relative;
  width: min(100%, 400px);
  aspect-ratio: 1;
  max-width: 100%;
  margin: 26px auto 4px;
}

#wheelCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  filter: drop-shadow(0 16px 24px rgba(51, 24, 7, 0.35));
}

.pointer {
  position: absolute;
  z-index: 3;
  top: -22px;
  left: 50%;
  width: 48px;
  height: 66px;
  margin-left: -24px;
  transform-origin: 24px 20px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}
.pointer svg { display: block; overflow: visible; }

.status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- result ---------- */
.win-view, .lose-view { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }

.win-title {
  font-size: clamp(3rem, 16vw, 4.4rem);
  line-height: 1.05;
  padding-top: 4px;
  background: linear-gradient(100deg, #7a4a14 10%, #d9a24f 45%, #7a4a14 80%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: pop 0.7s cubic-bezier(.2, 1.6, .4, 1) both, sheen 3s linear 0.7s infinite;
}

.ticket {
  position: relative;
  margin: 8px 0 4px;
  color: #f8e9d0;
  animation: flipIn 0.8s cubic-bezier(.2, .9, .2, 1) 0.25s both;
  transform-origin: 50% 0;
  filter: drop-shadow(0 14px 22px rgba(51, 24, 7, 0.3));
}

.ticket-top,
.ticket-bottom {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 18px;
  background: linear-gradient(160deg, #4a2410, #24100606 0%, #2a1206);
  background: linear-gradient(160deg, #4a2410, #2a1206);
  overflow: hidden;
}

.ticket-top {
  border-radius: 20px 20px 0 0;
  border-bottom: 2px dashed rgba(217, 176, 106, 0.55);
  -webkit-mask: radial-gradient(circle 13px at 0 100%, transparent 96%, #000 100%) left / 51% 100% no-repeat,
                radial-gradient(circle 13px at 100% 100%, transparent 96%, #000 100%) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 13px at 0 100%, transparent 96%, #000 100%) left / 51% 100% no-repeat,
                radial-gradient(circle 13px at 100% 100%, transparent 96%, #000 100%) right / 51% 100% no-repeat;
}

.ticket-bottom {
  border-radius: 0 0 20px 20px;
  -webkit-mask: radial-gradient(circle 13px at 0 0, transparent 96%, #000 100%) left / 51% 100% no-repeat,
                radial-gradient(circle 13px at 100% 0, transparent 96%, #000 100%) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 13px at 0 0, transparent 96%, #000 100%) left / 51% 100% no-repeat,
                radial-gradient(circle 13px at 100% 0, transparent 96%, #000 100%) right / 51% 100% no-repeat;
}

/* moving sheen across the ticket: a screenshot of the voucher won't have it */
.ticket-top::after,
.ticket-bottom::after {
  content: "";
  position: absolute;
  inset: -40% auto -40% -60%;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 220, 160, 0.22), transparent);
  transform: skewX(-18deg);
  animation: sweep 3.2s ease-in-out 1.2s infinite;
  pointer-events: none;
}

.ticket-label {
  font-family: var(--ui);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: #d9b06a;
}

.prize-name {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.7rem, 8vw, 2.2rem);
  line-height: 1.15;
  color: #fff4e3;
  text-wrap: balance;
}

.guest-name { font-weight: 700; color: #e9cfa8; }

.code {
  font-family: var(--ui);
  font-weight: 800;
  font-size: clamp(1.7rem, 9vw, 2.3rem);
  letter-spacing: 0.12em;
  color: #ffd99a;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.issued { font-size: 0.92rem; color: #e9cfa8; font-variant-numeric: tabular-nums; }

.note { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

.lose-view h2 { font-size: 2rem; }

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
}

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 10px 24px rgba(51, 24, 7, 0.28), inset 0 1px 0 rgba(255, 231, 176, 0.25); }
  50% { box-shadow: 0 10px 34px rgba(184, 135, 59, 0.6), inset 0 1px 0 rgba(255, 231, 176, 0.25); }
}
@keyframes pop { 0% { transform: scale(0.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes sheen { to { background-position: -220% 0; } }
@keyframes flipIn {
  0% { opacity: 0; transform: perspective(700px) rotateX(-75deg) translateY(-10px); }
  100% { opacity: 1; transform: none; }
}
@keyframes sweep { 0% { left: -60%; } 55%, 100% { left: 130%; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .ticket-top::after, .ticket-bottom::after { display: none; }
}

@media (max-width: 420px) {
  body { font-size: 16px; }
  .screen { padding: 24px 16px 20px; border-radius: 22px; }
  h1 { font-size: 1.75rem; }
}
