body.lottery-tool-page {
      --bg: #10141f;
      --panel: rgba(255,255,255,.08);
      --panel-strong: rgba(255,255,255,.13);
      --text: #f5f7fb;
      --muted: #a9b2c7;
      --line: rgba(255,255,255,.16);
      --accent: #8bd3ff;
      --accent-2: #ffd166;
      --danger: #ff7b7b;
      --ok: #9ef2b3;
      --shadow: 0 20px 60px rgba(0,0,0,.35);
      --radius: 8px;
      --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    }

    body.lottery-tool-page, body.lottery-tool-page * { box-sizing: border-box; }
    body.lottery-tool-page {
      margin: 0;
      min-height: 100vh;
      font-family: var(--font);
      color: var(--text);
      background:
        radial-gradient(circle at top left, rgba(139, 211, 255, .25), transparent 34rem),
        radial-gradient(circle at bottom right, rgba(255, 209, 102, .18), transparent 32rem),
        linear-gradient(135deg, #10141f 0%, #161b2d 50%, #10141f 100%);
    }

    .lottery-app header {
      padding: 34px 20px 16px;
      text-align: center;
    }

    .lottery-app .eyebrow {
      display: inline-flex;
      gap: 8px;
      align-items: center;
      padding: 7px 12px;
      border: 1px solid var(--line);
      border-radius: 999px;
      color: var(--muted);
      background: rgba(255,255,255,.05);
      font-size: 13px;
    }

    .lottery-app h1 {
      margin: 16px 0 8px;
      font-size: 42px;
      letter-spacing: 0;
      line-height: 1.05;
    }

    .lottery-app .subtitle {
      max-width: 760px;
      margin: 0 auto;
      color: var(--muted);
      line-height: 1.7;
      font-size: 15px;
    }

    .lottery-app main {
      width: min(1180px, calc(100% - 28px));
      margin: 18px auto 48px;
      display: grid;
      grid-template-columns: 360px 1fr;
      gap: 18px;
    }

    .lottery-app .card {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      backdrop-filter: blur(16px);
    }

    .lottery-app .side {
      padding: 18px;
      height: fit-content;
      position: sticky;
      top: 16px;
    }

    .lottery-app label {
      display: block;
      color: var(--muted);
      font-size: 13px;
      margin-bottom: 8px;
    }

    .lottery-app textarea, .lottery-app input, .lottery-app select {
      width: 100%;
      color: var(--text);
      background: rgba(0,0,0,.22);
      border: 1px solid var(--line);
      border-radius: 8px;
      outline: none;
      font: inherit;
    }

    .lottery-app textarea {
      min-height: 236px;
      padding: 14px;
      resize: vertical;
      line-height: 1.55;
    }

    .lottery-app input, .lottery-app select { padding: 11px 12px; }

    .lottery-app textarea:focus, .lottery-app input:focus, .lottery-app select:focus {
      border-color: rgba(139, 211, 255, .75);
      box-shadow: 0 0 0 3px rgba(139, 211, 255, .16);
    }

    .lottery-app .hint {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.5;
      margin: 8px 0 16px;
    }

    .lottery-app .row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin: 12px 0;
    }

    .lottery-app .check {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 12px;
      border-radius: 8px;
      background: rgba(255,255,255,.05);
      color: var(--muted);
      font-size: 13px;
      user-select: none;
    }

    .lottery-app .check input { width: auto; }

    .lottery-app button {
      border: 0;
      border-radius: 8px;
      padding: 12px 14px;
      color: #0e1320;
      background: linear-gradient(135deg, var(--accent), #b5e8ff);
      font: inherit;
      font-weight: 800;
      cursor: pointer;
      transition: transform .15s ease, filter .15s ease, opacity .15s ease;
    }

    .lottery-app button:hover { transform: translateY(-1px); filter: brightness(1.04); }
    .lottery-app button:active { transform: translateY(0); }
    .lottery-app button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

    .lottery-app .secondary {
      color: var(--text);
      background: rgba(255,255,255,.10);
      border: 1px solid var(--line);
      font-weight: 700;
    }

    .lottery-app .danger {
      color: #251010;
      background: linear-gradient(135deg, #ff9b9b, #ffd1d1);
    }

    .lottery-app .button-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin-top: 12px;
    }

    .lottery-app .tabs {
      display: flex;
      gap: 10px;
      padding: 12px;
      overflow-x: auto;
      border-bottom: 1px solid var(--line);
    }

    .lottery-app .tab {
      flex: 1;
      min-width: 116px;
      color: var(--text);
      background: rgba(255,255,255,.07);
      border: 1px solid transparent;
    }

    .lottery-app .tab.active {
      color: #0e1320;
      background: linear-gradient(135deg, var(--accent-2), #ffe5a3);
    }

    .lottery-app .workspace { overflow: hidden; }
    .lottery-app .method { display: none; padding: 18px; }
    .lottery-app .method.active { display: block; }

    .lottery-app .method-head {
      display: flex;
      gap: 12px;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: 16px;
    }

    .lottery-app .method h2 { margin: 0 0 6px; font-size: 22px; }
    .lottery-app .method p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 14px; }

    .lottery-app .stage {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: rgba(0,0,0,.16);
      min-height: 430px;
      display: grid;
      place-items: center;
      padding: 18px;
      position: relative;
      overflow: hidden;
    }

    .lottery-app .wheel-wrap {
      position: relative;
      width: min(460px, 92vw);
      aspect-ratio: 1;
      display: grid;
      place-items: center;
    }

    .lottery-app canvas#wheelCanvas {
      width: 100%;
      height: 100%;
      filter: drop-shadow(0 18px 34px rgba(0,0,0,.35));
    }

    .lottery-app .pointer {
      position: absolute;
      top: -5px;
      left: 50%;
      translate: -50% 0;
      width: 0;
      height: 0;
      border-left: 18px solid transparent;
      border-right: 18px solid transparent;
      border-top: 34px solid var(--accent-2);
      filter: drop-shadow(0 4px 10px rgba(0,0,0,.35));
      z-index: 5;
    }

    .lottery-app .center-badge {
      position: absolute;
      width: 108px;
      height: 108px;
      border-radius: 999px;
      display: grid;
      place-items: center;
      color: #10141f;
      background: #fff;
      border: 8px solid rgba(16,20,31,.2);
      font-weight: 900;
      letter-spacing: .08em;
      box-shadow: 0 12px 30px rgba(0,0,0,.28);
    }

    .lottery-app .box-stage {
      width: min(620px, 100%);
      display: grid;
      gap: 16px;
    }

    .lottery-app .lot-box {
      min-height: 240px;
      border-radius: 8px;
      border: 1px solid rgba(255,255,255,.22);
      background:
        linear-gradient(135deg, rgba(255,255,255,.13), rgba(255,255,255,.04)),
        repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 10px, transparent 10px 20px);
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 12px;
      flex-wrap: wrap;
      padding: 28px;
    }

    .lottery-app .ticket {
      min-width: 92px;
      max-width: 180px;
      padding: 12px 14px;
      border-radius: 8px;
      color: #111827;
      background: #fff;
      text-align: center;
      font-weight: 800;
      box-shadow: 0 10px 18px rgba(0,0,0,.22);
      transform: rotate(var(--r, 0deg));
      animation: floaty 2.8s ease-in-out infinite;
      word-break: break-word;
    }

    @keyframes floaty {
      0%,100% { translate: 0 0; }
      50% { translate: 0 -8px; }
    }

    .lottery-app .ghost-wrap {
      width: 100%;
      min-height: 390px;
      display: grid;
      place-items: center;
    }

    .lottery-app #ghostSvg {
      width: 100%;
      max-width: 780px;
      min-height: 360px;
      overflow: visible;
    }

    .lottery-app .svg-label {
      fill: var(--text);
      font-size: 13px;
      font-weight: 700;
    }

    .lottery-app .svg-muted { fill: var(--muted); font-size: 12px; }
    .lottery-app .ladder-line { stroke: rgba(255,255,255,.35); stroke-width: 4; stroke-linecap: round; }
    .lottery-app .ladder-rung { stroke: rgba(255,209,102,.76); stroke-width: 4; stroke-linecap: round; }
    .lottery-app .path-line { stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; fill: none; opacity: .95; filter: drop-shadow(0 0 6px rgba(255,255,255,.22)); }
    .lottery-app .path-dot { stroke: rgba(16,20,31,.65); stroke-width: 2; }

    .lottery-app .method-actions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .lottery-app .method-actions button { white-space: nowrap; }

    .lottery-app .ghost-picker {
      margin: 14px 0 0;
      padding: 14px;
      border: 1px solid rgba(139,211,255,.25);
      border-radius: 8px;
      background: rgba(139,211,255,.08);
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 12px;
      align-items: end;
    }

    .lottery-app .ghost-picker[hidden] { display: none; }

    .lottery-app .ghost-picker b { color: var(--accent-2); }

    .lottery-app .ghost-picker .hint { margin: 8px 0 0; }

    .lottery-app .ghost-picker-actions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .lottery-app .ghost-picker-actions button { white-space: nowrap; }

    .lottery-app .ghost-choice { cursor: pointer; }
    .lottery-app .ghost-choice-bg { fill: rgba(255,209,102,.14); stroke: rgba(255,209,102,.42); stroke-width: 1.5; }
    .lottery-app .ghost-choice:hover .ghost-choice-bg { fill: rgba(255,209,102,.28); }
    .lottery-app .ghost-choice.active .ghost-choice-bg { fill: rgba(158,242,179,.22); stroke: rgba(158,242,179,.75); }
    .lottery-app .ghost-choice-text { fill: var(--text); font-size: 12px; font-weight: 900; pointer-events: none; }
    .lottery-app .ghost-name-bg { fill: rgba(139,211,255,.14); stroke: rgba(139,211,255,.45); stroke-width: 1.5; }
    .lottery-app .ghost-name-text { fill: var(--text); font-size: 12px; font-weight: 900; pointer-events: none; }
    .lottery-app .ghost-top-hint { fill: var(--muted); font-size: 10px; font-weight: 700; pointer-events: none; }
    .lottery-app .ghost-cover { fill: rgba(16,20,31,.92); stroke: rgba(255,255,255,.25); stroke-width: 1.5; }
    .lottery-app .ghost-cover-text { fill: var(--muted); font-size: 11px; font-weight: 800; pointer-events: none; }
    .lottery-app .ghost-win { fill: var(--ok); font-size: 13px; font-weight: 900; }
    .lottery-app .ghost-lose { fill: var(--muted); font-size: 12px; font-weight: 800; }

    .lottery-app .result-panel {
      margin-top: 16px;
      padding: 16px;
      border-radius: 8px;
      border: 1px solid var(--line);
      background: rgba(255,255,255,.07);
      display: grid;
      gap: 10px;
    }

    .lottery-app .result-title {
      color: var(--muted);
      font-size: 13px;
    }

    .lottery-app .result-list {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      min-height: 35px;
    }

    .lottery-app .pill {
      padding: 8px 11px;
      border-radius: 999px;
      background: rgba(158,242,179,.14);
      border: 1px solid rgba(158,242,179,.35);
      color: var(--ok);
      font-weight: 800;
      word-break: break-word;
    }

    .lottery-app .empty {
      color: var(--muted);
      font-size: 14px;
      line-height: 1.5;
    }

    .lottery-app .status {
      margin-top: 12px;
      color: var(--muted);
      font-size: 13px;
      line-height: 1.5;
    }

    .lottery-app .history {
      margin-top: 14px;
      border-top: 1px solid var(--line);
      padding-top: 14px;
    }

    .lottery-app .history h3 {
      margin: 0 0 10px;
      font-size: 15px;
    }

    .lottery-app .history-list {
      display: grid;
      gap: 8px;
      max-height: 240px;
      overflow: auto;
      padding-right: 4px;
    }

    .lottery-app .history-item {
      padding: 10px;
      border-radius: 8px;
      background: rgba(255,255,255,.05);
      border: 1px solid rgba(255,255,255,.08);
      font-size: 13px;
      line-height: 1.45;
    }

    .lottery-app .history-item b { color: var(--accent-2); }
    .lottery-app .history-item time { color: var(--muted); display: block; margin-bottom: 4px; font-size: 12px; }

    .lottery-app .toast {
      position: fixed;
      left: 50%;
      bottom: 24px;
      translate: -50% 20px;
      background: rgba(16,20,31,.92);
      border: 1px solid var(--line);
      color: var(--text);
      padding: 12px 16px;
      border-radius: 999px;
      box-shadow: var(--shadow);
      opacity: 0;
      pointer-events: none;
      transition: .25s ease;
      max-width: min(92vw, 640px);
      text-align: center;
      z-index: 20;
    }

    .lottery-app .toast.show { opacity: 1; translate: -50% 0; }

    .lottery-app .privacy {
      margin-top: 14px;
      padding: 12px;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.55;
      border-radius: 8px;
      background: rgba(139,211,255,.08);
      border: 1px solid rgba(139,211,255,.18);
    }

    @media (max-width: 900px) {
      .lottery-app main { grid-template-columns: 1fr; }
      .lottery-app .side { position: static; }
      .lottery-app .method-head { flex-direction: column; }
      .lottery-app .ghost-picker { grid-template-columns: 1fr; }
      .lottery-app .ghost-picker-actions { justify-content: stretch; }
      .lottery-app .ghost-picker-actions button { flex: 1; }
      .lottery-app .stage { min-height: 360px; }
      .lottery-app textarea { min-height: 180px; }
    }

    @media (max-width: 560px) {
      .lottery-app header { padding-top: 24px; }
      .lottery-app h1 { font-size: 30px; }
      .lottery-app main { width: min(100% - 18px, 1180px); }
      .lottery-app .row, .lottery-app .button-row { grid-template-columns: 1fr; }
      .lottery-app .tabs { padding: 9px; gap: 8px; }
      .lottery-app .tab { min-width: 105px; padding: 10px 12px; }
      .lottery-app .method { padding: 12px; }
      .lottery-app .stage { padding: 10px; }
      .lottery-app .center-badge { width: 82px; height: 82px; font-size: 13px; }
    }

