* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif; color: #182230; background: #eef3f8; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
.hidden { display: none !important; }

.front-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 215, 64, 0.25), transparent 24%),
    radial-gradient(circle at top right, rgba(255, 92, 92, 0.20), transparent 20%),
    linear-gradient(180deg, #f5f8fc 0%, #eaf1f7 100%);
}

.admin-body, .admin-login-body {
  min-height: 100vh;
  background: linear-gradient(180deg, #f7fafc 0%, #edf3f8 100%);
}

.app-shell, .admin-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero-card, .admin-topbar, .panel, .login-card, .stat-card, .clown-dialog {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(13, 29, 56, 0.08);
  box-shadow: 0 18px 48px rgba(18, 44, 76, 0.10);
  border-radius: 24px;
}

.hero-card, .admin-topbar {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
}

.hero-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-badges span,
.result-chip,
.clown-tag,
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff0c3, #ffd85d);
  color: #7d4d00;
  font-size: 13px;
  font-weight: 700;
}

.ghost-link {
  background: #eff4ff;
  color: #3155cc;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.1; }
h2 { font-size: 24px; margin-bottom: 16px; }
h3 { font-size: 22px; }
.eyebrow {
  color: #55718d;
  font-size: 13px;
  letter-spacing: 0.08em;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.subtext {
  color: #637b94;
  line-height: 1.7;
  max-width: 760px;
}

.front-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 22px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-top: 22px;
}

.panel {
  padding: 24px;
}

.stack { display: flex; flex-direction: column; }
.gap-16 { gap: 16px; }
.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field span {
  color: #334e68;
  font-size: 14px;
  font-weight: 700;
}
.field input, .field select {
  width: 100%;
  border: 1px solid #d7e0ea;
  border-radius: 16px;
  background: #fff;
  padding: 14px 16px;
  outline: none;
}
.field input:focus, .field select:focus {
  border-color: #7d6bff;
  box-shadow: 0 0 0 4px rgba(125, 107, 255, 0.12);
}

.primary-btn, .secondary-btn, .link-btn, .close-btn {
  border: none;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}
.primary-btn:hover, .secondary-btn:hover, .close-btn:hover, .link-btn:hover { transform: translateY(-1px); }
.primary-btn {
  padding: 14px 18px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, #6b4dff, #4e8cff);
  box-shadow: 0 16px 28px rgba(78, 140, 255, 0.22);
  font-weight: 800;
}
.secondary-btn, .link-btn {
  padding: 12px 14px;
  border-radius: 14px;
  background: #eff4ff;
  color: #2740ac;
  font-weight: 700;
}
.close-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff0f0;
  color: #bf3131;
  font-size: 22px;
}

.rules-card, .info-box, .issued-code-box {
  margin-top: 18px;
  background: #f7fafc;
  border: 1px solid #e3ebf4;
  border-radius: 18px;
  padding: 16px;
}
.rules-card h3 { font-size: 18px; margin-bottom: 8px; }
.rules-card ol {
  padding-left: 20px;
  color: #53697f;
  line-height: 1.8;
  margin: 0;
}

.empty-state {
  min-height: 520px;
  border-radius: 24px;
  border: 1px dashed #d6e1ec;
  background: linear-gradient(180deg, #f8fbff 0%, #f1f5fa 100%);
  display: grid;
  place-items: center;
  text-align: center;
  color: #5f7487;
  padding: 32px;
}
.empty-icon { font-size: 54px; margin-bottom: 12px; }

.result-panel { min-height: 560px; }
.scratch-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ticket-meta {
  padding: 12px 14px;
  border-radius: 14px;
  background: #eef5ff;
  color: #4060a9;
  font-weight: 700;
}
.scratch-wrapper {
  position: relative;
  width: min(100%, 520px);
  margin: 0 auto;
}
.number-card {
  height: 300px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.4), transparent 24%),
    linear-gradient(135deg, #fff0b2, #ffdc63 40%, #ffc53a 100%);
  border: 1px solid rgba(199, 139, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -12px 30px rgba(197, 137, 0, 0.12);
}
.number-label {
  font-size: 16px;
  font-weight: 800;
  color: #8a4f00;
  margin-bottom: 12px;
}
.display-number {
  font-size: clamp(72px, 18vw, 124px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #1f2229;
  text-shadow: 0 6px 20px rgba(255,255,255,0.35);
}
#scratchCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 28px;
  touch-action: none;
}
.scratch-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  color: #2e4256;
  font-weight: 800;
  background: rgba(255,255,255,0.72);
  padding: 10px 14px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}
