/* ══════════════════════════════════════════
   CSS Variables
══════════════════════════════════════════ */
:root {
  /* Chinese New Year palette */
  --red:        #B1001A;   /* vermilion */
  --red-dark:   #6E0010;
  --red-ink:    #2A0006;

  --gold:       #FFD060;
  --gold-light: #FFF2B8;
  --gold-dark:  #B8872E;

  --bg:         radial-gradient(1200px 700px at 20% 0%, rgba(255,208,96,0.12), transparent 55%),
                radial-gradient(900px 600px at 100% 40%, rgba(255,208,96,0.10), transparent 60%),
                linear-gradient(180deg, #140006 0%, #0A0A0F 55%, #07070C 100%);
  --surface:    rgba(18, 18, 26, 0.86);
  --surface2:   rgba(10, 10, 18, 0.78);

  --border:     rgba(255,255,255,0.08);
  --border2:    rgba(255,208,96,0.18);

  --text:       #ffffff;
  --text-dim:   rgba(255,255,255,0.62);
  --text-faint: rgba(255,255,255,0.28);

  --accent-dim: rgba(255,255,255,0.55);
}
/* ══════════════════════════════════════════
   Reset & Base
══════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* ══════════════════════════════════════════
   App Shell
══════════════════════════════════════════ */
.app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════════
   Header
══════════════════════════════════════════ */
.header {
  display: flex;
  align-items: center;
  padding: 14px 20px 12px;
  border-bottom: 1px solid rgba(255,208,96,0.22);
  flex-shrink: 0;

  /* lacquer red bar */
  background:
    radial-gradient(800px 120px at 30% 0%, rgba(255,208,96,0.20), transparent 55%),
    linear-gradient(180deg, rgba(177,0,26,0.95), rgba(110,0,16,0.92));
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.header-title {
  font-family: 'Noto Serif TC', 'Noto Sans KR', serif;
  color: var(--gold);
  font-size: 26px;
  letter-spacing: 2px;
  text-shadow: 0 0 18px rgba(255,208,96,0.22);
}
.header-sub {
  font-family: 'Bebas Neue', sans-serif;
  color: rgba(255,255,255,0.72);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 5px;
  margin-left: 10px;
  opacity: 0.9;
}
.header-spacer { flex: 1; }

.pill {
  background:
    linear-gradient(180deg, rgba(0,0,0,0.20), rgba(0,0,0,0.40)),
    linear-gradient(135deg, rgba(255,208,96,0.22), rgba(255,208,96,0.08));
  border: 1px solid rgba(255,208,96,0.22);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 900;
  color: rgba(255,255,255,0.86);
  letter-spacing: 1.6px;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}
/* ══════════════════════════════════════════
   Body / Pages
══════════════════════════════════════════ */
.body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.page {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.page.active { display: flex; }

#setup-page {
  overflow-y: auto;
  padding: 16px;
  gap: 12px;
}

/* ══════════════════════════════════════════
   Cards
══════════════════════════════════════════ */
.card {
  background:
    radial-gradient(900px 360px at 30% 0%, rgba(255,208,96,0.08), transparent 55%),
    linear-gradient(180deg, rgba(18,18,26,0.88), rgba(10,10,18,0.76));
  border: 1px solid rgba(255,208,96,0.14);
  border-radius: 22px;
  padding: 16px;
  flex-shrink: 0;
  box-shadow:
    0 16px 40px rgba(0,0,0,0.35),
    inset 0 0 0 1px rgba(255,255,255,0.04);
}
.card-title {
  color: rgba(255,208,96,0.60);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 3px;
  margin-bottom: 12px;
  text-transform: uppercase;
}
/* ══════════════════════════════════════════
   Form Elements
══════════════════════════════════════════ */
.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.field {
  flex: 1;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  padding: 11px 14px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-family: 'Noto Sans KR', sans-serif;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  min-width: 0;
}
.field::placeholder { color: var(--text-faint); }
.field:focus { border-color: rgba(255,208,96,0.65); box-shadow: 0 0 0 4px rgba(255,208,96,0.08); }
.field.qty { flex: 0 0 70px; }

/* ══════════════════════════════════════════
   Buttons
══════════════════════════════════════════ */
.btn-gold {
  background:
    radial-gradient(140px 70px at 30% 25%, rgba(255,255,255,0.35), transparent 60%),
    linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-dark));
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  color: #1A1200;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.6px;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'Noto Sans KR', sans-serif;
  transition: transform .12s, filter .15s, opacity .15s;
  box-shadow: 0 12px 28px rgba(0,0,0,0.25), inset 0 0 0 1px rgba(255,255,255,0.18);
}
.btn-gold:hover  { filter: brightness(1.03); }
.btn-gold:active { transform: translateY(1px) scale(.985); }
.btn-gold.wide   { width: 100%; text-align: center; }
.btn-gold:hover  { opacity: .88; }
.btn-gold:active { transform: scale(.97); }
.btn-gold.wide   { width: 100%; text-align: center; }