.lottery-app {
  isolation: isolate;
}

.lottery-app .stage {
  max-width: 100%;
}

.lottery-app .ghost-wrap {
  overflow-x: auto;
}

@media (max-width: 640px) {
  .lottery-app canvas#wheelCanvas {
    max-width: 100%;
  }

  .lottery-app #ghostSvg {
    min-width: 560px;
  }
}

/* Light page theme and always-reachable draw controls. */
body.lottery-tool-page {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-strong: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --line: #d8e0ea;
  --accent: #2563eb;
  --accent-2: #f59e0b;
  --danger: #dc2626;
  --ok: #047857;
  --shadow: 0 16px 42px rgba(15, 23, 42, .08);
  color: var(--text);
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fafc 54%, #eef6ff 100%);
}

.lottery-app header {
  padding: 24px 20px 12px;
}

.lottery-app .eyebrow {
  color: #475569;
  background: #f8fafc;
  border-color: #e2e8f0;
}

.lottery-app .card {
  background: var(--panel);
  border-color: #e2e8f0;
  box-shadow: var(--shadow);
  backdrop-filter: none;
}

.lottery-app textarea,
.lottery-app input,
.lottery-app select {
  color: #172033;
  background: #ffffff;
  border-color: #cbd5e1;
}

.lottery-app textarea:focus,
.lottery-app input:focus,
.lottery-app select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.lottery-app .check,
.lottery-app .tabs,
.lottery-app .result-panel,
.lottery-app .history-item,
.lottery-app .privacy {
  background: #f8fafc;
}

