:root {
  --bg: #070b12;
  --panel: rgba(15, 22, 36, 0.92);
  --line: rgba(120, 160, 220, 0.16);
  --ink: #dce6f5;
  --dim: #7f8ea6;
  --accent: #6ee7b7;
  --gold: #fbbf24;
  --red: #f87171;
}

@font-face {
  font-family: "Noto Sans TC";
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/noto-tc-400.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Sans TC";
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/noto-tc-700.woff2") format("woff2");
}

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

body {
  min-height: 100vh;
  background:
    radial-gradient(800px 500px at 85% -10%, #16233d55, transparent),
    radial-gradient(600px 400px at 0% 110%, #2a241055, transparent),
    var(--bg);
  color: var(--ink);
  font: 15px/1.6 "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  display: flex;
  justify-content: center;
  padding: 32px 14px;
}

#app { width: 100%; max-width: 520px; }

header h1 { font-size: 25px; }
header h1 .latin { color: var(--dim); font-size: 13px; letter-spacing: 0.28em; margin-left: 8px; font-weight: 500; }
.tagline { color: var(--dim); font-size: 13.5px; margin: 5px 0 16px; }

.pill-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.pill {
  font-size: 12.5px; padding: 4px 12px; border-radius: 999px;
  background: rgba(110,231,183,0.1); border: 1px solid var(--line); color: var(--accent);
}
.pill.bad { color: var(--red); background: rgba(248,113,113,0.1); }
.pill.link { color: var(--dim); text-decoration: none; }
.pill.link:hover { color: var(--ink); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.tabs { display: flex; padding: 6px; gap: 6px; }
.tab {
  all: unset; cursor: pointer; flex: 1; text-align: center;
  padding: 9px 4px; border-radius: 9px; font-size: 14px; color: var(--dim);
}
.tab.active { background: rgba(110,231,183,0.14); color: var(--ink); }
.tab b {
  background: var(--gold); color: #000; border-radius: 999px;
  font-size: 11px; padding: 1px 7px; margin-left: 4px;
}

.panel[hidden] { display: none; }

#scanner-box { position: relative; border-radius: 10px; overflow: hidden; background: #000; aspect-ratio: 4/3; margin-bottom: 10px; }
#video { width: 100%; height: 100%; object-fit: cover; }
#scan-frame {
  position: absolute; inset: 18% 12%;
  border: 2px solid rgba(110,231,183,0.8);
  border-radius: 12px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.35);
  pointer-events: none;
}
#scan-frame::after {
  content: ''; position: absolute; left: 8%; right: 8%; top: 50%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scanline 2.2s ease-in-out infinite;
}
@keyframes scanline { 0%,100% { top: 22%; } 50% { top: 76%; } }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 5px; }
input {
  width: 100%; background: rgba(255,255,255,0.05);
  border: 1px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: 12px 14px; font: inherit;
  font-size: 22px; letter-spacing: 0.14em; text-align: center; outline: none;
}
input:focus { border-color: var(--accent); }

button.wide {
  all: unset; cursor: pointer; display: block; width: 100%; text-align: center;
  background: rgba(110,231,183,0.16); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font: inherit; font-size: 16px; font-weight: 500;
}
button.wide:hover { background: rgba(110,231,183,0.28); }
.ghost-btn {
  all: unset; cursor: pointer; font-size: 13px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px;
}
.ghost-btn:hover { color: var(--ink); }
.hint { color: var(--dim); font-size: 13px; margin-bottom: 10px; }

.history { list-style: none; margin-bottom: 12px; max-height: 320px; overflow-y: auto; }
.history li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px; border-bottom: 1px dashed rgba(255,255,255,0.06); font-size: 14px;
}
.history .num { font-family: ui-monospace, monospace; letter-spacing: 0.08em; flex: 1; }
.history .tag { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: rgba(255,255,255,0.06); color: var(--dim); }
.history li.sixth .tag, .history li.fifth .tag, .history li.fourth .tag, .history li.third .tag,
.history li.second .tag, .history li.first .tag, .history li.grand .tag, .history li.special .tag {
  background: rgba(251,191,36,0.18); color: var(--gold); font-weight: 600;
}
.history time { color: var(--dim); font-size: 12px; }

.verdict { text-align: center; padding: 26px 18px; }
.verdict[hidden] { display: none; }
.v-emoji { font-size: 46px; }
.v-title { font-size: 22px; font-weight: 700; margin: 8px 0 4px; }
.v-sub { color: var(--dim); font-size: 13.5px; }
.verdict.win { border-color: rgba(251,191,36,0.5); }
.verdict.jackpot { border-color: var(--gold); box-shadow: 0 0 40px -8px rgba(251,191,36,0.45); }
.verdict.lose .v-title { color: var(--dim); }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

footer { color: var(--dim); font-size: 12px; margin-top: 18px; line-height: 1.7; }
footer a { color: var(--dim); }
footer a:hover { color: var(--accent); }
