:root {
  --ink: #140e0c;
  --ink-2: #221612;
  --paper: #f6ead7;
  --paper-deep: #ead7b8;
  --lacquer: #8e241f;
  --lacquer-deep: #5d1414;
  --gold: #e6c98a;
  --gold-deep: #a9783b;
  --muted: rgba(246, 234, 215, 0.68);
  --line: rgba(230, 201, 138, 0.38);
  --display: "Kaiti SC", "STKaiti", "KaiTi", "Songti SC", "STSong", "PMingLiU", serif;
  --body: "Songti SC", "STSong", "SimSun", "PMingLiU", "Noto Serif SC", serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--body);
  color: var(--paper);
  background: var(--ink);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(980px 560px at 78% -8%, rgba(230, 201, 138, 0.16), transparent 58%),
    radial-gradient(720px 520px at -12% 88%, rgba(142, 36, 31, 0.42), transparent 52%),
    linear-gradient(180deg, #241611 0%, #100c0b 48%, #090807 100%);
}
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.55'/></svg>");
}

#app { position: relative; z-index: 1; min-height: 100dvh; }

.home, .game {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 24px;
}
.home {
  min-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.game {
  min-height: calc(100dvh - 20px);
  display: flex;
  flex-direction: column;
}

.home-kicker, .eyebrow {
  margin: 0;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-family: "Palatino Linotype", Palatino, "Times New Roman", serif;
  font-size: 12px;
  color: var(--gold);
}
.home-title {
  margin: 12px 0 0;
  font-family: var(--display);
  font-size: clamp(72px, 12vw, 148px);
  font-weight: 500;
  line-height: 0.86;
  letter-spacing: 0.08em;
}
.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 48px;
  align-items: end;
}
.lede {
  max-width: 16em;
  margin: 22px 0 0;
  font-size: 22px;
  line-height: 1.55;
  color: var(--muted);
}
.home-side { display: flex; flex-direction: column; gap: 18px; padding-bottom: 10px; }

.game-entry, .empty-seat {
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(20, 12, 10, 0.55);
  border-radius: 22px;
  padding: 22px 22px 18px;
  position: relative;
  overflow: hidden;
}
.game-entry {
  color: var(--paper);
  transition: transform 0.35s ease, border-color 0.35s ease, background 0.35s ease;
}
.game-entry:hover { transform: translateY(-4px); border-color: var(--gold); background: rgba(48, 22, 18, 0.72); }
.game-entry::before {
  content: "";
  position: absolute;
  width: 92px;
  height: 92px;
  right: -18px;
  top: -24px;
  border-radius: 50%;
  border: 1px solid rgba(230, 201, 138, 0.35);
}
.index-no {
  font-family: "Palatino Linotype", Palatino, serif;
  color: var(--gold);
  letter-spacing: 0.18em;
  font-size: 13px;
}
.game-entry h2, .empty-seat h2 {
  margin: 8px 0 6px;
  font-family: var(--display);
  font-size: 46px;
  font-weight: 500;
  letter-spacing: 0.12em;
}
.game-entry p, .empty-seat p { margin: 0; color: var(--muted); line-height: 1.6; }
.entry-go {
  display: inline-block;
  margin-top: 16px;
  color: var(--gold);
  letter-spacing: 0.2em;
}
.empty-seat { opacity: 0.72; }
.home-foot {
  margin-top: 34px;
  color: rgba(246, 234, 215, 0.45);
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  position: relative;
  z-index: 3;
}
.titleblock { flex: 1; min-width: 0; }
.home-btn {
  flex: none;
  align-self: flex-start;
  border: 1px solid var(--line);
  background: rgba(20, 12, 10, 0.45);
  border-radius: 999px;
  padding: 10px 16px;
  letter-spacing: 0.12em;
}
.titleblock h1 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: clamp(40px, 6vw, 68px);
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 0.9;
}
.steps { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.steps span {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: rgba(246, 234, 215, 0.42);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}
.steps span.on { color: var(--gold); border-color: var(--gold); }

.dock {
  width: 148px;
  min-height: 196px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  position: relative;
}
.dock-empty {
  width: 118px;
  height: 168px;
  border-radius: 16px;
  border: 1px dashed rgba(230, 201, 138, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--gold);
  background: rgba(230, 201, 138, 0.04);
}
.dock-empty span { font-size: 12px; letter-spacing: 0.18em; }
.dock-empty strong { font-family: var(--display); font-size: 28px; font-weight: 500; letter-spacing: 0.12em; }
.dock .card { width: 118px; height: 166px; }
.dock-label {
  position: absolute;
  top: -6px;
  right: 0;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--gold);
}

