*, *::before, *::after { box-sizing: border-box; }
:root { color-scheme: light; --bg: #f4f5f0; --paper: #fff; --ink: #1e302c; --muted: #68756e; --line: #e3e8e0; --green: #245b49; --green-hover: #194634; --mint: #e7f0df; --lime: #d9efb4; --danger: #ab3e36; --radius: 20px; accent-color: var(--green); }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.5; min-width: 280px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
button, a { touch-action: manipulation; }
:focus-visible { outline: 3px solid #8abd67; outline-offset: 4px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; border: 0 !important; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.header { border-bottom: 1px solid var(--line); }
.header-inner, .main, .footer { max-width: 1160px; margin: 0 auto; }
.header-inner { min-height: 88px; padding: 18px 32px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 22px; font-weight: 750; letter-spacing: -.8px; line-height: 1.15; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; background: var(--green); color: #edf4e9; display: grid; place-items: center; }
.brand-mark .icon { width: 28px; height: 28px; }
.brand-light { font-weight: 400; }
.brand small { display: block; margin-top: 6px; font-size: 8px; font-weight: 650; letter-spacing: 1.9px; color: var(--muted); }
.status-pill { border: 1px solid var(--line); border-radius: 30px; min-height: 36px; background: #fff9; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.status-dot, .status-indicator-dot { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: #8c9b93; }
.status-pill.online { color: var(--green); background: #e9f0e5; border-color: #dce7d6; }
.status-pill.online .status-dot { background: #478751; }
.status-pill.offline { color: var(--danger); }
.status-pill.offline .status-dot { background: var(--danger); }
.status-pill.connecting .status-dot { background: #b1903c; }
.main { padding: 34px 32px 36px; }
.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.eyebrow { color: var(--muted); font-size: 9px; letter-spacing: 2px; font-weight: 650; margin-bottom: 11px; }
h1 { font-size: clamp(27px, 3.5vw, 39px); font-weight: 700; line-height: 1.15; letter-spacing: -1.6px; }
h1 span { color: #789166; font-weight: 400; }
.intro-description { color: var(--muted); font-size: 12px; line-height: 1.7; padding-bottom: 2px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.38fr) minmax(0, 1fr); align-items: start; gap: 24px; }
.camera-panel, .card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.camera-panel { padding: 20px; min-width: 0; }
.panel-heading, .card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-heading { margin-bottom: 16px; }
h2 { font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 8px; letter-spacing: -.15px; }
h2 .icon { width: 17px; height: 17px; flex-basis: 17px; color: #7b8a80; }
.frame-ratio { color: #97a095; font-size: 8px; font-weight: 600; letter-spacing: 1.3px; }
.camera-frame { position: relative; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 13px; background: #182521; isolation: isolate; }
#cameraFeed, #photoPreview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
#moveOverlay { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; overflow: visible; }
.frame-move-label { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 28px); padding: 8px 14px; border: 1px solid #d9efb440; border-radius: 9px; background: #163326ed; color: #e6f6cf; font-size: 14px; font-weight: 650; text-align: center; z-index: 4; pointer-events: none; }
.camera-frame.is-locking, .camera-frame.calibrating { cursor: crosshair; touch-action: none; }
.camera-overlay { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 24px; color: #e4e9df; text-align: center; background: radial-gradient(ellipse at 50% 40%, #2b3c30 0%, #192620 60%, #15211c 100%); pointer-events: none; }
.camera-overlay.hidden { display: none; }
.empty-board { width: 117px; height: 117px; position: relative; margin-bottom: 26px; background: conic-gradient(#4e6040 25%, #3d4b36 0 50%, #4e6040 0 75%, #3d4b36 0) 50% 50% / 29.25px 29.25px; border-radius: 2px; box-shadow: 0 14px 24px #07120d30; }
.empty-knight { position: absolute; left: 32px; top: 25px; width: 57px; height: 66px; color: #bdce9f; fill: #3d4b36; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }
.view-corner { position: absolute; width: 18px; height: 18px; border-color: #b1ce90; border-style: solid; opacity: .65; }
.view-corner.tl { top: -10px; left: -10px; border-width: 2px 0 0 2px; border-radius: 5px 0 0 0; }
.view-corner.tr { top: -10px; right: -10px; border-width: 2px 2px 0 0; border-radius: 0 5px 0 0; }
.view-corner.bl { bottom: -10px; left: -10px; border-width: 0 0 2px 2px; border-radius: 0 0 0 5px; }
.view-corner.br { bottom: -10px; right: -10px; border-width: 0 2px 2px 0; border-radius: 0 0 5px 0; }
.camera-overlay h3 { font-size: 20px; font-weight: 550; letter-spacing: -.4px; margin-bottom: 8px; }
.camera-overlay p { font-size: 12px; color: #a3b1a0; line-height: 1.7; }
.camera-empty-note { margin-top: 23px; font-size: 7px; letter-spacing: 1.2px; color: #83937c; }
.frame-hud { position: absolute; inset: 13px 13px auto; display: flex; align-items: center; gap: 8px; z-index: 4; pointer-events: none; }
.frame-tag { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; background: #0d191acc; color: #dbe6dd; border: 1px solid #ffffff12; border-radius: 6px; padding: 5px 8px; font-size: 9px; font-weight: 600; line-height: 1.3; backdrop-filter: blur(8px); }
.hud-dot { width: 5px; height: 5px; border-radius: 50%; background: #819388; }
.frame-tag.locked { color: var(--lime); }
.live-indicator { margin-left: auto; font-size: 8px; letter-spacing: 1px; }
.live-indicator .hud-dot { background: #b9d795; }
.confidence { margin-left: auto; font-variant-numeric: tabular-nums; }
.live-indicator:not([hidden]) + .confidence { margin-left: 0; }
.camera-actions { display: flex; gap: 9px; margin-top: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; border-radius: 10px; padding: 11px 16px; border: 1px solid transparent; font-size: 12px; font-weight: 650; line-height: 1.3; transition: background .15s, border-color .15s; }
.btn .icon { width: 17px; height: 17px; flex-basis: 17px; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-hover); }
.btn-secondary, .btn-icon { background: #f5f7f2; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled), .btn-icon:hover:not(:disabled) { background: #eaf0e4; }
.camera-actions .btn-primary { flex: 1; }
.camera-actions .btn-secondary { min-width: 88px; }
.btn-icon { width: 46px; padding: 10px; flex: 0 0 46px; }
.camera-secondary-actions { display: flex; justify-content: center; gap: 28px; margin: 10px 0 8px; }
.text-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 550; padding: 9px 0; min-height: 36px; border-radius: 4px; text-decoration: none; }
.text-btn .icon { width: 14px; height: 14px; flex-basis: 14px; }
.text-btn:hover:not(:disabled) { color: var(--green); }
.board-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.board-tools > div { display: flex; gap: 16px; }
.board-tools .text-btn { font-size: 10px; }
.camera-tip { margin-top: 6px; color: #8b968d; font-size: 10px; line-height: 1.6; }
.coach-panel { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.card { padding: 22px; }
.move-card { background: #f0f5e9; border-color: #e1e9d6; }
.move-card h2 .icon { color: #688052; }
.engine-badge { background: #fff9; color: #728267; border: 1px solid #e3e9d8; border-radius: 20px; font-size: 8px; padding: 3px 8px; white-space: nowrap; }
.move-display { min-height: 178px; display: flex; align-items: center; padding: 24px 0 20px; }
.move-waiting { width: 100%; }
.waiting-arrow { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #e2ebd6; color: #759455; margin-bottom: 15px; }
.waiting-arrow .icon { width: 19px; height: 19px; }
.move-waiting h3 { font-size: 21px; letter-spacing: -.5px; font-weight: 600; margin-bottom: 8px; }
.move-waiting p { color: #7a8871; font-size: 12px; max-width: 270px; line-height: 1.65; }
.move-result { width: 100%; }
.move-overline { font-size: 8px; letter-spacing: 1.3px; color: #748464; font-weight: 650; margin-bottom: 8px; }
.move-text { font-size: 30px; line-height: 1.17; font-weight: 650; letter-spacing: -1px; overflow-wrap: anywhere; }
.move-notation { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.move-san { background: #dfeace; border: 1px solid #d5e2c2; padding: 4px 11px; border-radius: 6px; font-weight: 700; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.move-uci { color: #77836d; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.move-caption { color: #7a8871; font-size: 10px; margin-top: 12px; }
.status-bar { display: flex; align-items: flex-start; gap: 7px; border-top: 1px solid #dfe7d6; padding-top: 13px; color: #798671; font-size: 10px; line-height: 1.6; }
.status-indicator-dot { margin-top: 5px; width: 5px; height: 5px; flex-basis: 5px; background: #8d9d7d; }
.status-bar.ok { color: var(--green); }
.status-bar.ok .status-indicator-dot { background: #629744; }
.status-bar.error { color: var(--danger); }
.status-bar.error .status-indicator-dot { background: var(--danger); }
.recent-moves { padding-bottom: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 9px; color: #7b886f; }
#recentPills { display: flex; flex-wrap: wrap; gap: 4px; }
.recent-chip { border: 1px solid #dce5d0; border-radius: 4px; padding: 2px 6px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; }
.settings-card .card-heading { margin-bottom: 22px; }
.section-number { color: #b1bbad; font-size: 10px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.control-group { margin-bottom: 20px; }
.ctrl-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; font-weight: 550; color: #768272; margin-bottom: 9px; }
.toggle-group { display: flex; gap: 8px; }
.toggle-btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; flex: 1; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #7b8579; font-size: 12px; font-weight: 600; }
.toggle-btn.active { border-color: #a9ba9c; background: #f1f5eb; color: var(--green); }
.piece-dot { width: 11px; height: 11px; border-radius: 50%; }
.piece-dot.white { border: 1px solid #a3afa0; background: #fff; box-shadow: inset 0 -2px 0 #e7ebe3; }
.piece-dot.black { background: #334338; border: 1px solid #334338; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 22px; color: #768272; font-size: 11px; }
select { max-width: 58%; min-height: 36px; border: 1px solid var(--line); border-radius: 7px; background: #f8f9f5; color: var(--ink); padding: 7px 24px 7px 9px; font-size: 11px; }
.strength-control { margin-bottom: 19px; }
.depth-value { color: var(--green); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; font-weight: 700; }
.depth-unit { color: #a1ada0; font-size: 10px; font-weight: 400; }
input[type="range"] { width: 100%; height: 26px; margin: 0; background: transparent; cursor: pointer; }
.range-labels { display: flex; justify-content: space-between; font-size: 9px; color: #9ba594; margin-top: 2px; }
.advanced-settings { border-top: 1px solid var(--line); }
.advanced-settings summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; min-height: 44px; margin-bottom: -8px; padding-top: 6px; font-size: 10px; font-weight: 600; color: #819078; list-style: none; }
.advanced-settings summary::-webkit-details-marker { display: none; }
.advanced-settings summary .icon { width: 16px; height: 16px; flex-basis: 16px; transition: transform .15s; }
.advanced-settings[open] summary .icon { transform: rotate(180deg); }
.advanced-content { padding-top: 20px; }
.field-help { font-size: 10px; line-height: 1.7; color: #929d8b; }
.fen-field .field-help { margin-bottom: 8px; }
textarea, .modal-input { display: block; width: 100%; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #f8f9f5; padding: 10px; font-size: 11px; }
textarea { resize: vertical; min-height: 74px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; line-height: 1.7; margin-bottom: 7px; }
textarea::placeholder, .modal-input::placeholder { color: #a3ad9b; }
.setup-actions { display: flex; gap: 7px; margin-top: 12px; }
.setup-actions .btn { flex: 1; }
.btn-small { min-height: 39px; padding: 9px 10px; font-size: 10px; border-radius: 8px; }
.reset-btn { margin-top: 8px; font-size: 10px; }
.how-it-works { display: flex; gap: 12px; padding: 2px 10px; }
.how-icon { width: 33px; height: 33px; flex: 0 0 33px; border: 1px solid #e0e6d9; background: #eef2e8; border-radius: 10px; display: grid; place-items: center; color: #879676; margin-top: 2px; }
.how-icon .icon { width: 17px; height: 17px; }
.how-it-works h3 { color: #7a8970; font-size: 11px; font-weight: 600; margin-bottom: 5px; }
.how-it-works p { color: #a0a998; font-size: 10px; line-height: 1.7; max-width: 285px; }
.footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 32px 25px; color: #9ba693; font-size: 10px; }
.footer > div { display: flex; align-items: center; gap: 20px; }
.footer .text-btn, .footer a { color: #89977e; font-size: 10px; text-decoration: none; }
.footer a:hover { color: var(--green); }
.modal-dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(460px, calc(100% - 32px)); margin: auto; color: var(--ink); background: var(--paper); box-shadow: 0 30px 100px #18302440; }
.modal-dialog::backdrop { background: #14231b80; backdrop-filter: blur(4px); }
.modal-content { padding: 24px; }
.modal-content .card-heading { margin-bottom: 12px; }
.modal-content .card-heading .btn-icon { min-height: 32px; width: 32px; flex-basis: 32px; padding: 0; font-size: 23px; font-weight: 400; }
.modal-content > .field-help { margin-bottom: 18px; }
.modal-input { min-height: 44px; }
.modal-status { min-height: 30px; padding-top: 10px; font-size: 11px; color: var(--muted); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.modal-actions .btn-primary { margin-left: auto; }
@media (max-width: 800px) {
  .header-inner { min-height: 72px; padding: 15px 20px; }
  .brand { font-size: 20px; }
  .brand-mark { width: 37px; height: 37px; border-radius: 11px; }
  .brand small { font-size: 7px; letter-spacing: 1.5px; }
  .main { padding: 26px 20px 18px; max-width: 600px; }
  .page-intro { margin-bottom: 23px; }
  .intro-description { display: none; }
  .eyebrow { font-size: 8px; letter-spacing: 1.6px; margin-bottom: 9px; }
  h1 { font-size: 30px; letter-spacing: -1.1px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .camera-panel { padding: 16px; }
  .panel-heading { margin-bottom: 13px; }
  .coach-panel { gap: 16px; }
  .card { padding: 20px; }
  .move-display { min-height: 145px; padding-top: 21px; }
  .move-waiting { display: grid; grid-template-columns: 37px minmax(0, 1fr); align-items: center; column-gap: 13px; }
  .waiting-arrow { grid-row: span 2; margin-bottom: 0; }
  .move-waiting h3 { font-size: 19px; margin-bottom: 5px; }
  .move-waiting p { font-size: 11px; max-width: none; }
  .settings-card .card-heading { margin-bottom: 18px; }
  .how-it-works { padding: 4px 8px; }
  .how-it-works p { max-width: none; }
  .footer { max-width: 600px; padding: 17px 20px 25px; font-size: 9px; }
  .footer > div { gap: 14px; }
  .footer .text-btn, .footer a { font-size: 9px; }
}
@media (max-width: 400px) {
  .header-inner { padding-left: 16px; padding-right: 16px; }
  .main { padding-left: 12px; padding-right: 12px; }
  .status-pill { font-size: 10px; padding: 7px 10px; gap: 6px; }
  h1 { font-size: 27px; }
  .camera-panel { padding: 13px; border-radius: 16px; }
  .camera-overlay { padding: 22px 16px; }
  .empty-board { width: 88px; height: 88px; background-size: 22px 22px; margin-bottom: 24px; }
  .empty-knight { left: 23px; top: 17px; width: 44px; height: 52px; }
  .camera-overlay h3 { font-size: 18px; }
  .camera-overlay p { font-size: 11px; }
  .camera-empty-note { font-size: 6px; margin-top: 18px; letter-spacing: .7px; }
  .camera-actions { gap: 7px; margin-top: 13px; }
  .camera-actions .btn { font-size: 11px; padding-left: 12px; padding-right: 12px; }
  .camera-actions .btn-secondary { min-width: 74px; }
  .board-tools > div { gap: 12px; }
  .card { padding: 18px; border-radius: 16px; }
  .move-text { font-size: 28px; }
  .footer { padding-left: 16px; padding-right: 16px; flex-wrap: wrap; gap: 0; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Supporting copy and controls remain readable at phone viewing distance. */
.ctrl-label, .field-row, .field-help, .camera-tip, .status-bar, .move-caption, .move-uci, .text-btn, .how-it-works p { font-size: 12px; color: #5f6e62; }
.move-waiting p { color: #5f7056; }
.how-it-works h3, .advanced-settings summary { color: #506749; font-size: 12px; }
.camera-overlay p { color: #bbc8b5; }
.camera-empty-note { color: #abbc9d; font-size: 9px; }
.frame-hud { flex-wrap: wrap; }
.frame-tag { font-size: 10px; }
.toggle-btn, .btn-small { min-height: 44px; font-size: 12px; }
.text-btn { min-height: 44px; }
@media (max-width: 800px) {
  select, textarea, .modal-input { font-size: 16px; min-height: 44px; }
  select { max-width: 65%; padding-right: 18px; font-size: 13px; }
  .status-pill { min-height: 44px; }
  .main { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .board-tools .text-btn { font-size: 11px; }
}
