:root {
  --ink: #20262b;
  --muted: #667078;
  --cream: #f1f2f0;
  --paper: #ffffff;
  --line: #d4d8d8;
  --green: #294f59;
  --lime: #e6b85c;
  --orange: #a14f35;
  --blue: #4a8eb8;
  --violet: #7a71a8;
  --tile: #edddb9;
  --shadow: 0 8px 24px rgba(28, 37, 41, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: #f1f2f0;
  font-family: Manrope, Arial, sans-serif;
  min-height: 100vh;
}
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.page-shell { width: min(1440px, 100%); margin: auto; overflow: hidden; }
.topbar {
  height: 66px;
  padding: 0 clamp(24px, 5vw, 76px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(20, 35, 29, .12);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; font-weight: 800; letter-spacing: -.04em; font-size: 21px; }
.brand-mark { display: flex; align-items: flex-end; }
.brand-mark i {
  width: 29px; height: 32px; display: grid; place-items: center; font-style: normal;
  font-family: "DM Mono", monospace; font-size: 14px; color: var(--ink);
  background: var(--tile); border: 1px solid #cfbd95; box-shadow: 0 3px 0 #c9b58a;
}
.brand-mark i:last-child { margin-left: -3px; transform: translateY(2px); background: #d7e3df; border-color: #aebfba; }
.topbar-meta { display: flex; gap: 12px; align-items: center; }
.privacy-pill { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); padding: 8px 11px; border-radius: 999px; background: rgba(255,255,255,.45); }
.privacy-pill span { width: 7px; height: 7px; border-radius: 50%; background: #57a464; box-shadow: 0 0 0 3px rgba(87,164,100,.15); }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; font-weight: 800; }
.hero { padding: 46px clamp(24px, 8vw, 120px) 42px; position: relative; border-bottom: 1px solid var(--line); background: #f7f7f4; }
.eyebrow, .section-number { font-family: "DM Mono", monospace; font-size: 11px; font-weight: 500; letter-spacing: .14em; color: var(--orange); }
.hero h1 { margin: 14px 0 14px; font-size: clamp(36px, 5vw, 60px); line-height: 1.04; letter-spacing: -.045em; max-width: 760px; }
.hero > p { color: var(--muted); max-width: 590px; line-height: 1.7; font-size: 17px; }
.hero-stats { display: flex; gap: 24px; margin-top: 24px; color: var(--muted); font-size: 12px; }
.hero-stats span { padding-right: 28px; border-right: 1px solid var(--line); }
.hero-stats span:last-child { border: 0; }
.hero-stats strong { color: var(--ink); }
.workspace { background: #303b40; padding: 30px clamp(16px, 4vw, 62px) 60px; position: relative; }
.stepper { position: relative; display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 30px; }
.stepper i { width: 90px; height: 1px; background: rgba(255,255,255,.22); }
.step { border: 0; background: none; color: rgba(255,255,255,.52); display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 12px; font-weight: 700; }
.step b { width: 27px; height: 27px; border-radius: 50%; border: 1px solid currentColor; display: grid; place-items: center; font-family: "DM Mono"; font-size: 10px; }
.step.active { color: white; }
.step.active b { background: var(--lime); color: var(--ink); border-color: var(--lime); }
.workspace-grid { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; max-width: 1190px; margin: auto; align-items: start; }
.panel { background: var(--paper); border: 1px solid #dfe2e1; border-radius: 2px; box-shadow: var(--shadow); }
.board-panel { padding: clamp(20px, 3vw, 38px); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; }
.panel-heading h2, .results-heading h2 { font-size: 27px; letter-spacing: -.045em; margin: 4px 0; }
.panel-heading p, .results-heading p { color: var(--muted); font-size: 13px; margin: 0; }
.panel-heading.compact { align-items: center; margin-bottom: 20px; }
.panel-heading.compact h2 { font-size: 21px; margin-bottom: 0; }
.text-button { border: 0; border-bottom: 1px solid var(--ink); padding: 3px 0; background: none; cursor: pointer; font-size: 11px; font-weight: 700; }
.upload-zone { border: 1px dashed #aeb5b5; background: #f5f6f5; min-height: 145px; display: grid; place-items: center; cursor: pointer; position: relative; overflow: hidden; transition: .2s; }
.upload-zone.dragging { border-color: var(--green); background: #f0f6e3; }
.upload-empty { display: grid; place-items: center; gap: 5px; text-align: center; }
.upload-empty strong { font-size: 13px; }
.upload-empty span { color: var(--muted); font-size: 11px; }
.upload-icon { width: 36px; height: 36px; border: 1px solid var(--line); display: grid; place-items: center; background: white; margin-bottom: 4px; }
.upload-icon svg, .solve-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.screenshot-stage { width: 100%; height: 360px; background: #d9dbd5; position: relative; display: grid; place-items: center; overflow: hidden; touch-action: none; cursor: grab; }
.screenshot-stage.gesture-active { cursor: grabbing; }
.screenshot-stage img { width: 100%; height: 100%; object-fit: contain; }
.crop-box {
  position: absolute; border: 2px solid #f0c564; box-shadow: 0 0 0 999px rgba(12,25,20,.38);
  pointer-events: none; display: grid; place-items: start center;
  background-image:
    repeating-linear-gradient(90deg, transparent 0, transparent calc(6.6667% - 1px), rgba(213,243,107,.5) calc(6.6667% - 1px), rgba(213,243,107,.5) 6.6667%),
    repeating-linear-gradient(0deg, transparent 0, transparent calc(6.6667% - 1px), rgba(213,243,107,.5) calc(6.6667% - 1px), rgba(213,243,107,.5) 6.6667%);
}
.crop-box.fitted-grid { background-image: none; }
.detected-grid-line { position: absolute; background: rgba(213,243,107,.58); }
.detected-grid-line.vertical { top: 0; bottom: 0; width: 1px; }
.detected-grid-line.horizontal { left: 0; right: 0; height: 1px; }
.crop-box span { background: var(--lime); color: var(--ink); font: 500 9px "DM Mono"; padding: 3px 6px; transform: translateY(-100%); }
.scan-controls { padding: 14px; display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; background: #f3f4f3; border: 1px solid var(--line); border-top: 0; }
.scan-controls .text-button { color: #25343a; border-bottom-color: #25343a; }
.scan-action,
.scan-controls .scan-action { background: #234650; border-color: #18343c; color: #ffffff; }
.scan-status { display: grid; gap: 2px; }
.scan-status strong { color: #18262c; font-size: 11px; font-weight: 800; }
.scan-status span { color: #48575d; font-size: 10px; font-weight: 600; }
.manual-crop { grid-column: 1 / -1; padding-top: 9px; border-top: 1px solid var(--line); color: #3f5057; font-size: 10px; font-weight: 600; text-align: center; }
.divider { height: 44px; display: flex; align-items: center; gap: 12px; color: #858c87; font: 500 9px "DM Mono"; letter-spacing: .12em; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.board-wrap { max-width: 650px; margin: auto; }
.board-row { display: flex; }
.board-coordinates { display: grid; color: #818a84; font: 500 8px "DM Mono"; }
.board-coordinates.columns { grid-template-columns: repeat(15, 1fr); margin-left: 18px; height: 15px; }
.board-coordinates.rows { grid-template-rows: repeat(15, 1fr); width: 18px; }
.board-coordinates span { display: grid; place-items: center; }
.game-board { flex: 1; display: grid; grid-template-columns: repeat(15, 1fr); aspect-ratio: 1; background: #d4d6cc; border: 3px solid var(--ink); gap: 1px; padding: 1px; }
.cell { border: 0; padding: 0; min-width: 0; position: relative; background: #e8e5dc; cursor: pointer; color: rgba(20,35,29,.5); font: 500 clamp(5px, .65vw, 8px) "DM Mono"; text-transform: uppercase; }
.cell.tw { background: #e67952; color: #6e2e17; }
.cell.dw { background: #e5aa8e; color: #763c28; }
.cell.tl { background: #8099be; color: #263d63; }
.cell.dl { background: #a7c7d6; color: #345d70; }
.cell.center::after { content: "◆"; font-size: 10px; }
.cell.selected { outline: 3px solid var(--lime); z-index: 2; }
.cell.has-tile { background: var(--tile); box-shadow: inset 0 -3px 0 #c9b58a; color: var(--ink); border: 1px solid #c8b584; font-family: Manrope; font-size: clamp(10px, 1.7vw, 21px); font-weight: 800; }
.cell.has-tile::before { content: attr(data-letter); }
.cell.has-tile::after { content: attr(data-value); position: absolute; right: 9%; bottom: 6%; font: 700 clamp(5px, .55vw, 7px) Manrope; }
.cell.preview-tile { background: var(--lime); box-shadow: inset 0 -3px 0 #a9c53f; border-color: #9eb638; }
.cell.uncertain-tile { background: #ffd17a; box-shadow: inset 0 -3px 0 #d69a32; border: 1px solid #c98920; color: #694710; font-size: clamp(10px, 1.7vw, 21px); font-weight: 800; }
.cell.uncertain-tile::before { content: "?"; }
.board-legend { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin-top: 18px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.board-legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; display: inline-block; }
.legend-dot.tw { background: #e67952; }.legend-dot.dw { background: #e5aa8e; }.legend-dot.tl { background: #8099be; }.legend-dot.dl { background: #a7c7d6; }
.board-hint { color: var(--muted); text-align: center; font-size: 10px; margin: 10px 0 0; }
.board-edit-control { max-width: 390px; margin: 17px auto 0; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.board-edit-control label { display: grid; gap: 4px; color: var(--muted); font: 500 9px "DM Mono"; text-transform: uppercase; letter-spacing: .06em; }
.board-edit-control input { height: 42px; min-width: 0; border: 2px solid var(--green); background: white; color: var(--ink); text-align: center; text-transform: uppercase; font-size: 20px; font-weight: 800; outline: 0; }
.board-edit-control .secondary-button { height: 42px; }
.side-column { display: grid; gap: 18px; }
.rack-panel, .dictionary-panel { padding: 25px; }
.count-badge { background: #ecece5; color: var(--muted); border-radius: 99px; padding: 5px 9px; font: 500 9px "DM Mono"; }
.rack-inputs { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.rack-inputs input { min-width: 0; width: 100%; aspect-ratio: .82; text-align: center; text-transform: uppercase; border: 1px solid #cfbd95; border-radius: 2px; background: var(--tile); color: var(--ink); font-size: 20px; font-weight: 800; box-shadow: 0 3px 0 #c9b58a; outline: 0; }
.rack-inputs input:focus { border: 2px solid var(--green); }
.rack-panel > p, .dictionary-panel > p { color: var(--muted); font-size: 10px; line-height: 1.55; margin: 15px 0 0; }
code { font-family: "DM Mono"; background: #ecece5; border-radius: 2px; padding: 1px 4px; }
.status-dot { width: 8px; height: 8px; background: #66a86b; border-radius: 50%; box-shadow: 0 0 0 4px rgba(102,168,107,.13); }
.dictionary-current { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.file-mark { width: 38px; height: 43px; background: var(--green); color: white; display: grid; place-items: center; font: 500 9px "DM Mono"; clip-path: polygon(0 0, 72% 0, 100% 25%, 100% 100%, 0 100%); }
.dictionary-current div:last-child { display: grid; gap: 3px; }
.dictionary-current strong { font-size: 12px; }
.dictionary-current span { color: var(--muted); font: 400 9px "DM Mono"; }
.secondary-button { min-height: 38px; display: inline-flex; justify-content: center; align-items: center; border: 1px solid var(--ink); background: transparent; padding: 0 15px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; cursor: pointer; }
.file-button { width: 100%; }
.solve-button { height: 56px; border: 1px solid #182f36; background: var(--green); color: white; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; cursor: pointer; font-weight: 800; box-shadow: none; transition: .18s; }
.solve-button:hover { background: #213f48; }
.solve-button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.solve-note { color: rgba(255,255,255,.6); text-align: center; font-size: 10px; margin: -4px 0 0; }
.results-section { padding: 74px clamp(20px, 6vw, 90px) 90px; background: var(--cream); }
.results-heading { max-width: 1190px; margin: 0 auto 26px; display: flex; justify-content: space-between; align-items: end; }
.results-layout { max-width: 1190px; margin: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.move-list { display: grid; gap: 9px; align-content: start; }
.move-card { width: 100%; border: 1px solid var(--line); background: var(--paper); padding: 15px 18px; display: grid; grid-template-columns: 32px 1fr auto; gap: 14px; align-items: center; text-align: left; cursor: pointer; }
.move-card.active { border: 2px solid var(--green); background: #f3f8e7; padding: 14px 17px; }
.move-rank { color: var(--muted); font: 500 10px "DM Mono"; }
.move-word { font-size: 18px; font-weight: 800; letter-spacing: .08em; }
.move-meta { color: var(--muted); font-size: 9px; margin-top: 3px; text-transform: uppercase; }
.move-score { font: 500 24px "DM Mono"; color: var(--green); }
.move-score small { font-size: 8px; display: block; text-align: right; color: var(--muted); }
.move-detail { padding: 28px; min-height: 380px; position: sticky; top: 20px; }
.detail-score { font: 500 54px "DM Mono"; color: var(--green); line-height: 1; }
.detail-score span { font-size: 11px; color: var(--muted); }
.detail-title { display: flex; align-items: end; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 20px; }
.detail-title h3 { font-size: 29px; letter-spacing: .08em; margin: 0; }
.score-lines { display: grid; gap: 9px; font-size: 11px; }
.score-lines div { display: flex; justify-content: space-between; }
.score-lines .total { border-top: 1px solid var(--line); padding-top: 10px; font-weight: 800; }
.mini-board { display: grid; grid-template-columns: repeat(15, 1fr); gap: 1px; background: #d4d6cc; border: 2px solid var(--ink); margin-top: 22px; }
.mini-cell { aspect-ratio: 1; background: #e8e5dc; font-size: 0; }
.mini-cell.existing { background: #cab98e; }
.mini-cell.new { background: var(--lime); }
footer { padding: 28px clamp(24px, 5vw, 76px); display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; background: #e8e6de; }
dialog { width: min(520px, calc(100% - 30px)); border: 0; padding: 38px; box-shadow: 0 30px 90px rgba(0,0,0,.25); color: var(--ink); }
dialog::backdrop { background: rgba(11,30,23,.7); backdrop-filter: blur(3px); }
dialog h2 { font-size: 28px; letter-spacing: -.04em; }
dialog li, dialog p { color: var(--muted); font-size: 13px; line-height: 1.7; margin-bottom: 9px; }
.dialog-close { position: absolute; right: 16px; top: 12px; border: 0; background: none; font-size: 25px; cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: 25px; transform: translate(-50%, 120px); background: var(--ink); color: white; padding: 12px 18px; font-size: 11px; z-index: 20; transition: .25s; box-shadow: var(--shadow); }
.toast.show { transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .workspace-grid, .results-layout { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: 1fr 1fr; }
  .solve-button, .solve-note { grid-column: 1 / -1; }
  .hero::after { display: none; }
  .move-detail { position: static; }
}
@media (max-width: 600px) {
  .hero { padding-top: 54px; }
  .hero-stats { gap: 8px 14px; flex-wrap: wrap; }
  .hero-stats span { padding-right: 14px; }
  .side-column { grid-template-columns: 1fr; }
  .solve-button, .solve-note { grid-column: auto; }
  .stepper { gap: 6px; }
  .stepper i { width: 18px; }
  .step { gap: 5px; padding: 0; }
  .scan-controls { grid-template-columns: 1fr auto; }
  .scan-controls .secondary-button { grid-column: 1 / -1; }
  .board-panel { padding: 17px 10px 24px; }
  .panel-heading { padding: 0 8px; }
  .board-legend { gap: 8px; }
  .results-heading { align-items: flex-start; gap: 16px; }
  footer { display: grid; gap: 8px; }
}