.scratch-actions {
  display: flex;
  justify-content: center;
}
.result-card {
  margin-top: 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, #fffdf5 0%, #fff6d6 100%);
  border: 1px solid #f1df93;
  padding: 24px;
}
.result-message {
  color: #6d6241;
  margin-top: 10px;
  line-height: 1.75;
}
.result-amount-wrap {
  margin-top: 22px;
  text-align: center;
}
.amount-label {
  color: #8d6e14;
  font-size: 14px;
  font-weight: 800;
}
.final-points {
  font-size: clamp(40px, 10vw, 76px);
  font-weight: 900;
  color: #d33b2b;
  margin-top: 10px;
  letter-spacing: 0.02em;
}
.final-twd {
  margin-top: 6px;
  color: #70591a;
  font-weight: 700;
}
.final-meta {
  margin-top: 16px;
  color: #5d6f81;
  font-size: 14px;
  line-height: 1.7;
}

.clown-modal {
  position: fixed;
  inset: 0;
  background: rgba(13, 18, 30, 0.62);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.clown-dialog {
  position: relative;
  width: min(920px, 100%);
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(240px, 360px) 1fr;
  gap: 24px;
  align-items: center;
  animation: popIn 0.36s ease;
}
.clown-image {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  filter: drop-shadow(0 20px 40px rgba(17, 39, 84, 0.18));
}
.clown-copy h3 {
  font-size: clamp(26px, 4vw, 42px);
  margin: 8px 0 12px;
}
.clown-copy p {
  color: #5a7086;
  line-height: 1.85;
  font-size: 18px;
}
.clown-dialog .close-btn {
  position: absolute;
  right: 18px;
  top: 18px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  background: #182230;
  color: #fff;
  padding: 14px 16px;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(24, 34, 48, 0.22);
}
.toast.error { background: #b83232; }
.toast.show { display: block; }
.toast.hidden { display: none; }

.login-card {
  width: min(460px, calc(100% - 32px));
  margin: 80px auto;
  padding: 28px;
}

.stats-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}
.stat-card {
  padding: 18px;
}
.stat-card span {
  display: block;
  color: #60778e;
  font-size: 13px;
  font-weight: 700;
}
.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
}
.stat-card.wide { grid-column: span 2; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.filter-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 180px 220px 1fr 120px;
  gap: 12px;
  align-items: end;
}
.field.slim span { font-size: 13px; }
.field.slim.wide { min-width: 240px; }

