@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@600;800&family=Pixelify+Sans:wght@700&display=swap');

:root {
  --felt: #17322b; --red: #d8323c; --blue: #2f7bd6; --gold: #ffd166; --ink: #111; --paper: #f4ecd8;
  --idea: #e05a5a; --twist: #4f8fe0; --green: #4caf74; --muted: rgba(244, 236, 216, .65);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif; font-weight: 600;
  background: var(--felt); color: var(--paper);
  display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden;
  line-height: 1.35;
}
h1, h2, h3 { margin: 0; line-height: 1.1; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---- background ---- */
.swirl { position: fixed; inset: -40vh -40vw; z-index: -1; pointer-events: none; overflow: hidden; }
.swirl::before, .swirl::after {
  content: ""; position: absolute; inset: 0; filter: blur(70px); opacity: .55; transform-origin: 50% 50%;
  animation: swirl 24s linear infinite;
}
.swirl::before { background: radial-gradient(circle at 20% 30%, var(--red) 0, transparent 40%), radial-gradient(circle at 80% 70%, var(--blue) 0, transparent 40%); }
.swirl::after { background: radial-gradient(circle at 70% 25%, var(--blue) 0, transparent 35%), radial-gradient(circle at 30% 80%, var(--red) 0, transparent 35%); animation-direction: reverse; animation-duration: 37s; }
@keyframes swirl { from { transform: rotate(0deg) scale(1.6); } to { transform: rotate(360deg) scale(1.6); } }
.display, .title, .code-big, .count, .cash-big { font-family: "Pixelify Sans", "Nunito", system-ui, sans-serif; font-weight: 700; }
.crt { position: fixed; inset: 0; z-index: 50; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .06) 0 1px, transparent 1px 3px); box-shadow: inset 0 0 160px rgba(0, 0, 0, .55); }
body.flash::before { content: ""; position: fixed; inset: 0; background: var(--red); z-index: 40; pointer-events: none; animation: flashout 1s ease-out forwards; }
@keyframes flashout { from { opacity: .85; } to { opacity: 0; } }