.lottery-app .check {
  color: #475569;
  border: 1px solid #e2e8f0;
}

.lottery-app button {
  color: #ffffff;
  background: #2563eb;
  box-shadow: 0 8px 18px rgba(37, 99, 235, .18);
}

.lottery-app button:hover {
  filter: none;
  background: #1d4ed8;
}

.lottery-app .secondary {
  color: #334155;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: none;
}

.lottery-app .secondary:hover {
  color: #0f172a;
  background: #f1f5f9;
}

.lottery-app .danger {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
  box-shadow: none;
}

.lottery-app .danger:hover {
  background: #fecaca;
}

.lottery-app .tab {
  color: #475569;
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: none;
}

.lottery-app .tab.active {
  color: #ffffff;
  background: #2563eb;
  border-color: #2563eb;
}

.lottery-app .workspace {
  overflow: visible;
}

.lottery-app main {
  max-width: calc(100vw - 18px);
  min-width: 0;
}

.lottery-app .side,
.lottery-app .workspace,
.lottery-app .method,
.lottery-app .stage,
.lottery-app .result-panel,
.lottery-app .status {
  min-width: 0;
}

.lottery-app .method-head {
  position: static;
  align-items: center;
  padding: 0;
  margin: 0 0 12px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.lottery-app .method-head > div:first-child {
  min-width: 0;
}

.lottery-app .method-action-bar button,
.lottery-app .method-actions button {
  min-height: 44px;
}

.lottery-app .method-action-bar {
  position: sticky;
  top: 78px;
  z-index: 70;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 0 16px;
  padding: 10px;
  background: rgba(255, 255, 255, .95);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .09);
  backdrop-filter: blur(14px);
}

