:root {
  --bg: #1d1640;
  --bg2: #2a2060;
  --ink: #ffffff;
  --muted: #c9c2f0;
  --card: #ffffff;
  --card-ink: #1d1640;
  --red: #e63946;
  --yellow: #ffc93c;
  --blue: #2f80ed;
  --green: #22b573;
  --deck: var(--red);
  --deck-ink: #fff;
  --radius: 22px;
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg) 70%) fixed, var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

.view {
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- HOME ---------- */
.home-head { text-align: center; padding-top: 8px; }
.logo {
  margin: 0;
  font-size: clamp(48px, 15vw, 76px);
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
  background: linear-gradient(90deg, var(--red), var(--yellow) 35%, var(--green) 65%, var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo-dot { color: var(--yellow); -webkit-text-fill-color: var(--yellow); }
.tag { margin: 6px 0 0; color: var(--muted); font-size: 18px; }

.tiles {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-height: 340px;
}
.tile {
  position: relative;
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 6px 0 rgba(0,0,0,.25), inset 0 -6px 0 rgba(0,0,0,.12);
  transition: transform .08s ease;
  overflow: hidden;
}
.tile:active { transform: translateY(3px) scale(.98); }
.tile .t-emoji { font-size: 44px; line-height: 1; }
.tile .t-name { font-size: 24px; font-weight: 900; line-height: 1.05; }
.tile .t-what { font-size: 14px; opacity: .9; margin-top: 4px; }
.tile .t-left { position: absolute; top: 14px; right: 14px; font-size: 12px; font-weight: 700; opacity: .85; }
.tile.red { background: var(--red); color: #fff; }
.tile.yellow { background: var(--yellow); color: #3b2a00; }
.tile.blue { background: var(--blue); color: #fff; }
.tile.green { background: var(--green); color: #fff; }

.surprise {
  border-radius: 999px;
  padding: 16px;
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(90deg, #7b5cff, #b44cff);
  box-shadow: 0 5px 0 rgba(0,0,0,.25);
}
.surprise:active { transform: translateY(2px); }
.home-foot { display: flex; justify-content: center; gap: 28px; }
.link { color: var(--muted); text-decoration: underline; padding: 8px; font-size: 16px; }

/* ---------- CARD ---------- */
#card { gap: 14px; }
.card-top { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,.12); font-size: 34px; line-height: 1; padding-bottom: 4px;
}
.deck-name { flex: 1; font-size: 22px; font-weight: 900; color: var(--deck); filter: brightness(1.15); }
.deck-count { color: var(--muted); font-size: 14px; }

.card {
  background: var(--card);
  color: var(--card-ink);
  border-radius: var(--radius);
  border-top: 14px solid var(--deck);
  padding: 18px 18px 20px;
  box-shadow: 0 8px 0 rgba(0,0,0,.25);
  display: flex; flex-direction: column; gap: 12px;
  animation: deal .25s ease-out;
}
@keyframes deal { from { transform: translateY(16px) rotate(-1deg); opacity: 0; } to { transform: none; opacity: 1; } }

.allplay {
  background: repeating-linear-gradient(45deg, #fff3c4, #fff3c4 10px, #ffe58a 10px, #ffe58a 20px);
  color: #5a3d00; border-radius: 14px; padding: 8px 12px; text-align: center;
  display: flex; flex-direction: column; gap: 2px; font-size: 14px;
}
.allplay strong { font-size: 18px; letter-spacing: 1px; }
.kind {
  align-self: flex-start;
  background: var(--deck); color: var(--deck-ink);
  border-radius: 999px; padding: 5px 14px; font-weight: 800; font-size: 15px;
}
.prompt { margin: 0; font-size: clamp(21px, 5.6vw, 27px); line-height: 1.3; font-weight: 700; white-space: pre-line; }
.choices { display: grid; gap: 10px; counter-reset: c; }
.choice {
  counter-increment: c;
  background: #f1eefc; color: var(--card-ink); border-radius: 14px; padding: 14px 12px 14px 50px;
  font-size: 20px; font-weight: 700; position: relative; text-align: left; min-height: 56px;
  border: 3px solid transparent; transition: background .15s, border-color .15s, opacity .15s;
}
.choice:active { transform: scale(.98); }
.choices.locked .choice { cursor: default; }
.choices.locked .choice:not(.right):not(.wrong) { opacity: .45; }
.choice.right { background: #d6f5e5; border-color: var(--green); }
.choice.right::after { content: "✓"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--green); font-size: 26px; font-weight: 900; }
.choice.wrong { background: #fde2e4; border-color: var(--red); animation: shake .35s; }
.choice.wrong::after { content: "✗"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--red); font-size: 26px; font-weight: 900; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.tap-hint { margin: -2px 0 0; text-align: center; font-size: 15px; color: #6b6590; }
.choice::before {
  content: counter(c, upper-alpha);
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--deck); color: var(--deck-ink);
  display: grid; place-items: center; font-size: 14px;
}

.secret { display: flex; flex-direction: column; gap: 10px; }
.peek {
  border-radius: 16px; padding: 16px; font-size: 18px; font-weight: 800;
  background: var(--card-ink); color: #fff;
}
.secret-text {
  border: 3px dashed var(--deck); border-radius: 16px; padding: 16px;
  font-size: clamp(26px, 8vw, 36px); font-weight: 900; text-align: center; line-height: 1.15;
  white-space: pre-line;
}

/* ---------- TIMER ---------- */
.timer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto auto;
  align-items: center; justify-items: center; gap: 4px 12px;
}
.t-adj {
  width: 64px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.12);
  font-weight: 800; font-size: 18px;
}
.t-face { position: relative; width: 150px; height: 150px; border-radius: 50%; }
.t-face svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.t-track { fill: rgba(255,255,255,.08); stroke: rgba(255,255,255,.15); stroke-width: 10; }
.t-ring {
  fill: none; stroke: var(--deck); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 326.73; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear, stroke .2s;
}
.t-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 52px; font-weight: 900; padding-bottom: 12px; }
.t-hint { position: absolute; left: 0; right: 0; bottom: 30px; font-size: 13px; color: var(--muted); }
.timer.running .t-hint { visibility: hidden; }
.timer.low .t-ring { stroke: #ff4d4d; }
.timer.low .t-num { color: #ff8080; animation: pulse 1s infinite; }
.timer.done .t-num { color: #ff8080; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.t-reset { grid-column: 2; color: var(--muted); text-decoration: underline; padding: 4px 10px; }

/* ---------- ANSWER & ACTIONS ---------- */
.answer {
  background: #fffbe6; color: #3b2a00; border-radius: var(--radius); padding: 14px 18px;
  border-left: 10px solid var(--green); animation: deal .2s ease-out;
}
.verdict { font-size: clamp(26px, 7vw, 34px); font-weight: 900; margin-bottom: 6px; white-space: pre-line; line-height: 1.2; }

/* big pop-up stamp in the middle of the screen after tapping an answer */
.stamp {
  position: fixed; left: 50%; top: 40%; z-index: 25;
  transform: translate(-50%, -50%) rotate(-6deg);
  width: max-content; max-width: 90vw; padding: 18px 28px; border-radius: 24px;
  font-size: clamp(34px, 9vw, 64px); font-weight: 900; text-align: center; line-height: 1.15;
  white-space: pre-line; border: 6px solid currentColor; background: #fff;
  box-shadow: 0 12px 0 rgba(0,0,0,.25);
  animation: stampIn 1.4s ease-out forwards;
}
.stamp.yes { color: #138a55; }
.stamp.no { color: #c62834; transform: translate(-50%, -50%) rotate(5deg); }
@keyframes stampIn {
  0% { opacity: 0; scale: 2.2; }
  14% { opacity: 1; scale: .92; }
  22% { scale: 1.04; }
  30% { scale: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; scale: 1; }
}

/* confetti burst from the tapped answer */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i {
  position: absolute; width: 10px; height: 14px; border-radius: 2px; margin: -7px 0 0 -5px;
  animation: burst 1.5s cubic-bezier(.15,.7,.4,1) forwards;
}
.confetti i.emoji { width: auto; height: auto; font-style: normal; font-size: 22px; background: none; }
@keyframes burst {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 260px)) rotate(var(--rot)); opacity: 0; }
}
.card.wobble { animation: wobble .5s ease-in-out; }
@keyframes wobble {
  15% { transform: rotate(-3deg) translateX(-8px); } 35% { transform: rotate(2.5deg) translateX(8px); }
  55% { transform: rotate(-1.5deg) translateX(-4px); } 75% { transform: rotate(1deg); } 100% { transform: none; }
}
.verdict.yes { color: #138a55; animation: pop .4s ease-out; }
.verdict.no { color: #c62834; }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.12); } 100% { transform: none; } }
.answer.yes { border-left-color: var(--green); }
.answer.no { border-left-color: var(--red); }
.answer-label { font-size: 13px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; opacity: .7; }
.answer-text { font-size: clamp(22px, 6vw, 28px); font-weight: 900; line-height: 1.2; white-space: pre-line; }
.fact { margin-top: 8px; font-size: 17px; line-height: 1.35; }
.fact::before { content: "💡 "; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; }
.actions > [hidden] + .btn { grid-column: 1 / -1; }
.btn { border-radius: 16px; padding: 16px 10px; font-size: 19px; font-weight: 800; }
.btn.ghost { background: rgba(255,255,255,.12); }
.btn.solid { background: var(--deck); color: var(--deck-ink); box-shadow: 0 5px 0 rgba(0,0,0,.25); }
.btn:active { transform: translateY(2px); }

/* ---------- SHEET ---------- */
.sheet-wrap {
  position: fixed; inset: 0; background: rgba(10,6,30,.7);
  display: flex; align-items: flex-end; justify-content: center; z-index: 10;
}
.sheet {
  --deck: #7b5cff; --deck-ink: #fff;
  background: #fff; color: var(--card-ink);
  width: 100%; max-width: 640px; max-height: 88dvh; overflow: auto;
  border-radius: 24px 24px 0 0; padding: 22px 20px max(20px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
  -webkit-user-select: text; user-select: text;
}
.sheet h2 { margin: 0; font-size: 26px; }
.sheet p, .sheet li { font-size: 17px; line-height: 1.45; }
.sheet ul { padding-left: 20px; margin: 0; }
.sheet .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #eee; }
.sheet .row label { font-size: 17px; font-weight: 700; }
.sheet select, .sheet .mini {
  font: inherit; font-size: 16px; padding: 8px 12px; border-radius: 10px; border: 2px solid #ddd; background: #fff; color: var(--card-ink);
}
.sheet .mini { font-weight: 700; }
.sheet input[type=checkbox] { width: 26px; height: 26px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ---------- TIME'S UP FLASH ---------- */
.flash {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  font-size: clamp(48px, 16vw, 96px); font-weight: 900; color: #fff;
  background: rgba(230,57,70,.92);
  animation: flash .5s ease-in-out 3 alternate;
}
@keyframes flash { from { background: rgba(230,57,70,.95); } to { background: rgba(255,201,60,.95); color: #3b2a00; } }

@media (min-width: 700px) {
  .view { max-width: 820px; padding-left: 28px; padding-right: 28px; }
  .tiles { min-height: 520px; gap: 20px; }
  .tile { padding: 24px; }
  .tile .t-emoji { font-size: 64px; }
  .tile .t-name { font-size: 38px; }
  .tile .t-what { font-size: 18px; }
  .tile .t-left { font-size: 15px; }
  .deck-name { font-size: 28px; }
  .card { padding: 26px 28px 28px; gap: 16px; }
  .kind { font-size: 18px; }
  .prompt { font-size: 34px; }
  .choice { font-size: 27px; padding: 18px 16px 18px 64px; min-height: 72px; }
  .choice::before { width: 34px; height: 34px; font-size: 18px; left: 14px; }
  .tap-hint { font-size: 18px; }
  .secret-text { font-size: 44px; }
  .t-face { width: 180px; height: 180px; }
  .t-num { font-size: 62px; }
  .answer-text { font-size: 34px; }
  .fact { font-size: 21px; }
  .verdict { font-size: 40px; }
  .btn { font-size: 23px; padding: 20px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
