:root {
  font-family: system-ui, sans-serif;
  color: #172b3a;
  background-color: #f4f8fb;
  line-height: 1.5;
  font-synthesis: none;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 12px max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

main {
  max-width: 28rem;
  margin-inline: auto;
  overflow-wrap: break-word;
}

h1 {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.2;
}

h2 { margin: 0; font-size: 1rem; }

p { margin: 0; }

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.game-stats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.undo-button {
  flex: none;
  width: 48px;
  min-height: 48px;
  padding: 0;
  border: 1px solid #879ead;
  border-radius: 50%;
  color: #244f65;
  background-color: #fff;
  font: inherit;
  font-size: 1.5rem;
  cursor: pointer;
  touch-action: manipulation;
}

.undo-button:disabled {
  border-color: transparent;
  color: #879ead;
  background-color: #edf3f7;
  opacity: 0.6;
  cursor: default;
}

.game-stats p {
  display: flex;
  flex-direction: column;
  color: #496173;
  font-size: 0.75rem;
  line-height: 1.25;
}

.game-stats strong {
  color: #172b3a;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.current-score strong { font-size: 1.25rem; }

.board-sheet {
  padding: 6px;
  border: 1px solid #c6d4df;
  border-radius: 0.75rem;
  background-color: #fff;
}

.board-sheet__header { padding: 0.25rem 4px 0.375rem; }

.board {
  width: 100%;
  table-layout: fixed;
  border-spacing: 4px;
}

.board th,
.board td {
  padding: 0;
  text-align: center;
}

.board th {
  color: #496173;
  font-size: 0.875rem;
  font-weight: 600;
}

.board-corner { width: 22px; }

.street-marker {
  display: block;
  color: #705513;
  font-size: 0.75rem;
  line-height: 1.2;
}

.board-row--street .board-cell {
  box-shadow: inset 0 0 0 2px #bf9e35;
  background-color: #fff7dd;
}

.board-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  width: 100%;
  min-width: 0;
  min-height: clamp(3rem, 12vw, 3.5rem);
  padding: 4px;
  border: 1px solid #b7c7d2;
  border-radius: 0.5rem;
  color: #172b3a;
  background-color: #f4f8fb;
  font: inherit;
  font-variant-numeric: tabular-nums;
  appearance: none;
  touch-action: manipulation;
  cursor: pointer;
}

.board-cell--occupied { background-color: #fff; }

.board-cell:disabled {
  opacity: 1;
  -webkit-text-fill-color: currentColor;
  cursor: default;
}

.board-cell--start {
  border: 2px solid #30657d;
  color: #244f65;
  background-color: #e9f4fa;
}

.board-cell--goal {
  border: 2px solid #35705b;
  color: #285b48;
  background-color: #eaf5ef;
}

.board-cell--selected {
  border: 2px solid #275e75;
  background-color: #e9f4fa;
  box-shadow: inset 0 0 0 1px #275e75;
}

.board-cell__marker {
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
}

.board-cell__value {
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.2;
}

.board-cell__ice {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 2px;
  object-fit: contain;
  pointer-events: none;
}

.board-cell--frozen .board-cell__value,
.board-cell--frozen .board-cell__marker,
.board-cell--attack-iced .board-cell__value,
.board-cell--attack-iced .board-cell__marker {
  position: relative;
  z-index: 1;
  color: #172b3a;
  text-shadow: 0 0 3px #fff;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid #275e75;
  outline-offset: 2px;
}

.number-entry,
.attack-ice-actions {
  margin: 0.5rem 4px 0;
  padding-top: 0.5rem;
  border-top: 1px solid #c6d4df;
}

.attack-ice-actions > p {
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.attack-ice-actions__controls {
  display: flex;
  gap: 6px;
}

.number-entry > label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.number-entry__controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
}

.number-input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 6px 10px;
  border: 1px solid #879ead;
  border-radius: 0.5rem;
  color: #172b3a;
  background-color: #fff;
  font: inherit;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.number-input[aria-invalid="true"] {
  border: 2px solid #7d3d23;
  background-color: #fff0e7;
}

.number-help {
  margin-top: 0.375rem;
  color: #496173;
  font-size: 0.75rem;
}

.entry-feedback {
  margin-top: 0.375rem;
  color: #66311b;
  font-size: 0.875rem;
  font-weight: 600;
}

.action-button {
  width: 100%;
  min-height: 48px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #244f65;
  border-radius: 0.5rem;
  color: #fff;
  background-color: #244f65;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.number-entry .action-button { font-size: 0.875rem; }

.secondary-button {
  border-color: #879ead;
  color: #244f65;
  background-color: #fff;
}

.danger-button {
  border-color: #7d3d23;
  background-color: #7d3d23;
}

.goal-status {
  margin: 0.5rem 4px 0;
  padding: 0.5rem;
  border: 1px solid #35705b;
  border-radius: 0.5rem;
  color: #285b48;
  background-color: #eaf5ef;
  font-size: 0.875rem;
  font-weight: 600;
}

.street-bonus {
  margin: 0.375rem 4px 0;
  color: #705513;
  font-size: 0.8125rem;
  font-weight: 600;
}

.app-status {
  margin-top: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-left: 3px solid #275e75;
  border-radius: 0 0.5rem 0.5rem 0;
  color: #172b3a;
  background-color: #e9f4fa;
  font-size: 0.875rem;
}

.app-status[data-tone="success"] {
  border-color: #35705b;
  background-color: #eaf5ef;
}

.app-status[data-tone="warning"] {
  border-color: #bf9e35;
  background-color: #fff7dd;
}

.storage-status,
noscript p {
  margin-top: 0.5rem;
  color: #496173;
  font-size: 0.8125rem;
}

.reset-panel { margin-top: 0.5rem; }

.reset-panel #new-game {
  width: auto;
  border-color: transparent;
  color: #496173;
  background-color: transparent;
  font-size: 0.875rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.confirmation {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: 1px solid #7d3d23;
  border-radius: 0.75rem;
  background-color: #fff0e7;
}

.confirmation .action-button { margin-top: 0.5rem; }

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