.btn-ghost {
  background:
    linear-gradient(180deg, rgba(177,0,26,0.25), rgba(0,0,0,0.20));
  border: 1px solid rgba(255,208,96,0.14);
  border-radius: 14px;
  padding: 12px 16px;
  color: rgba(255,255,255,0.80);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.6px;
  cursor: pointer;
  width: 100%;
  font-family: 'Noto Sans KR', sans-serif;
  transition: opacity .15s, transform .12s;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.btn-ghost:hover { opacity: .92; }
.btn-ghost:active { transform: translateY(1px) scale(.99); }
.btn-ghost:hover { opacity: .75; }

/* ══════════════════════════════════════════
   Player Tags
══════════════════════════════════════════ */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.tag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 30px;
  padding: 6px 8px 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,.8);
}
.tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.35);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  transition: color .15s;
}
.tag-remove:hover { color: rgba(255,255,255,.7); }

/* ══════════════════════════════════════════
   Prize List
══════════════════════════════════════════ */
.prize-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.prize-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
}
.prize-label {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prize-qty-badge {
  background: #12121E;
  border-radius: 8px;
  padding: 4px 10px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  min-width: 36px;
  text-align: center;
}
.icon-btn {
  width: 32px;
  height: 32px;
  background: #14141E;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: rgba(255,255,255,.5);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.icon-btn:hover { background: #1C1C28; }

/* ══════════════════════════════════════════
   Ready card
══════════════════════════════════════════ */
.ready-text  { font-size: 13px; font-weight: 700; }
.ready-ok    { color: #60EE90; }
.ready-no    { color: #EE6060; }
.empty-hint  { color: rgba(255,255,255,.35); font-size: 13px; margin-top: 8px; }

/* ══════════════════════════════════════════
   Play Page Layout
══════════════════════════════════════════ */
#play-page {
  padding: 12px 16px 16px;
  gap: 12px;
}

/* Turn bar */
.turn-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 16px;
  flex-shrink: 0;
}
.turn-label {
  color: var(--accent-dim);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
}
.turn-name {
  flex: 1;
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
}

/* ══════════════════════════════════════════
   Scratch Card
══════════════════════════════════════════ */
.scratch-wrap {
  flex: 1;
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  min-height: 180px;
  border: 1px solid rgba(255,208,96,0.18);
  box-shadow: 0 18px 48px rgba(0,0,0,0.40), inset 0 0 0 1px rgba(255,255,255,0.03);
}
.scratch-wrap::before,
.scratch-wrap::after{
  content:"";
  position:absolute;
  width: 120px;
  height: 120px;
  border-radius: 26px;
  pointer-events:none;
  opacity: 0.35;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,208,96,0.22), transparent 55%),
    conic-gradient(from 180deg, rgba(255,208,96,0.0), rgba(255,208,96,0.25), rgba(255,208,96,0.0));
  filter: blur(0.2px);
}
.scratch-wrap::before{ top:-44px; left:-44px; transform: rotate(18deg); }
.scratch-wrap::after { bottom:-44px; right:-44px; transform: rotate(-12deg); }
.card-back {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 400px at 30% 0%, rgba(255,208,96,0.10), transparent 60%),
    linear-gradient(135deg, rgba(20,0,6,0.75), rgba(10,10,18,0.92));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
}
.card-watermark-tl {
  position: absolute;
  top: 16px;
  left: 20px;
  font-family: 'Bebas Neue', sans-serif;
  color: rgba(255,208,96,.08);
  font-size: 11px;
  letter-spacing: 4px;
  pointer-events: none;
}
.card-watermark-br {
  position: absolute;
  bottom: 16px;
  right: 20px;
  color: rgba(255,255,255,.04);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  pointer-events: none;
}

/* Scattered letter slots */
#letter-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.letter-slot {
  position: absolute;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 900;
  transition: opacity .15s;
  pointer-events: none;
  transform-origin: center;
}

