:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #273c39;
  background: #f6f3ea;
  font-synthesis: none;
  --ink: #273c39;
  --muted: #60706b;
  --green: #286353;
  --line: #d7dfd6;
  --paper: #fffef9;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid #ae5a20;
  outline-offset: 3px;
}

.page-shell { width: min(1080px, calc(100% - 40px)); margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 34px 0 26px; }
.eyebrow { margin: 0 0 6px; color: var(--green); font-size: 12px; letter-spacing: .12em; }
h1 { margin: 0; font-size: 36px; line-height: 1.2; letter-spacing: .06em; }
.intro { margin: 10px 0 0; font-size: 15px; color: var(--muted); }
.home-link { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 10px 12px; color: var(--green); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; text-decoration: none; white-space: nowrap; }
.home-link:hover { background: #eaf0e6; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; gap: 22px; min-width: 0; margin: 0; padding: 0; border: 0; }
.panel { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 4px 0 #e7e7d940; }
.panel h2 { margin: 0; font-size: 18px; line-height: 1.5; }
.panel-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-label { flex-shrink: 0; padding: 4px 8px; border-radius: 6px; background: #e9efe3; font-size: 12px; color: var(--green); }
.status-label.won { background: #e1edd1; font-weight: 700; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 14px 0 12px; }
.metrics p { margin: 0; padding: 6px 2px; text-align: center; background: #f0f3eb; border-radius: 8px; }
.metrics span { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; }
.metrics strong { display: block; font-size: 18px; font-weight: 650; line-height: 1.4; font-variant-numeric: tabular-nums; }
.city-board { display: grid; grid-template-columns: 36px repeat(4, minmax(44px, 1fr)) 36px; grid-template-rows: 36px repeat(4, 68px) 36px; gap: 4px; width: 100%; max-width: 450px; margin: 0 auto; }
.clue { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0; color: #65756d; border-radius: 6px; background: #f3f2e9; }
.clue strong { font-size: 17px; line-height: 1.05; }
.clue-state { font-size: 12px; line-height: 1.15; white-space: nowrap; }
.clue[data-status="match"] { background: #e5efdd; color: #336241; }
.clue[data-status="mismatch"], .clue[data-status="conflict"] { background: #fae9dd; color: #8c4129; }
.cell { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; min-width: 44px; min-height: 44px; padding: 5px 2px 4px; border: 1px solid #c9d4c9; border-radius: 8px; color: var(--ink); background: #fffef9; }
.cell.is-fixed { background: #eaf0e7; }
.cell.is-conflict { border-color: #b26340; background: #fff0e5; }
.cell.is-selected { outline: 3px solid var(--green); outline-offset: -3px; box-shadow: inset 0 0 0 5px #fffef9; }
.cell:focus-visible { outline: 3px solid #ae5a20; outline-offset: 1px; }
.cell:disabled { opacity: 1; color: var(--ink); }
.cell-badges { position: absolute; inset: 3px 4px auto; display: flex; justify-content: space-between; pointer-events: none; }
.cell-badges span { font-size: 12px; line-height: 1; font-weight: 600; }
.fixed-mark { color: #496957; }
.conflict-mark { margin-left: auto; color: #9b452b; }
.tower { display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-height: 27px; }
.tower-segment { display: block; width: 20px; height: 5px; border: 1px solid #4d8270; border-radius: 1px; background: #82ac93; }
.is-fixed .tower-segment { border-color: #5c7a67; background: #9ab29b; }
.is-conflict .tower-segment { border-color: #a75f3d; background: #dca17c; }
.cell-value { font-size: 14px; font-weight: 600; line-height: 1.2; }
.cell.is-empty .cell-value { font-weight: 400; color: #7b877c; }
.selected-info { min-height: 35px; margin: 12px 0 8px; font-size: 13px; line-height: 1.4; color: #435e51; }
.palette { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.height-button { min-width: 0; min-height: 46px; padding: 8px 2px; border: 1px solid #b9cabc; border-radius: 9px; background: #e7efdf; color: #275341; font-size: 15px; font-weight: 600; white-space: nowrap; }
.height-button:hover:not(:disabled) { background: #d7e6cb; }
.clear-button { background: #f5f2e8; color: #695f47; border-color: #d9d0b9; }
.height-button:disabled { opacity: .52; }
.feedback { min-height: 55px; margin: 10px 0 0; padding: 9px 10px; border-left: 3px solid #a7bba0; border-radius: 0 6px 6px 0; background: #f2f4ea; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.feedback.has-conflict { border-color: #bd704b; background: #fff0e5; }
.feedback.is-won { border-color: #648c40; background: #e9f2dd; }
.main-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.button { min-width: 44px; min-height: 44px; padding: 10px 14px; border: 1px solid #bccbbd; border-radius: 9px; font-size: 14px; line-height: 1.4; }
.secondary { color: #345746; background: #fffef9; }
.secondary:hover:not(:disabled) { background: #edf2e6; }
.primary { color: white; background: var(--green); border-color: var(--green); }
.primary:hover:not(:disabled) { background: #1d5142; }
.button:disabled { opacity: .45; }
.action-note, .small-note { font-size: 12px; line-height: 1.6; color: var(--muted); }
.side-panels { display: grid; gap: 16px; min-width: 0; }
.side-panels .panel { padding: 18px; border-radius: 14px; }
.side-panels h2 { font-size: 16px; }
.puzzle-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 13px 0 10px; }
.puzzle-button { min-width: 44px; min-height: 49px; padding: 7px 2px; border: 1px solid #d3dacf; border-radius: 8px; background: #f6f5ec; font-size: 13px; color: #526550; }
.puzzle-button[aria-pressed="true"] { border: 2px solid var(--green); background: #e6efdd; color: #284f3e; font-weight: 600; }
.puzzle-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.invitation-panel > p, .rules-panel p, .rules-panel li { font-size: 13px; line-height: 1.7; color: #56665c; }
.full-width { width: 100%; }
.share-result { margin-top: 12px; }
.share-result label { display: block; margin-bottom: 6px; font-size: 13px; }
.share-result input { width: 100%; min-height: 44px; padding: 10px; border: 1px solid #97ad96; border-radius: 7px; color: #304c3c; background: #f5f8f0; font-size: 13px; }
.share-result p { margin: 5px 0 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.address-notice { padding: 8px 10px; border-radius: 6px; background: #fff0dc; }
.rules-panel ol { margin: 11px 0; padding-left: 20px; }
.rules-panel li + li { margin-top: 7px; }
.rules-panel p:last-child { margin-bottom: 0; }
.history-list { margin: 10px 0 0; padding-left: 28px; color: #526451; font-size: 13px; line-height: 1.8; }
.history-empty { margin-bottom: 0; }
.confirmation { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; border-color: #bf9967; background: #fff6e6; }
.confirmation p { margin: 5px 0 0; font-size: 13px; line-height: 1.6; }
.confirmation-actions { display: flex; flex-shrink: 0; gap: 8px; }
.workspace:disabled { opacity: .65; }
footer { padding: 25px 0 32px; text-align: center; color: #778174; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .page-shell { width: min(520px, calc(100% - 24px)); }
  .page-header { align-items: flex-start; gap: 10px; padding: 20px 0 17px; }
  h1 { font-size: 28px; }
  .eyebrow { font-size: 12px; letter-spacing: .04em; }
  .intro { max-width: 235px; margin-top: 7px; font-size: 13px; line-height: 1.6; }
  .home-link { min-width: 44px; padding: 10px 8px; font-size: 12px; }
  .home-link span { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .game-panel { padding: 12px; border-radius: 14px; }
  .game-panel h2 { font-size: 17px; }
  .metrics { margin: 9px 0; gap: 5px; }
  .metrics p { padding: 4px 0; }
  .metrics strong { font-size: 16px; }
  .city-board { grid-template-rows: 32px repeat(4, 58px) 32px; }
  .selected-info { margin: 9px 0 7px; min-height: 36px; }
  .palette { gap: 5px; }
  .height-button { min-height: 44px; font-size: 14px; }
  .feedback { margin-top: 8px; min-height: 54px; padding: 7px 8px; }
  .main-actions { margin-top: 9px; gap: 10px; }
  .confirmation { display: block; padding: 16px; }
  .confirmation-actions { margin-top: 12px; flex-wrap: wrap; }
  .side-panels .panel { padding: 16px; }
}

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