.table-wrap {
  margin-top: 18px;
  overflow: auto;
  border: 1px solid #e3ebf4;
  border-radius: 18px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
.data-table th, .data-table td {
  padding: 14px 12px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
}
.data-table th {
  background: #f7fafc;
  color: #516577;
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table td.wrap {
  white-space: normal;
}
.table-empty {
  text-align: center !important;
  color: #6d8091;
  padding: 26px !important;
}
.pagination-row {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
}
.badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.badge.unused { background: #edf2f7; color: #4d6173; }
.badge.issued { background: #e7f1ff; color: #3155cc; }
.badge.redeemed { background: #fff3d6; color: #a06600; }
.badge.not_ready { background: #f0f4f8; color: #64778b; }
.badge.pending { background: #fff4ce; color: #9a6c00; }
.badge.paid { background: #e3f9ea; color: #177245; }

.issued-code-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.code-label {
  color: #62798f;
  font-weight: 700;
  font-size: 13px;
}
.issued-code-value {
  font-size: 32px;
  letter-spacing: 0.08em;
  font-weight: 900;
  color: #1c2f5d;
}

.info-box.muted { color: #63788d; }

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.92) translateY(10px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 1080px) {
  .front-grid, .admin-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .clown-dialog { grid-template-columns: 1fr; text-align: center; }
  .clown-image { max-height: 360px; }
}

@media (max-width: 760px) {
  .app-shell, .admin-shell { width: min(100% - 20px, 100%); }
  .hero-card, .admin-topbar { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card.wide { grid-column: span 2; }
  .filter-row, .two-cols { grid-template-columns: 1fr; }
  .display-number { font-size: 88px; }
}

.inline-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.inline-actions.center { justify-content: center; }
.inline-actions.wrap { flex-wrap: wrap; }
.top-gap-16 { margin-top: 16px; }
.compact-actions .secondary-btn { padding: 10px 12px; }
.mono-code {
  font-family: Consolas, "Courier New", monospace;
  font-weight: 800;
  color: #22355a;
}
.tiny-text {
  color: #6d8091;
  font-size: 12px;
  margin-top: 4px;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.panel-head.between { justify-content: space-between; }
.subtext.compact { max-width: none; font-size: 14px; margin-top: 6px; }
.history-panel {
  margin-top: 18px;
  background: #f8fbff;
  border: 1px solid #dce9f6;
  border-radius: 18px;
  padding: 18px;
}
.history-meta {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.history-meta-card {
  background: #fff;
  border: 1px solid #e3ebf4;
  border-radius: 16px;
  padding: 14px;
}
.meta-key {
  color: #617a91;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.meta-value {
  margin-top: 8px;
  color: #1d3059;
  font-weight: 800;
  word-break: break-word;
}
.history-list {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}
.history-item {
  background: #fff;
  border: 1px solid #e6edf5;
  border-radius: 18px;
  padding: 16px;
}
.history-item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.history-item-top strong { color: #22355a; }
.history-item-top span { color: #617a91; font-size: 13px; }
.history-item-body {
  display: grid;
  gap: 8px;
  color: #435a70;
  line-height: 1.7;
}
.history-empty {
  padding: 18px;
  text-align: center;
  color: #5f7487;
  border: 1px dashed #d6e1ec;
  border-radius: 16px;
  background: #fff;
}
.issued-code-meta {
  color: #5f7487;
  line-height: 1.6;
}
.badge.partial { background: #fff3d6; color: #a06600; }
.badge.completed { background: #e3f9ea; color: #177245; }
.detail-modal {
  width: min(980px, 100%);
  grid-template-columns: 1fr;
}
.detail-content.full-span { width: 100%; }
.admin-detail-list {
  max-height: 62vh;
  overflow: auto;
  padding-right: 4px;
}

@media (max-width: 760px) {
  .history-meta { grid-template-columns: 1fr; }
  .history-item-top { flex-direction: column; align-items: flex-start; }
}


/* ===== Front circus refresh v4 ===== */
.front-body {
  position: relative;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(26, 11, 24, 0.48), rgba(11, 19, 34, 0.42)),
    url("/circus_bg.png") center/cover fixed no-repeat;
}
.front-body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top center, rgba(255, 213, 92, 0.20), transparent 34%),
    radial-gradient(circle at left top, rgba(255, 77, 85, 0.12), transparent 22%),
    radial-gradient(circle at right top, rgba(32, 84, 216, 0.12), transparent 24%);
}
.front-body .app-shell {
  position: relative;
  z-index: 1;
}
.front-main-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 22px;
}
.circus-hero,
.front-body .circus-panel,
.front-body .clown-dialog {
  background: rgba(255, 250, 243, 0.60);
  border: 1px solid rgba(255, 219, 138, 0.32);
  box-shadow: 0 22px 48px rgba(7, 11, 24, 0.24);
  backdrop-filter: blur(8px);
}
.circus-hero {
  position: relative;
  overflow: hidden;
}
.circus-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 12px;
  background: repeating-linear-gradient(
    90deg,
    #df4047 0 36px,
    #fef6ec 36px 72px,
    #1d54d5 72px 108px,
    #f3c544 108px 144px
  );
}
.circus-hero .eyebrow {
  color: #9c4a17;
}
.circus-hero .subtext {
  color: #5d5b67;
}
.hero-title-wrap {
  display: grid;
  gap: 8px;
}
.hero-tagline {
  max-width: 680px;
  font-size: clamp(15px, 2vw, 19px);
  line-height: 1.65;
  margin-top: 2px;
}
.front-body h1,
.front-body h2,
.front-body h3,
.front-body .field span,
.front-body .meta-value,
.front-body .history-item-top strong {
  color: #1c2540;
}
.front-body .hero-badges span,
.front-body .result-chip,
.front-body .clown-tag {
  background: linear-gradient(135deg, #ffe493, #f5c741);
  color: #6f3f00;
  box-shadow: 0 10px 20px rgba(234, 170, 44, 0.20);
}
.front-body .primary-btn {
  background: linear-gradient(135deg, #d74147, #2054d8);
  box-shadow: 0 16px 28px rgba(29, 68, 160, 0.28);
}
.front-body .secondary-btn {
  background: linear-gradient(135deg, #f8f4ee, #ffffff);
  border: 1px solid rgba(30, 72, 161, 0.12);
  color: #1d43aa;
}
.front-body .secondary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.front-body .field input {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(32, 84, 216, 0.12);
}
.front-body .field input:focus {
  border-color: #2054d8;
  box-shadow: 0 0 0 4px rgba(32, 84, 216, 0.14);
}
.circus-rules {
  background: linear-gradient(180deg, rgba(255, 247, 227, 0.62), rgba(255, 252, 247, 0.58));
  border-color: rgba(235, 190, 79, 0.28);
}
.circus-rules ol,
.front-body .result-message,
.front-body .subtext,
.front-body .history-item-body {
  color: #615d69;
}
.circus-empty {
  background: linear-gradient(180deg, rgba(255, 246, 219, 0.76), rgba(255, 255, 255, 0.72));
  border: 1px dashed rgba(234, 190, 69, 0.38);
}
.front-body .empty-icon {
  filter: drop-shadow(0 8px 18px rgba(214, 67, 74, 0.18));
}
.front-body .ticket-meta {
  background: linear-gradient(135deg, rgba(30, 84, 214, 0.10), rgba(255, 209, 86, 0.18));
  color: #29416b;
}
.front-body .number-card {
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,0.28), transparent 24%),
    linear-gradient(135deg, #ffe27b, #ffc84d 52%, #f2b223 100%);
  border-color: rgba(181, 110, 0, 0.18);
  box-shadow:
    inset 0 -14px 30px rgba(179, 117, 0, 0.16),
    0 20px 40px rgba(10, 17, 32, 0.12);
}
.front-body .scratch-hint {
  background: rgba(255, 249, 234, 0.74);
  color: #5f4123;
  white-space: nowrap;
  max-width: calc(100% - 14px);
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(10px, 2.4vw, 13px);
  line-height: 1.2;
}
.front-body .result-card {
  background: linear-gradient(180deg, rgba(255, 250, 235, 0.68), rgba(255, 244, 211, 0.62));
  border-color: rgba(236, 198, 89, 0.40);
}
.front-body .amount-label {
  color: #8d6311;
}
.front-body .final-points {
  color: #d63b2a;
  text-shadow: 0 8px 20px rgba(214, 59, 42, 0.10);
}
.front-body .final-twd {
  display: none;
}
.front-body .final-meta {
  color: #545f70;
}
.history-shell {
  margin-top: 22px;
}
.history-content {
  margin-top: 16px;
}
.compact-btn {
  padding: 10px 12px;
}
.front-body .history-panel,
.front-body .history-shell {
  background: rgba(255, 250, 243, 0.60);
}
.front-body .history-meta-card,
.front-body .history-item {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(255, 220, 143, 0.32);
}
.front-body .history-item {
  padding: 0;
  overflow: hidden;
}
.front-body .history-item summary {
  list-style: none;
}
.front-body .history-item summary::-webkit-details-marker {
  display: none;
}
.front-body .history-item-top {
  margin: 0;
  padding: 16px 18px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.front-body .history-item-top > div:first-child {
  display: grid;
  gap: 4px;
}
.front-body .history-points {
  color: #1d43aa;
  font-weight: 900;
  white-space: nowrap;
}
.front-body .history-item[open] .history-item-top {
  background: linear-gradient(135deg, rgba(255, 244, 208, 0.72), rgba(255, 255, 255, 0.90));
}
.front-body .history-item-body {
  padding: 0 18px 18px;
}
.history-jackpot {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe493, #f5c741);
  color: #6f3f00;
  font-size: 12px;
  font-weight: 800;
}
.clown-modal {
  background: rgba(13, 12, 22, 0.68);
  overflow-y: auto;
}
.circus-dialog {
  overflow: auto;
  position: relative;
  width: min(1120px, 100%);
  max-height: min(92vh, 960px);
  grid-template-columns: minmax(280px, 400px) 1fr;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.94), rgba(255,252,245,0.88));
}
.circus-dialog::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 12px;
  background: repeating-linear-gradient(
    90deg,
    #df4047 0 34px,
    #fef6ec 34px 68px,
    #2054d8 68px 102px,
    #f3c544 102px 136px
  );
}
.clown-visual {
  position: relative;
  padding: 12px 10px 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
}
.clown-visual::before {
  content: "";
  position: absolute;
  inset: 20px 10px 20px 14px;
  border-radius: 26px;
  background: radial-gradient(circle at center, rgba(255, 222, 110, 0.36), rgba(255, 255, 255, 0));
  z-index: 0;
}
.circus-dialog .clown-image {
  position: relative;
  z-index: 1;
  width: min(100%, 360px);
  max-height: min(62vh, 560px);
  object-fit: contain;
  margin: 0 auto;
  transform-origin: center bottom;
  animation: clownEntrance 0.56s cubic-bezier(0.2, 0.9, 0.2, 1), clownBob 2.8s ease-in-out infinite 0.56s, clownSway 4.8s ease-in-out infinite 0.9s;
}
.circus-dialog .clown-copy {
  position: relative;
  z-index: 1;
  padding-right: 12px;
}
.circus-dialog .clown-copy h3 {
  color: #1c2540;
}
.circus-dialog .clown-copy p {
  color: #5f6370;
  font-size: clamp(15px, 2.1vw, 18px);
  line-height: 1.7;
}
.confetti-stage {
  position: absolute;
  inset: -16% -10%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.confetti-piece {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--size);
  height: calc(var(--size) * 1.95);
  border-radius: 7px;
  background: var(--bg);
  opacity: 0;
  transform: translate(-50%, -50%) rotate(0deg) scale(0.4);
  animation: confettiBurst var(--duration) cubic-bezier(0.16, 0.84, 0.29, 1) forwards;
  animation-delay: var(--delay);
  box-shadow: 0 4px 14px rgba(10, 17, 32, 0.16);
}
.confetti-piece.ribbon {
  width: calc(var(--size) * 0.38);
  height: calc(var(--size) * 5.8);
  border-radius: 999px;
}
.confetti-piece.dot {
  width: calc(var(--size) * 0.82);
  height: calc(var(--size) * 0.82);
  border-radius: 50%;
}
.confetti-piece.star {
  width: calc(var(--size) * 1.15);
  height: calc(var(--size) * 1.15);
  background: radial-gradient(circle at center, #fff9d8 0 34%, var(--bg) 35% 100%);
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 57%, 79% 92%, 50% 71%, 21% 92%, 32% 57%, 2% 35%, 39% 34%);
}
.confetti-flare {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,0.72) 0%, rgba(255,213,76,0.34) 24%, rgba(255,255,255,0) 62%);
  mix-blend-mode: screen;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.18);
  animation: flarePop var(--duration) ease-out forwards;
  animation-delay: var(--delay);
}
@keyframes confettiBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.26) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)) scale(1);
  }
}
@keyframes clownEntrance {
  0% { opacity: 0; transform: translateY(20px) scale(0.9) rotate(-4deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
}
@keyframes clownBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.01); }
}
@keyframes clownSway {
  0%, 100% { transform: rotate(-1.8deg); }
  50% { transform: rotate(1.8deg); }
}
@keyframes flarePop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.1);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.3);
  }
}
@media (max-width: 1080px) {
  .front-main-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .front-main-grid { grid-template-columns: 1fr; }
  .circus-dialog {
    grid-template-columns: 1fr;
    text-align: center;
    width: min(100%, 560px);
    max-height: calc(100vh - 24px);
    padding: 16px 14px 18px;
    gap: 10px;
  }
  .clown-dialog .close-btn {
    top: 12px;
    right: 12px;
    z-index: 4;
  }
  .clown-visual {
    min-height: auto;
    padding: 12px 4px 0;
  }
  .clown-visual::before {
    inset: 16px 10px;
    border-radius: 20px;
  }
  .circus-dialog .clown-image {
    width: min(82vw, 320px);
    max-height: 42vh;
  }
  .circus-dialog .clown-copy {
    padding: 0 6px 6px;
  }
  .circus-dialog .clown-copy h3 {
    font-size: clamp(28px, 8vw, 36px);
    margin: 6px 0 10px;
  }
  .circus-dialog .clown-copy p {
    font-size: 15px;
    line-height: 1.6;
  }
  .front-body .history-item-top {
    flex-direction: column;
    align-items: flex-start;
  }
  .scratch-hint {
    font-size: 12px;
    padding: 8px 10px;
    max-width: calc(100% - 10px);
  }
}
