:root {
  --bg-deep: #0b0f17;
  --bg-mid: #0c0f14;
  --bg-card: rgba(14, 17, 24, 0.88);
  --border: rgba(56, 255, 222, 0.18);
  --accent-cyan: #38ffde;
  --accent-purple: #4c40ec;
  --accent-gold: #f3ce28;
  --accent-pink: #fab6f4;
  --text: #ecebf0;
  --text-muted: rgba(236, 235, 240, 0.65);
  --radius-lg: 18px;
  --radius-md: 12px;
  --font-display: "Caveat", cursive;
  --font-ui: "DM Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  height: 100svh;
  max-height: 100svh;
  overflow: hidden;
  font-family: var(--font-ui);
  line-height: 1.4;
  color: var(--text);
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -30%, rgba(76, 64, 236, 0.22), transparent 55%),
    linear-gradient(180deg, var(--bg-mid) 0%, var(--bg-deep) 50%, #06080d 100%);
}

.shell {
  width: min(1280px, 100%);
  height: 100svh;
  max-height: 100svh;
  margin: 0 auto;
  padding: 10px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  padding: 12px 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

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

.brand-emoji {
  font-size: 2.25rem;
  line-height: 1;
  filter: drop-shadow(0 6px 12px rgba(76, 64, 236, 0.45));
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  margin: 0;
  background: linear-gradient(120deg, var(--text), var(--accent-cyan), var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-height: 720px) {
  .brand-text p {
    display: none;
  }
}

.pill {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 255, 222, 0.3);
  border-radius: 999px;
  padding: 3px 8px;
  margin-bottom: 4px;
}

.wallet-bar {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.wallet-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wallet-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  min-width: 4.5rem;
}

.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
}

.section-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.lottery-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.95fr);
  gap: 12px;
  align-items: center;
}

@media (max-width: 900px) {
  body {
    overflow-y: auto;
    height: auto;
    max-height: none;
  }

  .shell {
    height: auto;
    max-height: none;
    overflow: visible;
    min-height: 100svh;
  }

  .lottery-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

.wheel-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 0;
  height: 100%;
}

.wheel-wrap {
  position: relative;
  width: min(100%, min(54vmin, 500px));
  max-height: min(58vh, 500px);
  aspect-ratio: 1;
  margin: 0 auto;
}

#wheel-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 50%;
  box-shadow:
    0 0 0 3px rgba(76, 64, 236, 0.35),
    0 0 40px rgba(56, 255, 222, 0.12),
    0 16px 40px rgba(0, 0, 0, 0.5);
  transition: filter 0.3s;
}

.wheel-wrap.is-spinning #wheel-canvas {
  filter: brightness(1.08) saturate(1.1);
}

.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 22px solid var(--accent-gold);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  z-index: 2;
}

.spin-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

.panel-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  word-break: break-word;
}

.dev-test-wrap {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(196, 181, 253, 0.45);
  background: rgba(124, 58, 237, 0.08);
}

.dev-test-wrap.hidden {
  display: none;
}

.dev-test-hint {
  margin: 6px 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.dev-test-btn {
  width: 100%;
  border: 1px solid rgba(196, 181, 253, 0.55);
  color: #e9d5ff;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.85), rgba(91, 33, 182, 0.9));
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.25);
}

.dev-test-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: #0b0f17;
  background: linear-gradient(135deg, var(--accent-cyan), #2dd4bf);
  box-shadow: 0 6px 24px rgba(56, 255, 222, 0.25);
  width: 100%;
  flex-shrink: 0;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.sm {
  width: auto;
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn.ghost {
  width: auto;
  padding: 8px 12px;
  font-size: 0.8rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.ghost:hover:not(:disabled) {
  color: var(--accent-cyan);
  border-color: rgba(56, 255, 222, 0.4);
}

.result-banner {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(243, 206, 40, 0.4);
  background: rgba(243, 206, 40, 0.1);
  flex-shrink: 0;
}

.result-banner.hidden {
  display: none;
}

.result-title {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent-gold);
}

.result-detail {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.panel-extra {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.tx-simulator {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.tx-simulator summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  padding: 4px 0;
}

.tx-sim-hint {
  margin: 4px 0 8px;
  font-size: 0.78rem;
  line-height: 1.35;
}

.tx-sim-status {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
}

.tx-sim-status.hidden {
  display: none;
}

.tx-sim-status--ok {
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.08);
}

.tx-sim-status--fail {
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}

.tx-sim-output {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.4);
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 140px;
  overflow: auto;
}

.prize-list {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.prize-list summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  padding: 4px 0;
}

.prize-list ul {
  margin: 6px 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 4px;
}

.prize-list li {
  font-size: 0.8rem;
  line-height: 1.35;
}

.output-log {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.4);
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 64px;
  overflow: auto;
}

.footer-hints {
  flex-shrink: 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin: 0;
}

.footer-hints p {
  margin: 0;
}

.footer-hints .footer-hint--fine {
  opacity: 0.8;
  margin-top: 2px;
}

.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  position: relative;
  width: min(100%, 440px);
  padding: 24px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-badge {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 8px;
}

.modal-title {
  text-align: center;
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.75rem;
}

.modal-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 14px;
}

.modal-sig-code {
  display: block;
  font-size: 0.75rem;
  word-break: break-all;
  margin-top: 6px;
  color: var(--accent-cyan);
}

.modal-footer-btns {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-footer-btns .btn {
  flex: 1;
}

.modal-detail-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}