/* Hint */
.hint-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 2;
  pointer-events: none;
}
.hint-marks {
  color: rgba(255,255,255,.06);
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 8px;
}
.hint-text {
  color: rgba(255,255,255,0.55);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.6px;
}
/* Result overlay */
.result-overlay {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 2;
}
.result-overlay.show { display: flex; }
.result-emoji { font-size: 42px; }
.result-box {
  padding: 11px 22px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 900;
  text-align: center;
  background: rgba(0,0,0,.55);
}
.result-box.win  { color: var(--gold);              border: 1px solid rgba(255,208,96,.5); }
.result-box.lose { color: rgba(255,255,255,.8); border: 1px solid #3A3A48; }

/* Foil canvas */
#foil-canvas {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
}

/* ══════════════════════════════════════════
   Action Row & Inventory
══════════════════════════════════════════ */
.action-row {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.action-row > * { flex: 1; }

.inventory {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  flex-shrink: 0;
}
.inv-title {
  color: var(--accent-dim);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2.5px;
  margin-bottom: 10px;
}
.inv-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
}
.inv-tag {
  background: var(--bg);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border2);
  color: rgba(255,255,255,.72);
}
.inv-tag.empty {
  color: rgba(255,255,255,.22);
  border-color: #181820;
}

/* ══════════════════════════════════════════
   Bottom Nav
══════════════════════════════════════════ */
.nav {
  margin: 8px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px;
  display: flex;
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  border-radius: 16px;
  color: var(--accent-dim);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2.5px;
  cursor: pointer;
  font-family: 'Noto Sans KR', sans-serif;
  transition: background .18s, color .18s;
}
.nav-btn.active {
  background:
    radial-gradient(140px 70px at 30% 25%, rgba(255,208,96,0.22), transparent 60%),
    linear-gradient(180deg, rgba(177,0,26,0.55), rgba(0,0,0,0.20));
  color: var(--gold);
  outline: 1px solid rgba(255,208,96,0.22);
}
/* ══════════════════════════════════════════
   Dialog
══════════════════════════════════════════ */
.dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dialog-overlay.show { display: flex; }

.dialog {
  background:
    radial-gradient(700px 260px at 30% 0%, rgba(255,208,96,0.10), transparent 60%),
    linear-gradient(180deg, rgba(18,18,30,0.92), rgba(8,8,14,0.92));
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dialog.win  { border: 1px solid rgba(255,208,96,.5); box-shadow: 0 0 40px rgba(255,208,96,.12); }
.dialog.lose { border: 1px solid #2A2A38;             box-shadow: 0 0 40px rgba(0,0,0,.5); }

.dialog-emoji  { font-size: 48px; margin-bottom: 12px; }
.dialog-player { font-size: 20px; font-weight: 900; margin-bottom: 4px; }
.dialog-sub    { font-size: 14px; font-weight: 700; margin-bottom: 16px; }
.dialog-sub.win  { color: var(--gold); }
.dialog-sub.lose { color: rgba(255,255,255,.4); }

.dialog-prize {
  width: 100%;
  padding: 13px 20px;
  border-radius: 16px;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 20px;
}
.dialog-prize.win  { background: #1C1404; border: 1px solid rgba(255,208,96,.3); color: var(--gold); }
.dialog-prize.lose { background: #0A0A12; border: 1px solid #1E1E2A;            color: rgba(255,255,255,.65); }

.dialog-ok { width: 100%; }

/* ══════════════════════════════════════════
   Scrollbar
══════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ══════════════════════════════════════════
   New Year Badge
══════════════════════════════════════════ */
.newyear-badge{
  font-family: 'Ma Shan Zheng', 'Noto Serif TC', serif;
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--gold);
  padding: 6px 12px;
  margin-right: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,208,96,0.30);
  background:
    radial-gradient(120px 70px at 30% 25%, rgba(255,208,96,0.25), transparent 65%),
    linear-gradient(180deg, rgba(0,0,0,0.12), rgba(0,0,0,0.35));
  box-shadow: 0 10px 24px rgba(0,0,0,0.22), inset 0 0 0 1px rgba(255,255,255,0.06);
  white-space: nowrap;
}

.dialog-footer-mini{
  margin-top: 10px;
  font-size: 6px;
  line-height: 1.2;
  text-align: center;
  color: rgba(255,255,255,0.70);
  letter-spacing: 0.2px;
}

.dialog-footer-mini a{
  color: rgba(255,215,128,0.90);
  text-decoration: none;
  border-bottom: 1px dashed rgba(255,215,128,0.45);
  padding-bottom: 1px;
}

.dialog-footer-mini a:hover{
  color: rgba(255,235,170,1);
  border-bottom-color: rgba(255,235,170,0.85);
}
