:root {
  color-scheme: dark;
  --bg: #090c18;
  --bg-soft: #10152a;
  --panel: rgba(20, 26, 48, 0.9);
  --panel-strong: #171e37;
  --line: rgba(177, 190, 229, 0.15);
  --text: #f5f7ff;
  --muted: #a5aec8;
  --accent: #92f0ca;
  --accent-2: #78a8ff;
  --red: #ff5964;
  --green: #43d48a;
  --blue: #4f8dff;
  --yellow: #ffd456;
  --purple: #b875ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  font-family: Inter, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 3%, rgba(80, 124, 255, 0.18), transparent 31rem),
    radial-gradient(circle at 92% 26%, rgba(71, 222, 164, 0.1), transparent 32rem),
    var(--bg);
}

button, input { font: inherit; }
button { color: inherit; }

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

.status-pill {
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 8px 12px;
}

.hero { padding: 76px 0 52px; max-width: 790px; }
.eyebrow, .section-number { margin: 0 0 15px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.18em; }
.hero h1 { margin: 0; font-size: clamp(42px, 7vw, 78px); line-height: 1.02; letter-spacing: -0.055em; }
.hero h1 em { color: transparent; font-style: normal; background: linear-gradient(90deg, #8eb3ff, #8cf0c3); background-clip: text; -webkit-background-clip: text; }
.hero-copy { margin: 28px 0 0; max-width: 650px; color: var(--muted); font-size: 15px; line-height: 1.9; }

.workspace { display: grid; grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.35fr); gap: 22px; align-items: stretch; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.search-panel { height: 720px; padding: 28px; }
.results-panel { height: 720px; min-height: 720px; display: flex; flex-direction: column; padding: 28px 0 0; overflow: hidden; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 28px; }
.panel-heading .section-number { margin-bottom: 6px; }
.panel-heading h2, .notes h2 { margin: 0; font-size: 24px; letter-spacing: -0.03em; }
.mode-indicator { display: flex; align-items: center; gap: 11px; margin-top: -4px; }
.mode-indicator .status-pill { width: 11em; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.curry-mode-icon {
  --curry-sauce: #bc7139;
  --curry-sauce-shade: #914b2e;
  --curry-steam: #e7b976;
  --curry-spice-opacity: 0.55;
  width: 58px;
  flex: 0 0 auto;
}
.curry-mode-icon[data-mode="3"] {
  --curry-sauce: #efbd51;
  --curry-sauce-shade: #d98b35;
  --curry-steam: #f5d98b;
  --curry-spice-opacity: 0.18;
}
.curry-mode-icon[data-mode="5"] {
  --curry-sauce: #a93f40;
  --curry-sauce-shade: #742d36;
  --curry-steam: #ff8a7a;
  --curry-spice-opacity: 1;
}
.curry-mode-icon svg { display: block; width: 100%; height: auto; overflow: visible; }
.curry-shadow { fill: rgba(3, 6, 15, 0.4); }
.curry-plate-rim { fill: #8190b0; }
.curry-plate { fill: #dce4f3; }
.curry-sauce, .curry-sauce-shade, .curry-steam, .curry-spice { transition: 180ms ease; }
.curry-sauce { fill: var(--curry-sauce); }
.curry-sauce-shade { fill: var(--curry-sauce-shade); opacity: 0.72; }
.curry-rice { fill: #f8f5e9; }
.curry-rice-line { fill: none; stroke: #d6d4cc; stroke-linecap: round; stroke-width: 1; opacity: 0.8; }
.curry-garnish { fill: #54b879; }
.curry-spice { fill: #ffcf62; opacity: var(--curry-spice-opacity); }
.curry-steam { fill: none; stroke: var(--curry-steam); stroke-linecap: round; stroke-width: 2; opacity: 0.7; }
.curry-steam-late { opacity: 0.45; }
.status-pill.ready { color: var(--accent); border-color: rgba(146, 240, 202, 0.35); }
.status-pill.error { color: #ff9ca3; border-color: rgba(255, 89, 100, 0.35); }

.control-group { border: 0; padding: 0; margin: 0 0 24px; }
.control-group legend { display: flex; justify-content: space-between; width: 100%; margin-bottom: 10px; font-size: 13px; font-weight: 750; }
.input-label-row { display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 10px; }
.input-label-row > label:first-child { flex: 0 0 auto; font-size: 13px; font-weight: 750; }
.input-order { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap; }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; padding: 5px; background: rgba(6, 9, 21, 0.72); border: 1px solid var(--line); border-radius: 12px; }
.segmented-modes { grid-template-columns: repeat(3, 1fr); }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 10px 12px; color: var(--muted); text-align: center; border-radius: 8px; font-size: 13px; font-weight: 700; transition: 150ms ease; }
.segmented input:checked + span { color: #07150f; background: var(--accent); box-shadow: 0 5px 20px rgba(120, 232, 184, 0.18); }
.segmented input:focus-visible + span { outline: 2px solid white; outline-offset: 2px; }
.hint { margin: 9px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.mode-hint-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.mode-hint-row .hint { min-width: 0; }
.number-search-trigger { flex: 0 0 auto; margin-top: 9px; padding: 0; color: var(--accent); background: transparent; border: 0; cursor: pointer; font-size: 11px; font-weight: 750; line-height: 1.6; white-space: nowrap; }
.number-search-trigger:hover { color: #b9ffe0; }

.text-input-wrap { position: relative; }
.text-input-wrap input { width: 100%; height: 54px; padding: 0 82px 0 16px; color: var(--text); text-transform: lowercase; letter-spacing: 0.13em; background: rgba(7, 10, 23, 0.8); border: 1px solid var(--line); border-radius: 12px; outline: none; }
.text-input-wrap input.pattern-input { text-transform: uppercase; }
.text-input-wrap input:focus { border-color: rgba(146, 240, 202, 0.64); box-shadow: 0 0 0 3px rgba(146, 240, 202, 0.08); }
.text-input-wrap b { position: absolute; top: 50%; right: 14px; transform: translateY(-50%); color: var(--muted); font-size: 10px; }
.input-error { min-height: 18px; margin: 7px 2px 0; color: #ff9ca3; font-size: 11px; }

.color-pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 24px; }
.color-key { min-height: 54px; display: flex; gap: 6px; align-items: center; justify-content: center; background: var(--panel-strong); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-size: 12px; font-weight: 800; transition: transform 120ms ease, border-color 120ms ease, background 120ms ease; }
.color-key:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.3); background: #1d2746; }
.color-key:active { transform: translateY(0); }
.color-key:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pattern-key { font-size: 18px; }

.query-preview-wrap { padding: 15px; background: rgba(7, 10, 23, 0.58); border: 1px solid var(--line); border-radius: 14px; }
.preview-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.preview-label span { font-size: 11px; font-weight: 750; }
.preview-label small { color: var(--muted); font-size: 9px; }
.pair-strip { min-height: 54px; display: flex; gap: 7px; align-items: flex-end; overflow-x: auto; padding: 2px 1px 7px; scrollbar-width: thin; }
.pair-strip.empty { align-items: center; color: #65708f; font-size: 11px; }
.pair { flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px; align-items: center; }
.pair.partial { opacity: 0.72; }
.puyo, .mini-puyo { position: relative; display: inline-grid; place-items: center; border-radius: 48% 52% 50% 50%; box-shadow: inset -3px -4px 6px rgba(0,0,0,0.16), 0 4px 12px rgba(0,0,0,0.22); }
.puyo::after, .mini-puyo::after { content: ""; position: absolute; width: 34%; height: 24%; left: 18%; top: 13%; border-radius: 50%; background: rgba(255,255,255,0.48); filter: blur(0.5px); }
.puyo { width: 24px; height: 24px; }
.mini-puyo { width: 21px; height: 21px; }
.puyo-r { background: var(--red); }
.puyo-g { background: var(--green); }
.puyo-b { background: var(--blue); }
.puyo-y { background: var(--yellow); }
.puyo-p { background: var(--purple); }
.pattern-puyo { color: #0a1020; background: #dfe6fa; font-size: 10px; font-weight: 900; }
.pattern-a { background: #ff8c94; }
.pattern-b { background: #7ae0ab; }
.pattern-c { background: #86adff; }
.pattern-d { background: #ffe27c; }
.pattern-e { background: #ce9cff; }
.placeholder-puyo { border: 1px dashed #4a5472; background: transparent; box-shadow: none; }
.placeholder-puyo::after { display: none; }

.check-row { display: flex; align-items: center; gap: 10px; color: var(--muted); cursor: pointer; font-size: 12px; }
.check-row-inline { gap: 6px; font-size: 11px; white-space: nowrap; }
.check-row-inline .fake-check { width: 17px; height: 17px; border-radius: 5px; }
.check-row-inline .fake-check::after { font-size: 11px; }
.check-row input { position: absolute; opacity: 0; }
.fake-check { width: 19px; height: 19px; display: grid; place-items: center; border: 1px solid #4d5877; border-radius: 6px; }
.check-row input:checked + .fake-check { background: var(--accent); border-color: var(--accent); }
.check-row input:checked + .fake-check::after { content: "✓"; color: #07150f; font-size: 13px; font-weight: 900; }
.check-row input:focus-visible + .fake-check { outline: 2px solid white; outline-offset: 2px; }
.results-heading-row { padding: 0 28px; }
.result-counter { text-align: right; }
.result-counter strong { display: block; font-size: 26px; line-height: 1; }
.result-counter span { color: var(--muted); font-size: 10px; }
.result-summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 28px 17px; padding: 13px 15px; color: var(--muted); background: rgba(7,10,23,0.55); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; line-height: 1.55; }
.result-click-hint { flex: 0 0 auto; color: var(--accent); font-size: 11px; font-weight: 700; white-space: nowrap; }
.results-list { min-height: 0; flex: 1; overflow-y: auto; border-top: 1px solid var(--line); }
.results-list > .empty-state { height: 100%; }
.result-card { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 14px; align-items: center; min-height: 91px; padding: 16px 24px 16px 28px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background 140ms ease; }
.result-card:hover { background: rgba(114, 143, 218, 0.1); }
.result-card:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; background: rgba(114, 143, 218, 0.1); }
.seed-identity strong { display: block; font-size: 15px; }
.seed-identity span { display: block; margin-top: 5px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; }
.result-pairs { min-height: 52px; padding-bottom: 0; }
.open-deck-label { flex: 0 0 auto; align-self: center; margin-left: auto; padding: 10px 12px; color: var(--accent); border: 1px solid rgba(146, 240, 202, 0.28); border-radius: 9px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.empty-state { min-height: 330px; display: grid; place-content: center; justify-items: center; color: #687493; font-size: 12px; text-align: center; }
.empty-orbit { position: relative; width: 75px; height: 58px; border: 1px solid var(--line); border-radius: 50%; transform: rotate(-18deg); }
.empty-orbit .puyo, .empty-orbit .mini-puyo { position: absolute; }
.empty-orbit .puyo:first-child, .empty-orbit .mini-puyo:first-child { left: -5px; top: 17px; }
.empty-orbit .puyo:last-child, .empty-orbit .mini-puyo:last-child { right: -4px; bottom: 10px; }

.notes { padding: 92px 0 72px; }
.notes h2 { font-size: 30px; }
.note-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 25px; }
.note-grid article { padding: 24px; background: rgba(16, 21, 42, 0.72); border: 1px solid var(--line); border-radius: 16px; }
.note-grid strong { color: var(--accent-2); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; letter-spacing: 0.08em; }
.note-grid h3 { margin: 18px 0 8px; font-size: 15px; line-height: 1.5; }
.note-grid p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.75; }
.note-grid p + p, .note-grid p + ul { margin-top: 10px; }
.note-grid ul { margin: 10px 0 0; padding-left: 1.4em; color: var(--muted); font-size: 12px; line-height: 1.75; }
.note-grid li + li { margin-top: 3px; }
.note-grid li::marker { color: var(--accent-2); }
footer { display: flex; justify-content: space-between; align-items: flex-start; gap: 28px; padding: 24px 0 34px; color: #68728d; border-top: 1px solid var(--line); font-size: 10px; line-height: 1.65; }
footer p { margin: 0; }
.footer-info { display: grid; gap: 3px; }
.footer-disclaimer { max-width: 520px; text-align: right; }

.modal-open { overflow: hidden; }
.number-dialog {
  width: min(460px, calc(100vw - 32px));
  max-width: none;
  padding: 0;
  color: var(--text);
  background: #11172c;
  border: 1px solid rgba(177, 190, 229, 0.25);
  border-radius: 20px;
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.68);
  overflow: hidden;
}
.number-dialog::backdrop, .deck-dialog::backdrop { background: rgba(3, 5, 13, 0.78); backdrop-filter: blur(8px); }
.number-dialog-shell { padding: 24px; }
.number-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.number-dialog-label { margin: 0 0 7px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 0.13em; }
.number-dialog-header h2 { margin: 0; font-size: 24px; letter-spacing: -0.035em; }
.number-dialog-copy { margin: 20px 0 0; color: var(--muted); font-size: 12px; line-height: 1.75; }
.number-search-form { display: grid; margin-top: 21px; }
.number-search-form > label { margin-bottom: 8px; font-size: 12px; font-weight: 750; }
.number-mode-fieldset { min-width: 0; margin: 0 0 18px; padding: 0; border: 0; }
.number-mode-fieldset legend { margin-bottom: 8px; font-size: 12px; font-weight: 750; }
.number-mode-switch span { padding-inline: 7px; font-size: 11px; }
#number-search-input { width: 100%; padding: 13px 14px; color: var(--text); background: rgba(7, 10, 23, 0.72); border: 1px solid var(--line); border-radius: 10px; outline: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 16px; }
#number-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(146, 240, 202, 0.1); }
#number-search-input::placeholder { color: #5f6b8b; }
.number-search-help { margin: 9px 1px 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.number-search-error { min-height: 18px; margin: 7px 1px 0; color: #ff9ca3; font-size: 11px; line-height: 1.6; }
.number-search-submit { margin-top: 8px; padding: 12px 16px; color: #07150f; background: var(--accent); border: 0; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 800; }
.number-search-submit:hover { background: #b9ffe0; }
.deck-dialog {
  width: min(1040px, calc(100vw - 36px));
  max-width: none;
  max-height: min(900px, calc(100dvh - 36px));
  padding: 0;
  color: var(--text);
  background: #11172c;
  border: 1px solid rgba(177, 190, 229, 0.25);
  border-radius: 22px;
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.68);
  overflow: hidden;
}
.deck-dialog:focus { outline: none; }
.deck-dialog-shell { max-height: min(900px, calc(100dvh - 36px)); overflow-y: auto; }
.deck-dialog-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px 20px;
  background: rgba(17, 23, 44, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.deck-dialog-heading { min-width: 135px; margin-right: auto; }
.deck-mode-label { margin: 0 0 5px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 0.13em; }
.deck-dialog-header h2 { margin: 0; font-size: 28px; letter-spacing: -0.035em; }
.deck-meta { margin: 5px 0 0; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }
.deck-mode-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 4px; background: rgba(6, 9, 21, 0.72); border: 1px solid var(--line); border-radius: 11px; }
.deck-mode-switch button { min-width: 58px; padding: 8px 12px; color: var(--muted); background: transparent; border: 0; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 750; transition: 150ms ease; }
.deck-mode-switch button:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.deck-mode-switch button.active { color: #07150f; background: var(--accent); box-shadow: 0 5px 20px rgba(120, 232, 184, 0.14); }
.deck-close-button { width: 40px; height: 40px; flex: 0 0 auto; color: var(--muted); background: #1c2542; border: 1px solid var(--line); border-radius: 50%; cursor: pointer; font-size: 23px; line-height: 1; }
.full-deck { display: grid; grid-template-columns: repeat(16, minmax(46px, 1fr)); gap: 7px; padding: 24px 28px 28px; }
.full-deck-hand { min-width: 0; display: grid; justify-items: center; gap: 5px; padding: 8px 3px; background: rgba(7, 10, 23, 0.54); border: 1px solid var(--line); border-radius: 10px; }
.full-deck-hand .pair { gap: 1px; }
.full-deck-hand .puyo { width: 22px; height: 22px; }
.hand-number { color: #6f7b9b; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 8px; font-variant-numeric: tabular-nums; }
.deck-text-details { margin: 0 28px 28px; padding: 14px 16px; background: rgba(7, 10, 23, 0.54); border: 1px solid var(--line); border-radius: 12px; }
.deck-text-label { margin: 0; color: var(--muted); font-size: 10px; font-weight: 700; }
.deck-text-details code { display: block; margin-top: 12px; color: #cbd4ec; overflow-wrap: anywhere; font-size: 10px; line-height: 1.65; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .search-panel { height: auto; }
  .results-panel { height: auto; min-height: 610px; display: block; }
  .results-list { max-height: 575px; }
  .hero { padding-top: 58px; }
  .full-deck { grid-template-columns: repeat(10, minmax(46px, 1fr)); }
}

@media (max-width: 620px) {
  .site-shell { width: min(100% - 24px, 1180px); }
  .hero { padding: 48px 2px 35px; }
  .hero h1 { font-size: clamp(38px, 13vw, 58px); }
  .hero-copy { font-size: 13px; }
  .search-panel { padding: 20px; }
  .search-panel > .panel-heading { gap: 8px; }
  .mode-indicator { gap: 6px; }
  .curry-mode-icon { width: 40px; }
  .mode-indicator .status-pill { padding: 7px 9px; font-size: 9px; }
  .mode-hint-row { align-items: flex-end; gap: 8px; }
  .number-search-trigger { white-space: normal; text-align: right; }
  .results-panel { padding-top: 22px; border-radius: 18px; }
  .results-heading-row { padding: 0 20px; }
  .result-summary { margin-inline: 20px; }
  .result-summary { align-items: flex-start; flex-direction: column; gap: 5px; }
  .result-click-hint { white-space: normal; }
  .color-pad { gap: 5px; }
  .color-key { min-height: 49px; }
  .result-card { grid-template-columns: 92px minmax(0, 1fr); padding: 15px 18px 15px 20px; }
  .open-deck-label { display: none; }
  .result-pairs .pair:nth-child(n+7) { display: none; }
  .deck-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 16px; }
  .number-dialog { width: calc(100vw - 16px); border-radius: 16px; }
  .number-dialog-shell { padding: 20px 18px; }
  .number-dialog-header h2 { font-size: 21px; }
  .deck-dialog-shell { max-height: calc(100dvh - 16px); }
  .deck-dialog-header { display: grid; grid-template-columns: 1fr auto; gap: 14px 12px; padding: 18px 17px 15px; }
  .deck-dialog-heading { grid-column: 1; grid-row: 1; margin-right: 0; }
  .deck-mode-switch { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .deck-mode-switch button { min-width: 0; }
  .deck-dialog-header .deck-close-button { grid-column: 2; grid-row: 1; }
  .deck-dialog-header h2 { font-size: 23px; }
  .deck-close-button { width: 36px; height: 36px; }
  .full-deck { grid-template-columns: repeat(5, minmax(48px, 1fr)); gap: 6px; padding: 16px 17px 20px; }
  .full-deck-hand { padding-block: 7px; }
  .deck-text-details { margin: 0 17px 20px; }
  .note-grid { grid-template-columns: 1fr; }
  .notes { padding: 68px 0 55px; }
  footer { flex-direction: column; }
  .footer-disclaimer { max-width: none; text-align: left; }
}

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