:root {
  color: #27203f;
  background: #f3efff;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --purple: #6f4bc3;
  --purple-dark: #43297f;
  --purple-soft: #a98be7;
  --cyan: #9fe8ef;
  --yellow: #fff185;
  --ink: #27203f;
  --muted: #6f6685;
  --surface: rgba(255, 255, 255, 0.82);
  --shadow: 0 18px 50px rgba(65, 37, 118, 0.15);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% -5%, rgba(170, 224, 243, 0.75), transparent 34%),
    radial-gradient(circle at 100% 10%, rgba(183, 151, 237, 0.58), transparent 36%),
    linear-gradient(160deg, #f9f6ff 0%, #eee7ff 56%, #e9f7f4 100%);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(12px);
  opacity: 0.45;
  animation: drift 9s ease-in-out infinite alternate;
}
.ambient-one { width: 190px; height: 190px; background: #f7e77a; top: 72%; left: -80px; }
.ambient-two { width: 220px; height: 220px; background: #a7e6ee; right: -110px; top: 42%; animation-delay: -3s; }

#app {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
}

.shell { min-height: calc(100dvh - 40px); display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  margin-bottom: 14px;
}

.profile-chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 150px; min-height: 38px; padding: 6px 10px;
  border: 1px solid rgba(99,72,154,.14); border-radius: 999px; color: var(--purple-dark);
  background: rgba(255,255,255,.76); font-size: 12px; font-weight: 900; cursor: pointer;
}
.profile-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-avatar { width: 25px; height: 25px; flex: 0 0 auto; border-radius: 9px; object-fit: cover; background: #eee7ff; }

.main-tabs {
  position: sticky; z-index: 8; top: max(8px, env(safe-area-inset-top)); display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 5px; margin: -5px 0 19px; padding: 5px; border: 1px solid rgba(255,255,255,.8); border-radius: 18px;
  background: rgba(255,255,255,.76); box-shadow: 0 10px 28px rgba(66,40,112,.1); backdrop-filter: blur(16px);
}
.main-tab {
  min-height: 42px; border: 0; border-radius: 13px; color: var(--muted); background: transparent;
  font-size: 12px; font-weight: 900; cursor: pointer;
}
.main-tab span { margin-right: 4px; }
.main-tab.active { color: white; background: linear-gradient(135deg, #7956ce, #58369f); box-shadow: 0 7px 16px rgba(76,46,145,.2); }
.page-badge { display: flex; justify-content: flex-end; margin: -11px 2px 12px; }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 900; color: var(--purple-dark); }
.brand-star {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 12px;
  color: var(--purple-dark); background: var(--yellow); box-shadow: 0 6px 18px rgba(116, 86, 8, .18);
}
.mode-badge, .pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 11px; border-radius: 999px;
  background: rgba(255,255,255,.72); border: 1px solid rgba(99,72,154,.14); color: var(--muted);
  font-size: 12px; font-weight: 800;
}
.mode-badge.official { color: #654500; background: #fff5aa; }
.mode-badge.practice { color: #557078; background: #dff7f7; }

.panel {
  position: relative;
  overflow: hidden;
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, .84);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero { margin: auto 0; text-align: center; }
.hero::before {
  content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; right: -95px; top: -90px;
  background: radial-gradient(circle, rgba(166, 220, 235, .65), transparent 67%);
}
.hero-icon {
  display: grid; place-items: center; width: 86px; height: 86px; margin: 4px auto 18px;
  border-radius: 30px; font-size: 39px; background: linear-gradient(145deg, #7e5bd2, #5935a6);
  color: white; box-shadow: 0 18px 32px rgba(79, 49, 150, .28); transform: rotate(-5deg);
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(29px, 8vw, 40px); line-height: 1.08; letter-spacing: -1.2px; }
h2 { margin-bottom: 8px; font-size: 25px; line-height: 1.2; }
h3 { margin-bottom: 6px; font-size: 18px; }
.subtitle { margin-bottom: 22px; color: var(--muted); font-size: 15px; line-height: 1.7; }
.tiny { color: var(--muted); font-size: 12px; line-height: 1.55; }

.primary, .secondary, .text-button {
  width: 100%; min-height: 50px; border: 0; border-radius: 17px; cursor: pointer; font-weight: 900;
  transition: transform .15s ease, filter .15s ease, opacity .15s ease;
}
.primary { color: white; background: linear-gradient(135deg, #7956ce, #54349c); box-shadow: 0 12px 22px rgba(76, 46, 145, .23); }
.secondary { color: var(--purple-dark); background: #eee7ff; }
.text-button { min-height: 42px; color: var(--purple); background: transparent; }
.primary:active, .secondary:active, .text-button:active { transform: scale(.98); }
button:disabled { cursor: wait; filter: grayscale(.2); opacity: .55; }

.manual { display: grid; gap: 10px; margin-top: 16px; }
.manual input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 15px; border: 1px solid #d8ccef;
  outline: none; color: var(--ink); background: rgba(255,255,255,.75);
}
.manual input:focus { border-color: var(--purple-soft); box-shadow: 0 0 0 4px rgba(111,75,195,.1); }

.status-orb {
  width: 100px; height: 100px; margin: 18vh auto 20px; border-radius: 34px; display: grid; place-items: center;
  color: white; font-size: 42px; background: linear-gradient(145deg, #87dbe7, #6e4bc1); box-shadow: var(--shadow);
  animation: pulse 1.15s ease-in-out infinite alternate;
}
.center { text-align: center; }

.choice-heading { margin: 12px 4px 18px; }
.trixie-challenge-title {
  max-width: 460px; font-size: clamp(25px, 7vw, 34px); line-height: 1.16; overflow-wrap: anywhere;
}
.trixie-challenge-title span { color: var(--purple); }
.trixie-challenge-title span + span { color: var(--ink); }

.challenge-scene { display: flex; flex: 1; flex-direction: column; justify-content: flex-end; min-height: calc(100dvh - 160px); }
.trixie-portrait-wrap {
  display: grid; place-items: end center; min-height: 230px; max-height: 42vh; margin: -10px -8px -28px; overflow: hidden;
}
.trixie-portrait-wrap img { width: min(100%, 390px); max-height: 43vh; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 20px 24px rgba(54,40,93,.15)); }
.speech-bubble {
  position: relative; z-index: 2; padding: 19px 18px 16px; border: 2px solid #7451bd; border-radius: 23px 23px 23px 7px;
  color: var(--purple-dark); background: rgba(255,255,255,.94); box-shadow: var(--shadow);
}
.speech-bubble::before {
  content: ""; position: absolute; left: 20px; top: -13px; width: 22px; height: 22px; background: white;
  border-left: 2px solid #7451bd; border-top: 2px solid #7451bd; transform: rotate(45deg);
}
.speech-bubble .speaker {
  position: relative; color: var(--purple); font-size: clamp(15px, 4.2vw, 18px); line-height: 1.25;
  overflow-wrap: anywhere; font-weight: 1000; letter-spacing: .25px; text-transform: uppercase;
}
.speech-bubble h2 { position: relative; margin: 4px 0 0; font-size: 23px; }
.challenge-actions { display: grid; gap: 10px; margin-top: 13px; }
.choice-dialog {
  width: 100%; padding: 15px 16px; text-align: left; border: 0; border-radius: 18px; cursor: pointer;
  box-shadow: 0 10px 24px rgba(65,40,110,.12); transition: transform .15s ease;
}
.choice-dialog:active { transform: scale(.985); }
.choice-dialog strong, .choice-dialog span { display: block; }
.choice-dialog strong { margin-bottom: 3px; font-size: 15px; }
.choice-dialog span { font-size: 11px; opacity: .72; }
.choice-dialog.direct { color: #4d4160; background: rgba(255,255,255,.88); border: 1px solid rgba(92,70,136,.14); }
.choice-dialog.challenge { color: white; background: linear-gradient(135deg, #7956ce, #4c2d92); }
.game-list { display: grid; gap: 14px; }
.game-option {
  position: relative; overflow: hidden; width: 100%; padding: 20px; text-align: left; border: 1px solid rgba(94,70,145,.12);
  border-radius: 24px; color: var(--ink); background: rgba(255,255,255,.78); box-shadow: 0 12px 30px rgba(64,40,111,.1);
  cursor: pointer;
}
.game-option::after { content: "✦"; position: absolute; right: 18px; top: 14px; color: #c1acee; font-size: 38px; }
.game-option:nth-child(2)::after { content: "≈"; color: #6fc9d6; }
.game-option:nth-child(3)::after { content: "24"; color: #8c6bd2; font-size: 25px; font-weight: 1000; }
.game-option:active { transform: scale(.985); }
.game-kicker { margin-bottom: 8px; color: var(--purple); font-size: 12px; font-weight: 900; letter-spacing: .8px; }
.game-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.game-meta span { padding: 6px 9px; border-radius: 999px; color: var(--muted); background: #f3effb; font-size: 11px; font-weight: 800; }
.guarantee { margin: 16px 2px 0; padding: 12px 14px; border-radius: 15px; color: #67571d; background: rgba(255,242,149,.55); font-size: 12px; line-height: 1.5; }

.draw-stage { display: grid; place-items: center; flex: 1; text-align: center; }
.draw-visual {
  position: relative; width: min(82vw, 330px); aspect-ratio: 1; overflow: hidden; border-radius: 36px;
  background: #dfe9df; box-shadow: var(--shadow);
}
.draw-visual img { width: 100%; height: 100%; object-fit: cover; }
.draw-spark { position: absolute; inset: auto 0 13px; color: white; font-weight: 900; text-shadow: 0 2px 12px #3b276d; }

.board-head { margin-bottom: 12px; text-align: center; }
.board-head h2 { font-size: 21px; }
.target-card {
  width: 46px; aspect-ratio: .65; margin: 10px auto 6px; border-radius: 9px; overflow: hidden;
  box-shadow: 0 8px 18px rgba(55,34,97,.22); transform: rotate(4deg);
}
.card-art { position: relative; overflow: hidden; background: #c2b1e7; }
.card-art::before {
  content: ""; position: absolute; inset: 0; background-image: url('/assets/card.webp?v=1');
  background-size: 342% 149%; background-position: center center; background-repeat: no-repeat;
}

.attempts { display: flex; justify-content: center; gap: 6px; margin: 8px 0 13px; }
.attempt-dot { width: 9px; height: 9px; border-radius: 50%; background: #d6cbea; }
.attempt-dot.used { background: var(--purple); }

.card-grid { display: grid; gap: 7px; perspective: 900px; }
.card-grid.game1, .card-grid.luck { grid-template-columns: repeat(5, 1fr); }
.playing-card {
  position: relative; width: 100%; aspect-ratio: .65; padding: 0; border: 0; border-radius: 11px; overflow: visible;
  background: transparent; cursor: pointer; animation: deal-in .55s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: calc(var(--i) * 28ms); transform-style: preserve-3d;
}
.playing-card .card-art { position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 7px 15px rgba(58,37,100,.18); }
.playing-card:active:not(:disabled) { transform: translateY(-5px) rotate(-1deg); }
.playing-card.is-picking .card-art, .playing-card.is-revealed .card-art { animation: picked-away .48s ease-in forwards; }
.revealed-number {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 12px; color: var(--purple-dark);
  background: radial-gradient(circle, #fff 0%, #f7f0ff 70%); border: 2px solid #cbb9ed;
  font-size: clamp(19px, 6vw, 31px); font-weight: 1000; opacity: 0; animation: number-in .46s .28s ease-out forwards;
}
.revealed-number.hit { color: #765a00; background: radial-gradient(circle, #fffce0, #ffed82); border-color: #f0d348; }
.choice-number {
  position: absolute; z-index: 2; left: 50%; bottom: 5px; transform: translateX(-50%); min-width: 28px; padding: 3px 6px;
  border-radius: 999px; color: var(--purple-dark); background: rgba(255,255,255,.9); font-weight: 1000; font-size: 13px;
  box-shadow: 0 3px 8px rgba(53,35,91,.16);
}
.board-note { margin: 15px 2px 0; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.5; }

.result-panel { margin: auto 0; text-align: center; }
.result-symbol {
  display: grid; place-items: center; width: 78px; height: 78px; margin: 0 auto 16px; border-radius: 28px;
  font-size: 36px; background: #fff2a5; box-shadow: 0 14px 28px rgba(111,87,24,.15);
}
.result-symbol.loss { background: #e5f4f6; }
.target-reveal { margin: 14px 0; color: var(--muted); }
.target-reveal strong { color: var(--purple-dark); font-size: 27px; }
.credit-box { margin: 16px 0; padding: 15px; border-radius: 19px; background: linear-gradient(135deg, #f9e985, #fff7c5); }
.credit-box strong { display: block; color: #67500b; font-size: 31px; }
.api-key { margin: 14px 0; padding: 13px; border-radius: 15px; background: #29223b; color: #e9dcff; font: 12px/1.55 ui-monospace, Consolas, monospace; word-break: break-all; user-select: all; }
.action-stack { display: grid; gap: 10px; margin-top: 17px; }
.pending { margin: 14px 0; padding: 12px; border-radius: 14px; background: #f2edf9; color: var(--muted); font-size: 12px; }

.tab-heading { margin: 7px 4px 16px; }
.section-kicker { display: block; margin-bottom: 6px; color: var(--purple); font-size: 10px; font-weight: 1000; letter-spacing: 1.5px; }
.pool-panel { display: grid; gap: 18px; }
.pool-row-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.pool-row-head strong { font-size: 17px; }
.pool-row-head span { color: var(--purple); font-size: 23px; font-weight: 1000; }
.pool-track { height: 13px; overflow: hidden; border-radius: 999px; background: #e6def4; }
.pool-track span { display: block; height: 100%; min-width: 0; border-radius: inherit; background: linear-gradient(90deg, #7651c8, #94dfe9); transition: width .5s ease; }
.pool-row:nth-child(2) .pool-track span { background: linear-gradient(90deg, #6eabd4, #9ce8d7); }
.pool-row:nth-child(3) .pool-track span { background: linear-gradient(90deg, #e7c957, #fff09a); }
.pool-row p { margin: 7px 0 0; color: var(--muted); font-size: 11px; }

.leaderboard-panel { display: grid; gap: 9px; margin-bottom: 14px; }
.rank-row { display: grid; grid-template-columns: 34px 40px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 52px; padding: 7px 5px; border-bottom: 1px solid #eee8f7; border-radius: 13px; }
.rank-row:last-child { border-bottom: 0; }
.rank-number { color: var(--muted); text-align: center; font-size: 12px; font-weight: 900; }
.rank-avatar { display: grid; place-items: center; width: 38px; height: 38px; overflow: hidden; border-radius: 13px; background: #f0e9ff; }
.rank-avatar-image { width: 100%; height: 100%; object-fit: cover; }
.rank-player { display: grid; min-width: 0; gap: 2px; }
.rank-player strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.rank-player small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 10px; }
.rank-role-image { width: 16px; height: 16px; border-radius: 5px; object-fit: cover; }
.rank-score { color: var(--purple); font-weight: 1000; }
.rank-row.rank-1 { border: 1px solid rgba(210,161,23,.3); background: linear-gradient(90deg, rgba(255,235,146,.52), rgba(255,255,255,.4)); box-shadow: 0 8px 20px rgba(176,128,11,.1); }
.rank-row.rank-2 { border: 1px solid rgba(147,151,168,.25); background: linear-gradient(90deg, rgba(225,230,240,.58), rgba(255,255,255,.4)); }
.rank-row.rank-3 { border: 1px solid rgba(179,112,68,.22); background: linear-gradient(90deg, rgba(243,205,173,.5), rgba(255,255,255,.4)); }
.rank-row.rank-1 .rank-score { color: #8c6500; }
.rank-row.rank-2 .rank-score { color: #5e6677; }
.rank-row.rank-3 .rank-score { color: #92552f; }

.modal-backdrop {
  position: fixed; z-index: 40; inset: 0; display: grid; align-items: end; padding: 18px; overflow-y: auto;
  background: rgba(39,27,63,.48); backdrop-filter: blur(7px); animation: fade-in .18s ease-out;
}
.profile-modal {
  position: relative; width: min(100%, 480px); margin: 0 auto; padding: 26px 20px max(20px, env(safe-area-inset-bottom));
  border-radius: 28px; color: var(--ink); background: #fcfaff; box-shadow: 0 25px 80px rgba(35,21,66,.34);
}
.modal-close { position: absolute; right: 14px; top: 12px; width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--muted); background: #f0ebf8; font-size: 25px; cursor: pointer; }
.profile-heading-icon { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 12px; overflow: hidden; border-radius: 20px; background: #eee7ff; }
.profile-heading-image { width: 100%; height: 100%; object-fit: cover; }
.field-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 900; }
.profile-input { width: 100%; height: 49px; padding: 0 14px; border: 1px solid #d9ceeb; border-radius: 15px; outline: none; background: white; }
.profile-input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(111,75,195,.1); }
.avatar-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin: 17px 0 20px; padding: 0; border: 0; }
.avatar-picker legend { grid-column: 1 / -1; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 900; }
.avatar-choice input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-choice span { display: grid; place-items: center; aspect-ratio: 1; overflow: hidden; border: 2px solid transparent; border-radius: 14px; background: #f1ecfa; cursor: pointer; }
.avatar-option-image { width: 100%; height: 100%; object-fit: cover; }
.avatar-choice input:checked + span { border-color: var(--purple); background: #e4d9fb; transform: translateY(-2px); }

.profile-nudge {
  display: flex; align-items: center; gap: 10px; width: 100%; margin: -5px 0 14px; padding: 11px 13px;
  border: 1px dashed #9c82d0; border-radius: 16px; color: var(--purple-dark); background: rgba(255,255,255,.55); cursor: pointer;
}
.profile-nudge span { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; color: white; background: var(--purple); }
.profile-nudge strong { text-align: left; font-size: 11px; line-height: 1.45; }

.character-grid { display: grid; gap: 11px; }
.character-card {
  display: grid; grid-template-columns: 86px minmax(0,1fr); align-items: center; gap: 14px; width: 100%; min-height: 108px;
  padding: 10px; text-align: left; border: 1px solid rgba(91,66,142,.14); border-radius: 23px; color: var(--ink);
  background: rgba(255,255,255,.78); box-shadow: 0 10px 25px rgba(64,40,111,.08); cursor: pointer;
}
.character-card:active { transform: scale(.985); }
.character-shot { width: 86px; height: 86px; overflow: hidden; border-radius: 20px; background: linear-gradient(145deg,#eee7ff,#dff5f5); }
.character-image { width: 100%; height: 100%; object-fit: cover; }
img[data-avatar-id="twilight"] { transform: rotate(180deg); }
.character-copy { display: grid; gap: 3px; }
.character-copy strong { font-size: 17px; }
.character-copy b { color: var(--purple); font-size: 13px; }
.character-copy small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.character-dialog-backdrop { align-items: center; }
.character-dialog {
  width: min(100%, 430px); max-height: calc(100dvh - 36px); margin: auto; padding: 25px 20px max(20px, env(safe-area-inset-bottom));
  overflow-y: auto; text-align: center; border: 1px solid rgba(111,75,195,.16); border-radius: 29px;
  color: var(--ink); background: #fcfaff; box-shadow: 0 25px 80px rgba(35,21,66,.34);
}
.character-dialog-shot {
  width: clamp(110px, 35vw, 160px); aspect-ratio: 1; margin: 0 auto 16px; overflow: hidden;
  border: 4px solid white; border-radius: 34px; background: linear-gradient(145deg,#eee7ff,#dff5f5);
  box-shadow: 0 14px 32px rgba(73,46,129,.2);
}
.character-dialog-image { width: 100%; height: 100%; object-fit: cover; }
.character-dialog h2 { margin: 4px 0 13px; font-size: clamp(24px, 7vw, 31px); }
.character-quote {
  position: relative; margin-bottom: 18px; padding: 16px 17px; text-align: left; border: 2px solid #c9b5ec;
  border-radius: 20px 20px 20px 6px; color: var(--purple-dark); background: white; font-size: 15px;
  font-weight: 800; line-height: 1.65; overflow-wrap: anywhere;
}
.character-quote::before {
  content: ""; position: absolute; left: 18px; top: -9px; width: 14px; height: 14px; border-left: 2px solid #c9b5ec;
  border-top: 2px solid #c9b5ec; background: white; transform: rotate(45deg);
}

.timer-line { display: flex; align-items: baseline; justify-content: space-between; margin: 5px 2px 8px; }
.timer-line strong { font-size: 14px; }
.timer-line span { color: var(--purple); font-size: 21px; font-weight: 1000; font-variant-numeric: tabular-nums; }
.timer-track { height: 12px; overflow: hidden; border-radius: 999px; background: #dfd6ef; box-shadow: inset 0 1px 2px rgba(44,26,80,.1); }
.timer-track span { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#77d7df,#7250c5); transition: width .1s linear; }
.timer-track.danger span { background: linear-gradient(90deg,#f3d763,#7952ca); }

.speed-stage { display: flex; flex: 1; flex-direction: column; min-height: calc(100dvh - 175px); }
.tap-count { display: flex; align-items: baseline; justify-content: center; gap: 7px; margin: clamp(17px,4vh,38px) 0 12px; color: var(--muted); }
.tap-count strong { color: var(--purple-dark); font-size: clamp(54px,18vw,84px); line-height: 1; font-variant-numeric: tabular-nums; }
.tap-count small { font-weight: 900; }
.cozy-tapper {
  position: relative; display: grid; place-items: center; width: min(66vw,300px); aspect-ratio: 1; margin: 0 auto;
  padding: 0; overflow: hidden; border: 5px solid rgba(255,255,255,.85); border-radius: 50%; background: #dceee4;
  box-shadow: 0 22px 52px rgba(74,48,132,.22); cursor: pointer; touch-action: none; user-select: none;
}
.cozy-tapper img {
  width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; -webkit-touch-callout: none;
}
.cozy-tapper span { position: absolute; inset: auto 0 18px; color: white; font-size: 18px; font-weight: 1000; text-shadow: 0 2px 10px rgba(42,28,63,.8); pointer-events: none; }
.cozy-tapper.tap-pop { animation: tap-pop .13s ease-out; }
.speed-finish { width: min(100%, 300px); min-height: 46px; margin: 13px auto 0; }

.intelligence-stage { padding-bottom: 12px; }
.intelligence-meta { display: flex; align-items: center; justify-content: space-between; margin: 12px 1px; color: var(--muted); font-size: 12px; font-weight: 800; }
.intelligence-meta > span:last-child strong { color: var(--purple); font-size: 18px; }
.role-mini { display: inline-flex; align-items: center; gap: 7px; }
.role-mini-image { width: 29px; height: 29px; border-radius: 10px; object-fit: cover; background: #eee7ff; }
.number-cards { display: grid; grid-template-columns: repeat(4,1fr); gap: 9px; margin: 13px 0; }
.number-card {
  aspect-ratio: .72; border: 2px solid #c6b5e8; border-radius: 16px; color: var(--purple-dark); background: linear-gradient(155deg,#fff,#eee7ff);
  box-shadow: 0 9px 18px rgba(60,38,101,.13); font-size: clamp(27px,9vw,40px); font-weight: 1000; cursor: pointer;
}
.number-card.used { transform: translateY(4px) scale(.94); filter: grayscale(.5); opacity: .42; }
.ability-button {
  display: grid; gap: 3px; width: 100%; margin: 11px 0; padding: 11px 13px; text-align: left; border: 1px solid rgba(111,75,195,.22);
  border-radius: 15px; color: var(--purple-dark); background: #f1eafd; cursor: pointer;
}
.ability-button span { font-size: 12px; font-weight: 1000; }
.ability-button small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.ability-effect { display: grid; gap: 3px; margin: 9px 0; padding: 10px 12px; border-radius: 14px; color: #5d4810; background: #fff4b5; }
.ability-effect b { font-size: 11px; }
.ability-effect span { font-size: 12px; line-height: 1.4; }
.ability-form { margin: 10px 0; padding: 14px; border: 1px solid #d7c8ee; border-radius: 18px; background: rgba(255,255,255,.88); }
.ability-form > strong { display: block; margin-bottom: 10px; }
.replace-card-picker { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; margin-bottom: 12px; }
.replace-card-picker input { position: absolute; opacity: 0; }
.replace-card-picker span { display: grid; place-items: center; aspect-ratio: 1; border: 2px solid transparent; border-radius: 12px; background: #eee8f7; font-size: 20px; font-weight: 1000; cursor: pointer; }
.replace-card-picker input:checked + span { border-color: var(--purple); background: #dfd2f8; }
.inline-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 10px; }
.inline-actions button { min-height: 44px; }
.expression-screen {
  display: grid; grid-template-columns: minmax(0,1fr) 40px; align-items: center; min-height: 58px; margin: 12px 0 7px; padding: 8px 8px 8px 14px;
  border: 2px solid #d7caeb; border-radius: 16px; background: white; box-shadow: inset 0 2px 5px rgba(47,28,83,.05);
}
.expression-screen.has-error { border-color: #d99cb1; }
.expression-screen span { overflow-x: auto; white-space: nowrap; color: var(--purple-dark); font: 700 18px/1.4 ui-monospace,Consolas,monospace; }
.expression-screen button { width: 38px; height: 38px; border: 0; border-radius: 11px; color: var(--muted); background: #f0ebf7; cursor: pointer; }
.answer-error { margin: 0 2px 8px; color: #a33c61; font-size: 11px; }
.operator-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; }
.operator-grid button { min-height: 44px; border: 0; border-radius: 13px; color: var(--purple-dark); background: #eae2f9; font-size: 19px; font-weight: 1000; cursor: pointer; }
.operator-grid .clear-expression { grid-column: span 2; color: var(--muted); background: #eeeaf2; font-size: 13px; }
.operator-grid .submit-expression { grid-column: span 2; color: white; background: linear-gradient(135deg,#7956ce,#54349c); font-size: 13px; }

.score-hero { display: grid; justify-items: center; margin: 14px 0; padding: 13px; border-radius: 19px; background: #f1ebfb; }
.score-hero span { color: var(--muted); font-size: 11px; font-weight: 900; }
.score-hero strong { color: var(--purple-dark); font-size: 42px; line-height: 1.2; }
.score-hero small { color: var(--purple); font-weight: 900; }
.result-role { display: inline-flex; align-items: center; gap: 7px; margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 900; }
.result-role-image { width: 30px; height: 30px; border-radius: 10px; object-fit: cover; }

.board-tabs { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-bottom: 10px; }
.board-tabs button { min-height: 43px; padding: 5px; border: 1px solid rgba(91,66,142,.14); border-radius: 13px; color: var(--muted); background: rgba(255,255,255,.55); font-size: 11px; font-weight: 900; cursor: pointer; }
.board-tabs button.active { color: white; border-color: transparent; background: linear-gradient(135deg,#7651c8,#563497); }

@keyframes tap-pop { 50% { transform: scale(.965); filter: brightness(1.08); } }

.error-card { margin: auto 0; text-align: center; }
.error-icon { font-size: 45px; margin-bottom: 12px; }

.effect-overlay {
  position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px;
  background: rgba(37,25,62,.44); backdrop-filter: blur(5px); animation: fade-in .18s ease-out;
}
.effect-overlay img { width: min(86vw, 390px); max-height: 72vh; object-fit: contain; border-radius: 30px; box-shadow: 0 22px 70px rgba(30,15,61,.32); }
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  padding: 11px 16px; border-radius: 999px; color: white; background: #302541; font-size: 13px; font-weight: 800;
  animation: toast-in .25s ease-out;
}

@keyframes drift { to { transform: translate3d(25px,-30px,0) scale(1.1); } }
@keyframes pulse { to { transform: translateY(-8px) rotate(4deg); box-shadow: 0 28px 60px rgba(77,49,143,.3); } }
@keyframes deal-in {
  from { opacity: 0; transform: translate3d(0,-110px,0) scale(.45) rotate(calc((var(--i) - 8) * 3deg)); }
  to { opacity: 1; transform: translate3d(0,0,0) scale(1) rotate(0); }
}
@keyframes picked-away {
  0% { opacity: 1; transform: rotateY(0) scale(1); }
  55% { opacity: .8; transform: rotateY(120deg) scale(.72); }
  100% { opacity: 0; transform: rotateY(220deg) scale(.08); }
}
@keyframes number-in { from { opacity: 0; transform: scale(.3) rotate(-12deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 15px); } }

@media (min-width: 540px) {
  #app { padding-left: 24px; padding-right: 24px; }
  .card-grid { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; scroll-behavior: auto !important; }
}