.lottery-app .stage {
  background: #f8fafc;
  border-color: #dbe4ef;
}

.lottery-app .lot-box {
  border-color: #d8e0ea;
  background:
    linear-gradient(135deg, #ffffff, #eef6ff),
    repeating-linear-gradient(45deg, rgba(37, 99, 235, .06) 0 10px, transparent 10px 20px);
}

.lottery-app .ticket {
  color: #0f172a;
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

.lottery-app .svg-label,
.lottery-app .ghost-choice-text,
.lottery-app .ghost-name-text {
  fill: #172033;
}

.lottery-app .svg-muted,
.lottery-app .ghost-top-hint,
.lottery-app .ghost-cover-text,
.lottery-app .ghost-lose {
  fill: #64748b;
}

.lottery-app .ladder-line {
  stroke: rgba(71, 85, 105, .42);
}

.lottery-app .ladder-rung {
  stroke: rgba(245, 158, 11, .78);
}

.lottery-app .ghost-choice-bg {
  fill: #fff7ed;
  stroke: #fed7aa;
}

.lottery-app .ghost-choice:hover .ghost-choice-bg {
  fill: #ffedd5;
}

.lottery-app .ghost-choice.active .ghost-choice-bg {
  fill: #dcfce7;
  stroke: #86efac;
}

.lottery-app .ghost-name-bg {
  fill: #eff6ff;
  stroke: #bfdbfe;
}

.lottery-app .ghost-cover {
  fill: #f8fafc;
  stroke: #cbd5e1;
}

.lottery-app .ghost-win {
  fill: #047857;
}

.lottery-app .result-panel,
.lottery-app .history-item {
  border-color: #e2e8f0;
}

.lottery-app .pill {
  color: #047857;
  background: #ecfdf5;
  border-color: #bbf7d0;
}

.lottery-app .history-item b,
.lottery-app .ghost-picker b {
  color: #b45309;
}

.lottery-app .privacy,
.lottery-app .ghost-picker {
  color: #475569;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.lottery-app .toast {
  color: #ffffff;
  background: rgba(15, 23, 42, .94);
  border-color: rgba(15, 23, 42, .18);
}

@media (max-width: 900px) {
  .lottery-app .workspace {
    order: -1;
  }

  .lottery-app .method-head p {
    display: none;
  }

  .lottery-app .method-action-bar,
  .lottery-app .method-actions {
    top: 72px;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .lottery-app header {
    padding: 18px 16px 8px;
  }

  .lottery-app .method-head {
    align-items: stretch;
    flex-direction: column;
    margin: -4px -4px 12px;
  }

  .lottery-app .method-action-bar,
  .lottery-app .method-actions {
    top: 70px;
    display: grid;
    grid-template-columns: 1fr;
    margin: 0 0 12px;
  }

  .lottery-app .method-action-bar button,
  .lottery-app .method-actions button {
    width: 100%;
  }

  .lottery-app .stage {
    min-height: 320px;
  }

  .lottery-app main {
    width: calc(100% - 18px);
    max-width: calc(100vw - 18px);
  }

  .lottery-app .tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lottery-app .tab {
    min-width: 0;
  }
}

body.lottery-focus-mode {
  min-height: 100dvh;
  overflow-x: hidden;
  background: #f8fafc;
}

body.lottery-focus-mode > .kilo-site-nav,
.lottery-app.focus-mode > header,
.lottery-app.focus-mode .side,
.lottery-app.focus-mode .status {
  display: none !important;
}

.lottery-app.focus-mode {
  min-height: 100dvh;
  padding: 12px;
}

.lottery-app.focus-mode main {
  width: min(1440px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  min-height: calc(100dvh - 24px);
  margin: 0 auto;
  display: block;
}

.lottery-app.focus-mode .workspace {
  min-height: calc(100dvh - 24px);
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  border-color: #dbe4ef;
  box-shadow: 0 18px 54px rgba(15, 23, 42, .12);
}

.lottery-app.focus-mode .tabs {
  position: sticky;
  top: 12px;
  z-index: 80;
  background: rgba(248, 250, 252, .96);
  backdrop-filter: blur(14px);
}

.lottery-app.focus-mode .method {
  padding: 14px;
}

.lottery-app.focus-mode .method-head {
  margin: 0 0 10px;
}

.lottery-app.focus-mode .method-head p {
  display: none;
}

.lottery-app.focus-mode .method-action-bar {
  top: 72px;
  margin-bottom: 14px;
  box-shadow: none;
}

.lottery-app.focus-mode .stage {
  min-height: min(66dvh, 720px);
  padding: 22px;
}

.lottery-app.focus-mode .wheel-wrap {
  width: min(64dvh, 680px, 86vw);
}

.lottery-app.focus-mode .box-stage {
  width: min(860px, 100%);
}

.lottery-app.focus-mode .lot-box {
  min-height: min(44dvh, 420px);
}

.lottery-app.focus-mode .ghost-wrap {
  min-height: min(58dvh, 620px);
}

.lottery-app.focus-mode #ghostSvg {
  max-width: min(1120px, 100%);
  min-height: min(54dvh, 560px);
}

.lottery-app.focus-mode .result-panel {
  margin-top: 18px;
}

@media (max-width: 640px) {
  .lottery-app.focus-mode {
    padding: 8px;
  }

  .lottery-app.focus-mode main {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
  }

  .lottery-app.focus-mode .workspace {
    min-height: calc(100dvh - 16px);
  }

  .lottery-app.focus-mode .method {
    padding: 10px;
  }

  .lottery-app.focus-mode .tabs {
    top: 8px;
  }

  .lottery-app.focus-mode .method-action-bar {
    top: 62px;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }

  .lottery-app.focus-mode .stage {
    min-height: 52dvh;
    padding: 12px;
  }

  .lottery-app.focus-mode .wheel-wrap {
    width: min(52dvh, calc(100vw - 56px));
  }
}

.lottery-app .result-panel {
  position: relative;
  padding: 18px;
  background: linear-gradient(180deg, #fffdf5 0%, #fffbeb 100%);
  border: 2px solid #f8c24e;
  box-shadow: 0 12px 28px rgba(180, 83, 9, .12);
}

.lottery-app .result-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #92400e;
  font-size: 14px;
  font-weight: 900;
}

.lottery-app .result-title::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #f59e0b;
  box-shadow: 0 0 0 5px rgba(245, 158, 11, .15);
}

.lottery-app .result-list {
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.lottery-app .pill {
  min-height: 48px;
  padding: 11px 18px;
  border-radius: 8px;
  color: #064e3b;
  background: #d1fae5;
  border: 2px solid #34d399;
  font-size: 22px;
  font-weight: 950;
  line-height: 1.25;
  box-shadow: 0 10px 24px rgba(4, 120, 87, .14);
  animation: result-pop .32s ease-out both;
}

.lottery-app .empty {
  color: #78716c;
}

.lottery-app.focus-mode .result-panel {
  margin-top: 20px;
  padding: 22px;
}

.lottery-app.focus-mode .result-list {
  min-height: 72px;
}

.lottery-app.focus-mode .pill {
  min-height: 60px;
  padding: 14px 24px;
  font-size: 30px;
}

@keyframes result-pop {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 640px) {
  .lottery-app .result-panel {
    padding: 14px;
  }

  .lottery-app .result-list {
    min-height: 48px;
  }

  .lottery-app .pill {
    width: 100%;
    min-height: 46px;
    justify-content: center;
    text-align: center;
    font-size: 20px;
  }

  .lottery-app.focus-mode .result-panel {
    padding: 16px;
  }

  .lottery-app.focus-mode .pill {
    min-height: 52px;
    font-size: 24px;
  }
}

/* Keep the draw result visible without scrolling past the stage. */
.lottery-app .method-action-bar {
  margin-bottom: 10px;
}

.lottery-app .result-panel {
  position: sticky;
  top: 154px;
  z-index: 60;
  margin: 0 0 14px;
}

.lottery-app .stage {
  min-height: clamp(260px, 36dvh, 360px);
  padding: 16px;
}

.lottery-app .wheel-wrap {
  width: min(360px, 76vw);
}

.lottery-app .lot-box {
  min-height: clamp(160px, 28dvh, 240px);
}

.lottery-app .ghost-wrap {
  min-height: clamp(240px, 34dvh, 360px);
}

.lottery-app #ghostSvg {
  min-height: clamp(230px, 32dvh, 340px);
}

.lottery-app.focus-mode .result-panel {
  top: 150px;
  margin: 0 0 14px;
}

.lottery-app.focus-mode .stage {
  min-height: min(42dvh, 460px);
  padding: 18px;
}

.lottery-app.focus-mode .wheel-wrap {
  width: min(42dvh, 520px, 78vw);
}

.lottery-app.focus-mode .lot-box {
  min-height: min(30dvh, 300px);
}

.lottery-app.focus-mode .ghost-wrap {
  min-height: min(38dvh, 420px);
  height: min(38dvh, 420px);
}

.lottery-app.focus-mode #ghostSvg {
  min-height: min(36dvh, 390px);
  height: min(36dvh, 390px);
}

@media (max-width: 900px) {
  .lottery-app .result-panel {
    top: 148px;
  }
}

@media (max-width: 640px) {
  .lottery-app .result-panel {
    top: 142px;
    margin-bottom: 10px;
  }

  .lottery-app .stage {
    min-height: clamp(220px, 34dvh, 300px);
    padding: 10px;
  }

  .lottery-app .wheel-wrap {
    width: min(34dvh, calc(100vw - 64px));
  }

  .lottery-app .ghost-wrap {
    min-height: clamp(220px, 32dvh, 300px);
    height: clamp(220px, 32dvh, 300px);
  }

  .lottery-app #ghostSvg {
    min-height: clamp(220px, 30dvh, 290px);
    height: clamp(220px, 30dvh, 290px);
  }

  .lottery-app.focus-mode .result-panel {
    top: 136px;
  }

  .lottery-app.focus-mode .stage {
    min-height: 34dvh;
    padding: 10px;
  }

  .lottery-app.focus-mode .wheel-wrap {
    width: min(32dvh, calc(100vw - 64px));
  }
}

