:root {
  color-scheme: light;
  --ink: #171717;
  --paper: #f7f3e8;
  --yellow: #ffdc3c;
  --yellow-deep: #f1bd00;
  --blue: #2667ff;
  --blue-soft: #dce7ff;
  --red: #ff5a4f;
  --line: #c9c4b9;
  --white: #fffefa;
  --shadow: 8px 8px 0 #171717;
  font-family: ui-rounded, "SF Pro Rounded", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 220, 60, .78) 0 12%, transparent 12.2%),
    linear-gradient(90deg, rgba(23,23,23,.045) 1px, transparent 1px),
    linear-gradient(rgba(23,23,23,.045) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 28px 28px, 28px 28px, auto;
  color: var(--ink);
}

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

.page-shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; }

.site-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 2px solid var(--ink);
}

.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.15rem; }
.brand-mark { width: 34px; height: 34px; border: 3px solid var(--ink); border-radius: 50%; background: var(--yellow); display: grid; place-items: center; position: relative; overflow: hidden; }
.brand-mark::before { content: ""; position: absolute; width: 100%; height: 3px; background: var(--ink); }
.brand-mark span { position: relative; width: 12px; height: 12px; background: var(--white); border: 3px solid var(--ink); border-radius: 50%; }
.unofficial { margin: 0; font-size: .875rem; font-weight: 700; color: #555149; }

.intro { padding: 70px 0 46px; }
.eyebrow, .preview-kicker { margin: 0 0 14px; font-size: .82rem; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.eyebrow { display: inline-block; background: var(--ink); color: white; padding: 8px 12px; transform: rotate(-1deg); }
h1 { margin: 0; max-width: 850px; font-size: clamp(3rem, 7.2vw, 7rem); line-height: .94; letter-spacing: -.065em; font-weight: 950; }
h1 span { color: var(--blue); }
.lede { max-width: 640px; margin: 28px 0 0; font-size: clamp(1rem, 1.5vw, 1.22rem); line-height: 1.75; font-weight: 650; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, .72fr); gap: 40px; align-items: start; padding-bottom: 80px; }
.controls { display: grid; gap: 26px; }
.selection-block, .preview-panel { background: var(--white); border: 3px solid var(--ink); box-shadow: var(--shadow); }
.selection-block { padding: clamp(20px, 3vw, 34px); }
.selection-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.selection-heading > div { display: flex; align-items: center; gap: 13px; }
.selection-heading h2, .preview-heading h2 { margin: 0; font-size: clamp(1.35rem, 2vw, 1.85rem); line-height: 1.15; }
.step { display: grid; place-items: center; width: 44px; height: 44px; border: 3px solid var(--ink); border-radius: 50%; background: var(--yellow); font-size: .8rem; font-weight: 950; }
.step-want { background: var(--blue-soft); }
.hint { margin: 12px 0 20px 57px; color: #6d685f; font-size: .92rem; font-weight: 650; }
.selection-actions { display: flex; align-items: center; gap: 14px; }
.select-button, .clear-button { border: 0; background: transparent; padding: 9px 0; font-size: .9rem; font-weight: 800; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.select-button { color: var(--blue); }
.clear-button { color: #68635a; }
.select-button:hover, .clear-button:hover { color: var(--ink); }
.number-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 8px; }
.number-button { aspect-ratio: 1; min-width: 0; border: 2px solid var(--ink); border-radius: 50%; background: transparent; color: var(--ink); font-weight: 900; cursor: pointer; transition: transform .12s ease, background .12s ease, color .12s ease; }
.number-button:hover { transform: translateY(-2px); }
.number-button:focus-visible, .primary-action:focus-visible, .secondary-action:focus-visible, .select-button:focus-visible, .clear-button:focus-visible { outline: 4px solid var(--red); outline-offset: 3px; }
[data-list="have"] .number-button[aria-pressed="true"] { background: var(--yellow); box-shadow: 2px 2px 0 var(--ink); transform: translate(-1px, -1px); }
[data-list="want"] .number-button[aria-pressed="true"] { background: var(--blue); color: white; box-shadow: 2px 2px 0 var(--ink); transform: translate(-1px, -1px); }

.preview-panel { position: sticky; top: 24px; padding: 24px; background: var(--ink); color: white; box-shadow: 8px 8px 0 var(--yellow-deep); }
.in-app-notice { margin: 0 0 20px; padding: 14px 16px; border: 2px solid var(--yellow); background: #292929; color: white; }
.in-app-notice strong { display: block; color: var(--yellow); font-size: .95rem; }
.in-app-notice p { margin: 6px 0 0; font-size: .88rem; line-height: 1.55; }
.preview-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 18px; }
.preview-kicker { color: var(--yellow); margin-bottom: 5px; }
.size-label { color: #c9c9c9; font-size: .76rem; font-weight: 800; }
.canvas-wrap { background: #333; overflow: hidden; line-height: 0; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; background: var(--paper); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.primary-action, .secondary-action { min-height: 54px; border: 2px solid white; font-weight: 900; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.primary-action { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.secondary-action { background: transparent; color: white; }
.primary-action:hover, .secondary-action:hover { transform: translateY(-2px); }
.primary-action:hover { box-shadow: 0 4px 0 var(--yellow-deep); }
.status { min-height: 1.4em; margin: 12px 0 0; color: #d6d6d6; text-align: center; font-size: .84rem; }
.save-dialog { width: min(620px, calc(100% - 24px)); max-height: calc(100svh - 24px); padding: 18px; border: 3px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 8px 8px 0 var(--ink); overflow: auto; }
.save-dialog::backdrop { background: rgba(23, 23, 23, .82); }
.save-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.save-dialog-header h2 { margin: 0; font-size: 1.5rem; }
.save-dialog .preview-kicker { color: var(--blue); margin-bottom: 5px; }
.dialog-close { width: 44px; height: 44px; flex: 0 0 auto; border: 2px solid var(--ink); border-radius: 50%; background: var(--white); color: var(--ink); font-size: 1.8rem; line-height: 1; cursor: pointer; }
.save-dialog img { display: block; width: auto; max-width: 100%; max-height: 65svh; margin: 0 auto; border: 2px solid var(--ink); object-fit: contain; -webkit-touch-callout: default; user-select: auto; }
.save-help { margin: 14px 0 0; font-size: .95rem; font-weight: 700; line-height: 1.6; }
.footer-note { border-top: 2px solid var(--ink); margin: 0; padding: 24px 0 36px; display: flex; justify-content: space-between; gap: 20px; font-size: .9rem; font-weight: 700; color: #5e594f; }
.footer-note p { margin: 0; }
.signature { color: var(--ink); font-weight: 900; white-space: nowrap; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { position: static; width: min(620px, 100%); justify-self: center; }
}

@media (max-width: 640px) {
  .page-shell { width: min(100% - 24px, 1440px); }
  .site-header { min-height: 70px; }
  .unofficial { max-width: 160px; text-align: right; font-size: .72rem; line-height: 1.35; }
  .intro { padding: 46px 0 34px; }
  h1 { font-size: clamp(2.75rem, 15vw, 4.3rem); }
  .lede { margin-top: 20px; }
  .workspace { gap: 28px; }
  .selection-block { padding: 18px 14px 22px; }
  .selection-heading h2 { font-size: 1.25rem; }
  .hint { margin-left: 0; }
  .number-grid { grid-template-columns: repeat(6, 1fr); gap: 8px; }
  .preview-panel { padding: 16px; }
  .preview-heading { align-items: start; }
  .size-label { display: none; }
  .canvas-wrap { display: flex; justify-content: center; max-height: 55svh; }
  .canvas-wrap canvas { width: auto; max-width: 100%; max-height: 55svh; }
  .actions { grid-template-columns: 1fr; }
  .footer-note { align-items: flex-start; flex-direction: column; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