.statusline {
  min-height: 3.2em;
  margin: 22px 0 8px;
  font-size: 20px;
  line-height: 1.55;
}
.statusline em { font-style: normal; color: var(--gold); }

.table {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 8px 0;
}
.table::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(760px, 100%);
  height: 78%;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse, rgba(92, 28, 22, 0.45), transparent 68%);
  pointer-events: none;
}
.table.flash::after {
  content: "";
  position: absolute;
  inset: 10% 18%;
  border-radius: 40px;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 236, 196, 0.28), transparent 62%);
  animation: flash 700ms ease;
}
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 158px));
  gap: clamp(12px, 2.2vw, 26px);
  justify-content: center;
}
.slot { display: grid; place-items: center; }

.card, .ghost {
  width: 146px;
  height: 204px;
  border: 0;
  padding: 0;
  background: transparent;
  position: relative;
}
.card {
  display: block;
  perspective: 1000px;
  isolation: isolate;
}
.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 720ms cubic-bezier(.2,.75,.2,1);
}
.card.lit .card-inner { transform: rotateY(180deg); }
.face, .card-back {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.card-back {
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 226, 176, 0.16), transparent 26%),
    linear-gradient(165deg, #a3332c 0%, #6d1818 58%, #431112 100%);
  box-shadow: inset 0 0 0 1px rgba(230, 201, 138, 0.7), inset 0 0 0 8px rgba(80, 16, 16, 0.35), inset 0 0 0 9px rgba(230, 201, 138, 0.38);
}
.card-back .seal {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 62px;
  height: 62px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--gold);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 28px;
  color: var(--gold);
  letter-spacing: 0;
}
.card-back .no, .face .no {
  position: absolute;
  top: 10px;
  left: 12px;
  font-family: "Palatino Linotype", Palatino, serif;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--gold);
}
.face .no { color: var(--gold-deep); }
.card-back .corner {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 18px;
  height: 18px;
  border-right: 1px solid rgba(230, 201, 138, 0.7);
  border-bottom: 1px solid rgba(230, 201, 138, 0.7);
}
.face {
  transform: rotateY(180deg);
  background:
    linear-gradient(180deg, rgba(255,255,255,.35), transparent 28%),
    linear-gradient(180deg, #fff8ee, #f0dcc0);
  color: #2b160f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 12px 16px;
  box-shadow: inset 0 0 0 1px rgba(120, 72, 32, 0.28), inset 0 0 0 7px rgba(255, 248, 238, 0.7);
}
.face .tag {
  font-size: 12px;
  letter-spacing: 0.22em;
  color: #8a5a32;
}
.face .prize {
  margin-top: 8px;
  font-family: var(--display);
  font-size: clamp(22px, 2.5vw, 32px);
  line-height: 1.2;
  text-align: center;
  letter-spacing: 0.04em;
}
.face.low .prize { font-size: 28px; color: #6d5844; }
.face.mid .prize { color: #7a3b18; }
.face.high {
  background:
    linear-gradient(180deg, rgba(255,255,255,.4), transparent 30%),
    linear-gradient(180deg, #fff4d8, #f0cb86);
}
.face.high .prize { color: #8a2a16; }
.face.jackpot {
  background:
    radial-gradient(circle at 50% 36%, #fff, transparent 36%),
    linear-gradient(180deg, #f8e7c2, #e4c27a 70%, #c9964e);
}
.face.jackpot .prize { font-size: 22px; color: #6b2a12; }
.ribbon {
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 0.24em;
  color: #8e241f;
}
.phone {
  width: 22px;
  height: 34px;
  border: 1.5px solid #6a3b16;
  border-radius: 5px;
  margin-bottom: 4px;
  position: relative;
}
.phone::after {
  content: "";
  position: absolute;
  left: 7px;
  bottom: 3px;
  width: 6px;
  height: 2px;
  border-radius: 2px;
  background: #6a3b16;
}

.card.selected { transform: translateY(-10px); }
.card.selected .card-back, .card.selected .face {
  box-shadow: 0 18px 30px rgba(0,0,0,.28), 0 0 0 2px var(--gold);
}
.card.sealed .card-back { animation: sealpop 720ms cubic-bezier(.2,.8,.2,1); }
@keyframes sealpop {
  0% { filter: brightness(1); }
  40% { filter: brightness(1.35); }
  100% { filter: brightness(1); }
}
.card.enter { animation: deal 560ms cubic-bezier(.16,.84,.22,1) both; animation-delay: calc(var(--i) * 45ms); }
@keyframes deal {
  from { opacity: 0; transform: translateY(24px) rotate(-4deg); }
  to { opacity: 1; transform: none; }
}
.card.selected.enter { animation: none; }

.ghost {
  border-radius: 18px;
  border: 1px dashed rgba(230, 201, 138, 0.32);
  color: rgba(230, 201, 138, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 244, 220, 0.03);
}
.ghost b { font-family: "Palatino Linotype", Palatino, serif; font-weight: 500; letter-spacing: 0.14em; }
.ghost span { font-family: var(--display); letter-spacing: 0.12em; }

.opened {
  min-height: 28px;
  margin: 18px auto 0;
  max-width: 720px;
  text-align: center;
  color: var(--muted);
  line-height: 1.6;
}
.opened b { color: var(--paper); font-weight: 500; }

.actions {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  position: sticky;
  bottom: 14px;
  padding: 12px;
  border-radius: 20px;
  background: rgba(14, 9, 8, 0.78);
  border: 1px solid rgba(230, 201, 138, 0.16);
  backdrop-filter: blur(12px);
}
.actions button, .modal button {
  border-radius: 999px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  background: transparent;
  letter-spacing: 0.12em;
}
.actions button.primary, .modal button.primary {
  background: linear-gradient(#b4332c, #751816);
  border-color: var(--gold);
  color: #f8e7c8;
}
.actions button.gold {
  background: linear-gradient(#f0d7a4, #c89a55);
  color: #3c2012;
  border-color: transparent;
}
.actions button:disabled { opacity: 0.38; }
.actions .hint {
  width: 100%;
  text-align: center;
  color: rgba(246, 234, 215, 0.5);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.finale {
  margin: 8px auto 0;
  max-width: 640px;
  text-align: center;
  padding: 16px 18px 6px;
}
.finale strong {
  display: block;
  font-family: var(--display);
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.finale p { margin: 8px 0 0; color: var(--muted); }

.mask {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: rgba(8, 5, 4, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal {
  width: min(760px, 100%);
  background: linear-gradient(180deg, #2a1b16, #160f0d);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
}
.modal h2 { margin: 0; font-family: var(--display); font-size: 36px; letter-spacing: 0.14em; font-weight: 500; }
.modal .sub { color: var(--muted); margin: 6px 0 16px; }
.fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.fields label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--gold); letter-spacing: 0.12em; }
.fields input {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 248, 238, 0.06);
  padding: 12px;
  letter-spacing: 0.04em;
}
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.form-error { min-height: 1.4em; color: #ffb4a8; margin: 10px 0 0; }

.sound {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(14, 9, 8, 0.8);
  padding: 8px 12px;
  letter-spacing: 0.12em;
  font-size: 13px;
}

@media (max-width: 800px) {
  .home-layout, .topbar, .fields { grid-template-columns: 1fr; }
  .topbar { justify-items: start; }
  .dock { justify-self: end; margin-top: -8px; }
  .home-title { font-size: 84px; }
  .game-entry h2 { font-size: 38px; }
  .statusline { font-size: 17px; }
  .home { justify-content: flex-start; padding-top: 28px; }
  .card, .ghost { width: 104px; height: 146px; }
  .dock .card { width: 96px; height: 134px; }
  .face .prize { font-size: 20px; }
  .actions { position: static; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

.home { min-height: 100dvh; }
.game {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  padding: 18px 0 12px;
  overflow: hidden;
}
.topbar { align-items: center; }
.titleblock h1 { font-size: clamp(28px, 4vw, 46px); }
.steps { margin-top: 6px; }
.dock { width: 136px; min-height: 0; flex: none; padding-top: 18px; }
.dock-empty, .dock .card { width: 116px; height: 156px; }
.dock-empty strong { font-size: 22px; letter-spacing: 0.04em; white-space: nowrap; }
.dock-empty span { letter-spacing: 0.14em; white-space: nowrap; }
.dock-label { top: 0; right: 2px; }
.statusline {
  min-height: 1.45em;
  margin: 8px 0 2px;
  font-size: 16px;
}
.table { min-height: 0; padding: 2px 0 0; }
.grid {
  width: min(100%, 468px);
  height: 100%;
  max-height: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.5vh, 16px);
}
.slot { min-width: 0; min-height: 0; height: 100%; }
.card, .ghost {
  width: auto;
  height: min(100%, 178px);
  aspect-ratio: 5 / 7;
  max-width: 100%;
}
.card { transition: transform 280ms cubic-bezier(.2,.8,.2,1); }
.opened { min-height: 0; margin: 6px auto 0; }
.opened:empty { display: none; }
.actions {
  margin-top: 8px;
  position: static;
  flex: none;
  padding: 8px 10px;
}
.face .prize { font-size: clamp(15px, 2vh, 26px); overflow-wrap: anywhere; }
.face.jackpot .prize { font-size: clamp(13px, 1.7vh, 18px); }
.card-back .seal { width: 46px; height: 46px; font-size: 22px; }
.sound { left: 16px; right: auto; }
@media (hover: hover) {
  .card:hover { transform: translateY(-6px); }
  .card.selected:hover { transform: translateY(-12px); }
}
@media (max-width: 800px) {
  .game { height: auto; max-height: none; overflow: visible; min-height: 100dvh; }
  .topbar { align-items: flex-start; }
  .grid { width: min(100%, 420px); height: auto; }
  .slot { height: auto; }
  .card, .ghost { width: 100%; height: auto; }
  .actions { position: static; }
  .sound { left: auto; right: 12px; top: 12px; bottom: auto; }
}
@media (max-height: 780px) and (min-width: 801px) {
  .card, .ghost { height: min(100%, 142px); }
  .dock { width: 112px; }
  .dock-empty, .dock .card { width: 96px; height: 128px; }
  .dock-empty strong { font-size: 18px; }
  .titleblock h1 { font-size: 32px; }
  .statusline { font-size: 15px; margin-top: 4px; }
}

.finale {
  margin: 2px auto 6px;
  max-width: 760px;
  padding: 0;
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
}
.finale strong { display: inline; font-size: 28px; letter-spacing: 0.08em; }
.finale span { color: var(--muted); }
.table.flash::after { display: none; }

.sound, .sound-slot .sound {
  position: static;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
}
.sound-slot { display: flex; align-items: center; flex: none; }
.face .prize { white-space: nowrap; }
.face.jackpot .prize { white-space: normal; }
.finale { margin-bottom: 10px; }

@media (max-width: 800px) {
  .topbar {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-areas:
      "home sound gap dock"
      "title title title dock";
    align-items: center;
    column-gap: 8px;
    row-gap: 6px;
    justify-items: start;
  }
  .home-btn { grid-area: home; }
  .sound-slot { grid-area: sound; }
  .titleblock { grid-area: title; min-width: 0; }
  .dock { grid-area: dock; align-self: start; justify-self: end; margin-top: 0; width: 112px; }
  .titleblock h1 { font-size: 40px; letter-spacing: 0.1em; white-space: nowrap; }
  .steps { flex-wrap: nowrap; }
  .game { width: min(1120px, calc(100% - 20px)); }
}