/* Draw layout: keep the stage large and move controls/results to the side. */
.lottery-app .draw-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 312px);
  grid-template-areas:
    "stage controls"
    "stage status";
  gap: 18px;
  align-items: stretch;
  min-width: 0;
}

.lottery-app .draw-stage-panel {
  grid-area: stage;
  min-width: 0;
  display: grid;
}

.lottery-app .draw-control-panel {
  grid-area: controls;
  min-width: 0;
  align-self: start;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #d8e2ef;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .08);
}

.lottery-app .draw-layout > .status {
  grid-area: status;
  min-width: 0;
  margin: 0;
}

.lottery-app .draw-layout > .ghost-picker {
  grid-column: 2;
  min-width: 0;
}

.lottery-app .draw-control-panel .method-head,
.lottery-app.focus-mode .draw-control-panel .method-head {
  margin: 0;
}

.lottery-app .draw-control-panel .method-head {
  display: block;
}

.lottery-app .draw-control-panel .method h2,
.lottery-app .draw-control-panel h2 {
  font-size: 20px;
}

.lottery-app .draw-control-panel .method-action-bar,
.lottery-app .draw-control-panel .result-panel,
.lottery-app.focus-mode .draw-control-panel .method-action-bar,
.lottery-app.focus-mode .draw-control-panel .result-panel {
  position: static;
  top: auto;
  z-index: auto;
  margin: 0;
}

