:root {
  --bg: #f1eadf;
  --bg-deep: #dfcfb4;
  --panel: rgba(255, 248, 236, 0.9);
  --panel-border: rgba(102, 73, 36, 0.14);
  --ink: #261b14;
  --muted: #6e5946;
  --red: rgb(220, 60, 60);
  --blue: rgb(40, 100, 220);
  --off-white: rgb(246, 241, 232);
  --grid-edge: rgb(182, 182, 182);
  --candidate-low: rgb(244, 232, 250);
  --candidate-high: rgb(170, 125, 210);
  --shadow: 0 16px 38px rgba(79, 48, 17, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.55), transparent 36%),
    linear-gradient(180deg, #f5eee2 0%, var(--bg) 58%, var(--bg-deep) 100%);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

a {
  color: #7d4b24;
}

a:hover {
  color: #5f3717;
}

code,
input,
button,
.entry-list {
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

.page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0;
}

.page-footer {
  margin-top: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.footer-sep {
  margin: 0 8px;
  color: var(--muted);
}

.hero {
  margin-bottom: 18px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3.3vw, 2.8rem);
  line-height: 0.96;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.58fr) minmax(280px, 0.74fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.board-panel {
  position: relative;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(246, 237, 221, 0.82)),
    repeating-linear-gradient(
      -45deg,
      rgba(173, 126, 69, 0.04) 0,
      rgba(173, 126, 69, 0.04) 10px,
      rgba(255, 255, 255, 0.02) 10px,
      rgba(255, 255, 255, 0.02) 20px
    );
}

.board-topbar {
  position: absolute;
  top: 30px;
  left: 18px;
  right: 18px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.board-controls {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.detail-panel {
  min-width: 0;
  padding: 14px;
  display: grid;
  gap: 14px;
}

.button-row,
.input-row {
  display: flex;
  gap: 10px;
}

.input-row {
  align-items: center;
  margin-bottom: 8px;
}

.board {
  width: 100%;
  min-height: 560px;
  display: block;
  user-select: none;
}

button {
  border: 1px solid rgba(78, 49, 25, 0.18);
  background: linear-gradient(180deg, #fff7ea 0%, #f0dcc0 100%);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(108, 67, 24, 0.16);
}

button:disabled {
  cursor: default;
  opacity: 0.65;
  transform: none;
  box-shadow: none;
}

.board-reset,
.board-random {
  padding: 8px 12px;
}

.board-random-mode {
  display: flex;
  gap: 0;
  padding: 3px;
  border: 1px solid rgba(78, 49, 25, 0.18);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 247, 234, 0.98), rgba(240, 220, 192, 0.98));
  box-shadow: 0 8px 20px rgba(108, 67, 24, 0.12);
}

.random-mode-btn {
  min-width: 34px;
  padding: 5px 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.random-mode-btn.is-active {
  background: linear-gradient(180deg, #eed8b6 0%, #dfc093 100%);
  box-shadow: inset 0 0 0 1px rgba(93, 59, 25, 0.08), 0 3px 8px rgba(108, 67, 24, 0.14);
}

.random-mode-btn:hover {
  transform: none;
  box-shadow: none;
}

.random-mode-btn.is-active:hover {
  box-shadow: inset 0 0 0 1px rgba(93, 59, 25, 0.08), 0 3px 8px rgba(108, 67, 24, 0.14);
}

.turn-indicator {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.turn-indicator.turn-red {
  color: rgb(220, 60, 60);
}

.turn-indicator.turn-blue {
  color: rgb(40, 100, 220);
}

input {
  flex: 1;
  min-width: 0;
  border-radius: 14px;
  border: 1px solid rgba(78, 49, 25, 0.18);
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-size: 1rem;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.detail-card {
  min-width: 0;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 252, 245, 0.86);
  border: 1px solid rgba(113, 81, 49, 0.12);
}

.info-card h2 {
  margin: 0 0 8px;
}

.info-card .card-copy {
  font-size: 0.94rem;
  line-height: 1.32;
}

.symmetry-card h2 {
  margin: 0 0 12px;
}

.symmetry-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.symmetry-btn {
  width: 100%;
  padding: 9px 10px;
  font-size: 0.88rem;
}

.detail-card h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.canonical-label {
  margin-top: 14px;
}

.copyable-code {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(78, 49, 25, 0.14);
  background: rgba(255, 255, 255, 0.72);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1rem;
  line-height: 1.35;
  cursor: pointer;
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

.copyable-code:hover {
  color: #7d4b24;
}

.card-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.4;
  min-height: 1.2em;
}

.meta-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  min-height: 1.1em;
}

.board-hex {
  stroke-width: 0.75;
}

.board-hex-face {
  pointer-events: none;
}

.board-hover-hit {
  fill: transparent;
  stroke: none;
  pointer-events: all;
}

.board-hover-hit.clickable {
  cursor: pointer;
}

.board.dragging,
.board.dragging .board-hover-hit.clickable {
  cursor: grabbing;
}

.board-hover-hit.hoverable:hover {
  fill: var(--hover-fill, transparent);
}

.board-hover-hit.hoverable:hover + .board-hex-face {
  stroke: var(--hover-outline, rgb(182, 182, 182));
  stroke-width: 1.6;
}

.board-hex.candidate {
  stroke: none;
}

.board-hex.tenuki {
  stroke-width: 0.95;
}

.board-hex.drag-source {
  opacity: 0.34;
}

.board-ghost {
  pointer-events: none;
  opacity: 0.42;
}

.board-ghost-target {
  opacity: 0.64;
}

.cell-text {
  fill: #111111;
  font-size: 12px;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.tenuki-text {
  font-size: 12px;
}

.tenuki-label {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .board-topbar {
    position: static;
    margin-bottom: 14px;
    align-items: center;
    gap: 12px;
  }

  .board-controls {
    grid-template-columns: repeat(3, max-content);
    justify-content: end;
    align-items: center;
  }

  .symmetry-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .board {
    min-height: 0;
  }
}