/* ---- layout ---- */
.app { flex: 1; display: flex; flex-direction: column; width: 100%; padding: 16px; margin: 0 auto; position: relative; z-index: 1; }
.app.narrow { max-width: 560px; }
.screen { display: none; flex: 1; flex-direction: column; gap: 16px; animation: pop-in .35s cubic-bezier(.2, .9, .3, 1.3); }
.screen.active { display: flex; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.center { text-align: center; align-items: center; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
@keyframes pop-in { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

.title { font-size: clamp(2rem, 6vw, 4.5rem); font-weight: 700; text-shadow: 5px 5px 0 #000; letter-spacing: .02em; text-transform: uppercase; }
.title small { display: block; font-size: .35em; color: var(--gold); letter-spacing: .3em; }
.h { font-size: 1.6rem; font-weight: 700; text-shadow: 3px 3px 0 #000; text-transform: uppercase; letter-spacing: .05em; }
.emoji-big { font-size: 4rem; line-height: 1; filter: drop-shadow(4px 4px 0 #000); }
.code-big { font-size: clamp(3.5rem, 12vw, 9rem); font-weight: 700; letter-spacing: .25em; text-shadow: 6px 6px 0 #000; color: var(--gold); line-height: 1; }

/* ---- panels ---- */
.panel { background: var(--paper); color: var(--ink); border: 4px solid var(--ink); border-radius: 8px; box-shadow: 0 8px 0 #000; padding: 14px; }
.panel.dark { background: rgba(0, 0, 0, .45); color: var(--paper); box-shadow: 0 8px 0 #000, inset 0 0 0 2px rgba(255, 255, 255, .08); }
.panel .muted { color: rgba(17, 17, 17, .55); }
.panel.dark .muted { color: var(--muted); }

/* ---- buttons & inputs ---- */
.btn {
  font: inherit; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; cursor: pointer;
  background: var(--gold); color: var(--ink); border: 4px solid var(--ink); border-radius: 8px; box-shadow: 0 6px 0 #000;
  padding: 12px 20px; transition: transform .06s, box-shadow .06s; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #000; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 6px 0 #000; }
.btn.red { background: var(--red); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.ghost { background: transparent; color: var(--paper); border-color: var(--paper); box-shadow: 0 6px 0 rgba(0, 0, 0, .6); }
.panel .btn.ghost { color: var(--ink); border-color: var(--ink); }
.btn.big { font-size: 1.3rem; padding: 16px 24px; }
.btn.sm { padding: 6px 12px; font-size: .85rem; box-shadow: 0 4px 0 #000; }
.btn.sm:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.input, textarea.input {
  font: inherit; width: 100%; padding: 12px 14px; background: var(--paper); color: var(--ink);
  border: 4px solid var(--ink); border-radius: 8px; box-shadow: inset 4px 4px 0 rgba(0, 0, 0, .12); outline: none;
}
.input:focus { box-shadow: inset 4px 4px 0 rgba(0, 0, 0, .12), 0 0 0 4px var(--gold); }
.input.code { text-transform: uppercase; letter-spacing: .3em; font-size: 1.6rem; text-align: center; font-weight: 700; }
.input:disabled { opacity: .5; }
label { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; display: flex; flex-direction: column; gap: 6px; }

/* ---- cards ---- */
.hand { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; padding: 12px 0 18px; }
.pcard {
  width: 180px; aspect-ratio: 2 / 3; background: var(--paper); color: var(--ink);
  border: 4px solid var(--ink); border-radius: 8px; box-shadow: 0 8px 0 #000, inset 0 0 0 3px #fff;
  display: flex; flex-direction: column; padding: 8px; position: relative; flex: 0 0 auto;
  animation: wobble 3.2s ease-in-out infinite; transition: transform .15s, box-shadow .15s; cursor: default;
}
.pcard:nth-child(2n) { animation-delay: -1.1s; }
.pcard:nth-child(3n) { animation-delay: -2.3s; }
.pcard:nth-child(5n) { animation-duration: 3.9s; }
@keyframes wobble { 0%, 100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg); } }
.pcard.big { width: 300px; }
.pcard.small { width: 120px; font-size: .8rem; animation: none; }
.pcard.small .pcard-body { font-size: .78rem; }
.pcard.pick { cursor: pointer; }
.pcard.pick:hover, .pcard.selected { animation: none; transform: translateY(-10px) scale(1.06) rotate(0); box-shadow: 0 14px 0 #000, 0 0 0 4px var(--gold), inset 0 0 0 3px #fff; z-index: 2; }
.pcard.selected::after { content: "✓"; position: absolute; top: -12px; right: -12px; width: 34px; height: 34px; border-radius: 50%; background: var(--gold); border: 4px solid var(--ink); display: grid; place-items: center; font-weight: 700; }
.pcard-top { color: #fff; text-transform: uppercase; letter-spacing: .15em; font-size: .7rem; font-weight: 700; padding: 5px 8px; border-radius: 4px; border: 2px solid var(--ink); }
.kind-idea .pcard-top { background: var(--idea); }
.kind-twist .pcard-top { background: var(--twist); }
.pcard-body { flex: 1; display: grid; place-items: center; text-align: center; font-weight: 700; font-size: .98rem; padding: 8px 4px; line-height: 1.2; }
.pcard.big .pcard-body { font-size: 1.5rem; }
.pcard-foot { text-align: center; color: rgba(17, 17, 17, .4); font-size: .9rem; }
.pcard.down { background: repeating-linear-gradient(45deg, var(--red) 0 10px, #a8232c 10px 20px); }
.pcard.down > * { visibility: hidden; }

/* ---- countdown & score ---- */
.count { font-size: clamp(4rem, 14vw, 11rem); font-weight: 700; color: var(--paper); text-shadow: 6px 6px 0 #000; line-height: 1; font-variant-numeric: tabular-nums; text-align: center; }
.count.sm { font-size: clamp(2.5rem, 8vw, 4rem); text-shadow: 4px 4px 0 #000; }
.count.hurry { color: var(--red); animation: pulse .5s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.06); } }
.cash-big { font-size: clamp(3rem, 10vw, 7rem); font-weight: 700; color: var(--gold); text-shadow: 5px 5px 0 #000; line-height: 1; text-align: center; display: inline-block; }
.pop { animation: pop .45s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pop { 0% { transform: scale(1.5); color: #fff; } 100% { transform: scale(1); color: var(--gold); } }

/* ---- money ---- */
.note {
  width: 90px; height: 44px; background: var(--green); color: #fff; border: 3px solid var(--ink); border-radius: 6px;
  font: inherit; font-weight: 700; display: grid; place-items: center; box-shadow: 0 4px 0 #000; letter-spacing: .05em; flex: 0 0 auto;
}
button.note { cursor: pointer; transition: transform .06s; }
button.note:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.wallet { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.pile { position: relative; height: 260px; width: 100%; max-width: 700px; margin: 0 auto; }
.pile .note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) rotate(var(--r)); }
.note.fly { position: fixed; z-index: 30; left: 0; top: 0; animation: fly .7s cubic-bezier(.3, .8, .4, 1) forwards; pointer-events: none; }
@keyframes fly { from { transform: translate(var(--fx), var(--fy)) rotate(0); } to { transform: translate(var(--tx), var(--ty)) rotate(720deg); } }

/* ---- board ---- */
.board { width: 100%; border-collapse: collapse; }
.board td { padding: 10px 8px; border-bottom: 3px solid rgba(0, 0, 0, .15); vertical-align: middle; }
.board tr.mine td { background: rgba(255, 209, 102, .35); }
.board .rank { font-size: 1.6rem; font-weight: 700; width: 2.2em; text-align: center; }
.board .who { font-size: 1.05rem; }
.board .cash { font-size: 1.6rem; font-weight: 700; text-align: right; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { background: var(--gold); color: var(--ink); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 8px; font-size: .72rem; font-weight: 700; }

/* ---- podium ---- */
.podium { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; align-items: end; height: 300px; max-width: 900px; margin: 0 auto; width: 100%; }
.podium .spot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.podium .spot .em { font-size: 3rem; filter: drop-shadow(4px 4px 0 #000); }
.podium .spot .nm { font-weight: 700; text-shadow: 3px 3px 0 #000; text-align: center; }
.podium .spot .block { width: 100%; background: var(--paper); color: var(--ink); border: 4px solid var(--ink); border-radius: 8px 8px 0 0; box-shadow: 0 8px 0 #000; display: grid; place-items: center; font-size: 1.6rem; font-weight: 700; }
.podium .p1 .block { height: 170px; background: var(--gold); }
.podium .p2 .block { height: 120px; }
.podium .p3 .block { height: 80px; }
.podium .p1 { order: 2; } .podium .p2 { order: 1; } .podium .p3 { order: 3; }

/* ---- misc ---- */
.members { display: flex; flex-wrap: wrap; gap: 6px; }
.member { background: rgba(0, 0, 0, .12); border: 2px solid currentColor; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: .82rem; display: inline-flex; gap: 6px; align-items: center; }
.member.off { opacity: .45; }
.member button { border: 0; background: transparent; color: inherit; cursor: pointer; font-weight: 700; padding: 0; font: inherit; }
.qfeed { display: flex; flex-direction: column; gap: 8px; }
.q { background: var(--paper); color: var(--ink); border: 4px solid var(--ink); border-radius: 8px; box-shadow: 0 6px 0 #000; padding: 10px 14px; font-size: 1.1rem; }
.q b { color: var(--blue); }
.q.new { animation: qpop .45s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes qpop { from { transform: scale(1.15); } to { transform: scale(1); } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--red); color: #fff; padding: 12px 20px; border: 4px solid var(--ink); border-radius: 8px; font-weight: 700; box-shadow: 0 6px 0 #000; z-index: 60; animation: pop-in .3s; max-width: 90vw; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 45; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border: 2px solid #000; animation: fall linear infinite; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.shake { animation: shake .5s; }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.kbd { background: rgba(0, 0, 0, .35); border: 2px solid var(--paper); padding: 1px 6px; border-radius: 4px; font-size: .85em; }