.lottery-app .draw-control-panel .method-action-bar {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.lottery-app .draw-control-panel .result-panel {
  padding: 16px;
}

.lottery-app .draw-control-panel .result-list {
  min-height: 64px;
}

.lottery-app .draw-stage-panel .stage {
  width: 100%;
  min-height: clamp(460px, 62dvh, 760px);
  padding: clamp(14px, 2vw, 28px);
}

.lottery-app .draw-stage-panel .wheel-wrap {
  width: min(100%, 58dvh, 680px);
}

.lottery-app .draw-stage-panel .box-stage {
  width: min(820px, 100%);
}

.lottery-app .draw-stage-panel .lot-box {
  min-height: clamp(280px, 48dvh, 540px);
}

.lottery-app .draw-stage-panel .ghost-wrap {
  width: 100%;
  min-height: clamp(380px, 58dvh, 680px);
  height: auto;
}

.lottery-app .draw-stage-panel #ghostSvg {
  width: 100%;
  max-width: 100%;
  min-height: clamp(360px, 54dvh, 640px);
  height: auto;
}

.lottery-app.focus-mode .draw-layout {
  grid-template-columns: minmax(0, 1fr) minmax(250px, 312px);
  gap: 14px;
  min-height: calc(100dvh - 112px);
}

.lottery-app.focus-mode .draw-control-panel {
  max-height: calc(100dvh - 116px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lottery-app.focus-mode .draw-stage-panel .stage {
  min-height: calc(100dvh - 116px);
}

.lottery-app.focus-mode .draw-stage-panel .wheel-wrap {
  width: min(100%, calc(100dvh - 150px), 820px);
}

.lottery-app.focus-mode .draw-stage-panel .lot-box {
  min-height: min(62dvh, 600px);
}

.lottery-app.focus-mode .draw-stage-panel .ghost-wrap {
  min-height: calc(100dvh - 150px);
  height: auto;
}

.lottery-app.focus-mode .draw-stage-panel #ghostSvg {
  min-height: calc(100dvh - 170px);
  height: auto;
}

@media (max-width: 760px) {
  .lottery-app .draw-layout,
  .lottery-app.focus-mode .draw-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "controls"
      "stage"
      "status";
    gap: 12px;
    min-height: 0;
  }

  .lottery-app .draw-control-panel,
  .lottery-app.focus-mode .draw-control-panel {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 12px;
  }

  .lottery-app .draw-layout > .ghost-picker,
  .lottery-app.focus-mode .draw-layout > .ghost-picker {
    grid-column: 1;
  }

  .lottery-app .draw-stage-panel .stage,
  .lottery-app.focus-mode .draw-stage-panel .stage {
    min-height: clamp(260px, 44dvh, 380px);
  }

  .lottery-app .draw-stage-panel .wheel-wrap,
  .lottery-app.focus-mode .draw-stage-panel .wheel-wrap {
    width: min(42dvh, calc(100vw - 64px), 420px);
  }

  .lottery-app .draw-stage-panel .lot-box,
  .lottery-app.focus-mode .draw-stage-panel .lot-box {
    min-height: clamp(210px, 34dvh, 320px);
  }

  .lottery-app .draw-stage-panel .ghost-wrap,
  .lottery-app.focus-mode .draw-stage-panel .ghost-wrap,
  .lottery-app .draw-stage-panel #ghostSvg,
  .lottery-app.focus-mode .draw-stage-panel #ghostSvg {
    min-height: clamp(240px, 38dvh, 340px);
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  body.lottery-focus-mode {
    overflow: hidden;
  }

  .lottery-app.focus-mode {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    padding: 6px;
  }

  .lottery-app.focus-mode main {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    min-height: calc(100dvh - 12px);
  }

  .lottery-app.focus-mode .workspace {
    min-height: calc(100dvh - 12px);
    max-height: calc(100dvh - 12px);
    grid-template-rows: auto 1fr;
    overflow: hidden;
  }

  .lottery-app.focus-mode .tabs {
    position: static;
    padding: 6px;
  }

  .lottery-app.focus-mode .tab {
    min-height: 36px;
    padding: 8px 10px;
  }

  .lottery-app.focus-mode .method {
    min-height: 0;
    padding: 6px;
    overflow: hidden;
  }

  .lottery-app.focus-mode .draw-layout {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 34vw);
    grid-template-areas:
      "stage controls"
      "stage status";
    gap: 8px;
    height: calc(100dvh - 66px);
    min-height: 0;
    overflow: hidden;
  }

  .lottery-app.focus-mode #method-ghost .draw-layout {
    grid-template-columns: minmax(0, 1fr) minmax(252px, 38vw);
  }

  .lottery-app.focus-mode .draw-control-panel {
    max-height: 100%;
    overflow-y: auto;
    padding: 10px;
    gap: 8px;
  }

  .lottery-app.focus-mode .draw-layout > .ghost-picker {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    max-height: 48%;
    overflow-y: auto;
  }

  .lottery-app.focus-mode .method-head h2 {
    font-size: 18px;
  }

  .lottery-app.focus-mode .method-head p {
    display: none;
  }

  .lottery-app.focus-mode .draw-control-panel .method-action-bar {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .lottery-app.focus-mode .draw-control-panel .method-action-bar button {
    min-height: 40px;
    padding: 9px 10px;
  }

  .lottery-app.focus-mode .draw-control-panel .result-panel {
    padding: 12px;
  }

  .lottery-app.focus-mode .draw-control-panel .result-list {
    min-height: 48px;
  }

  .lottery-app.focus-mode .draw-control-panel .pill {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    font-size: 22px;
    text-align: center;
    justify-content: center;
  }

  .lottery-app.focus-mode .draw-stage-panel .stage {
    height: 100%;
    min-height: 0;
    padding: 8px;
  }

  .lottery-app.focus-mode .draw-stage-panel .wheel-wrap {
    width: min(100%, calc(100dvh - 92px), 500px);
  }

  .lottery-app.focus-mode .draw-stage-panel .box-stage {
    width: 100%;
  }

  .lottery-app.focus-mode .draw-stage-panel .lot-box {
    min-height: calc(100dvh - 110px);
    padding: 16px;
  }

  .lottery-app.focus-mode .draw-stage-panel .ghost-wrap,
  .lottery-app.focus-mode .draw-stage-panel #ghostSvg {
    min-height: calc(100dvh - 100px);
    height: calc(100dvh - 100px);
  }
}
