:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #233e36;
  background: #edf4ef;
  font-synthesis: none;
  --ink: #233e36;
  --muted: #52675f;
  --teal: #21695f;
  --line: #bbcdc2;
  --paper: #fffef8;
}

* { box-sizing: border-box; }

body { margin: 0; }

button,
select,
input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid #8da69a;
  border-radius: 9px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
}

button {
  padding: 9px 12px;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover:not(:disabled) { background: #e1eee4; }

button.primary {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

button.primary:hover:not(:disabled) { background: #174d45; }

button:disabled,
select:disabled,
input:disabled {
  opacity: 0.58;
  cursor: default;
}

:focus-visible {
  outline: 3px solid #a34c15;
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.shell {
  width: min(100%, 940px);
  margin: 0 auto;
  padding: 16px 24px 32px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.home-link {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 7px 8px;
  border-radius: 8px;
  color: #255b50;
  font-size: 13px;
  text-underline-offset: 4px;
}

.intro {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.game-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.board-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.board-heading h2 { margin: 0; font-size: 17px; line-height: 24px; }
.status-label { color: #3f6652; font-size: 12px; font-weight: 700; }
.status-label.is-won { color: #804613; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 6px;
  padding: 5px 2px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.metrics div + div { border-left: 1px solid var(--line); }
.metrics dt { font-size: 12px; line-height: 16px; color: var(--muted); }
.metrics dd { margin: 0; font-size: 17px; font-weight: 700; line-height: 21px; }

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(285px, 1fr);
  align-items: center;
  gap: 24px;
}

.board-panel { min-width: 0; margin: 0; }

#bridge-board {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  border-radius: 18px;
  background: #e2eeea;
  pointer-events: none;
}

.bridge-line {
  stroke: #42685c;
  stroke-width: 3.5;
  stroke-linecap: butt;
}

.bridge-line.is-selected { stroke: #a8521c; }
.selection-guide { stroke: #9d5b2c; stroke-width: 2; stroke-dasharray: 7 6; }
.island-circle { fill: var(--paper); stroke: #587969; stroke-width: 2; }
.island-circle.is-satisfied { fill: #eaf1d5; }
.island-selection { fill: none; stroke: #a8521c; stroke-width: 2; }
.island-label, .island-count { fill: var(--ink); text-anchor: middle; font-size: 18px; }
.island-label { font-weight: 600; }
.island-count { font-weight: 750; }

figcaption { margin-top: 4px; font-size: 12px; line-height: 17px; color: #5d654b; }
.bridge-panel { min-width: 0; }
.selection-summary { margin: 0 0 6px; }
.selection-summary p { margin: 0; }
.selected-bridge { font-size: 15px; font-weight: 750; line-height: 23px; }
.selected-islands { font-size: 13px; color: var(--muted); line-height: 21px; }

.feedback {
  min-height: 54px;
  margin: 0 0 9px;
  padding: 8px 10px;
  border-left: 3px solid #749667;
  border-radius: 0 8px 8px 0;
  background: #f8f5e6;
  color: #48563b;
  font-size: 13px;
  line-height: 19px;
}

.feedback.is-won { border-color: #a25b20; background: #fff0d7; color: #704012; }
.select-label { display: block; margin-bottom: 4px; font-size: 13px; line-height: 18px; }
#bridge-select { width: 100%; padding: 8px 10px; }
.bridge-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 8px; }
.bridge-actions button { padding-right: 4px; padding-left: 4px; }

.island-section,
.map-section,
.share-section,
.rules-section,
.history-section {
  margin-top: 21px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

section h2 { margin: 0 0 9px; font-size: 16px; line-height: 24px; }
.island-section h2 span { margin-left: 7px; font-size: 12px; font-weight: 400; color: var(--muted); }
.island-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px 10px; margin: 0; padding: 0; list-style: none; }
.island-list li { font-size: 13px; line-height: 22px; }
.board-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.board-buttons [aria-pressed="true"] { border: 2px solid var(--teal); background: #dbeadd; font-weight: 700; }
.two-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.session-actions { margin-top: 8px; }
.share-section > p, .invitation p { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.6; }
#share-board { width: 100%; }
.invitation { margin-top: 12px; }
.invitation label { display: block; margin-bottom: 5px; font-size: 13px; line-height: 20px; }
#invitation-url { width: 100%; padding: 9px; font-size: 13px; }
.invitation p { margin: 5px 0 0; font-size: 12px; }
.rules-section ul { margin: 0; padding-left: 1.4em; }
.rules-section li { margin: 5px 0; font-size: 13px; line-height: 1.7; }
.history-section p, .history-section li { font-size: 13px; line-height: 1.7; }
.history-section ol { margin: 0; padding-left: 1.6em; }
.history-section p { margin: 0; color: var(--muted); }

.confirmation {
  margin: 8px 0 14px;
  padding: 14px;
  border: 2px solid #a4612c;
  border-radius: 12px;
  background: #fff7e7;
}

.confirmation h2 { margin-bottom: 4px; }
.confirmation p { margin: 0 0 12px; font-size: 14px; line-height: 1.6; }
.confirmation button { font-size: 13px; }
.address-notice { padding: 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; line-height: 1.6; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 700px) {
  .shell { padding: 8px 12px 26px; }
  h1 { font-size: 24px; }
  .intro { margin: 2px 0 5px; font-size: 12px; line-height: 18px; }
  .board-heading { margin-bottom: 3px; }
  .board-heading h2 { font-size: 15px; line-height: 22px; }
  .metrics { padding: 3px 0; margin-bottom: 4px; }
  .play-layout { display: block; }
  .board-panel { width: min(100%, 336px); margin: 0 auto; }
  figcaption { margin-top: 2px; line-height: 16px; }
  .selection-summary { margin: 4px 0; }
  .selected-bridge { font-size: 14px; line-height: 21px; }
  .selected-islands { font-size: 12px; line-height: 18px; }
  .feedback { min-height: 44px; margin-bottom: 5px; padding: 5px 8px; font-size: 12px; line-height: 17px; }
  .select-label { margin-bottom: 2px; font-size: 12px; line-height: 16px; }
  .bridge-actions { margin-top: 6px; gap: 6px; }
  .island-section { margin-top: 15px; padding-top: 10px; }
  .island-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
