:root {
  --paper: #f3f4f6;
  --paper-shadow: rgba(20, 24, 32, 0.08);
  --paper-line: rgba(57, 66, 80, 0.14);
  --ink: #171b22;
  --muted: #5f6775;
  --accent: #687181;
  --accent-strong: #505867;
  --board: #d7dbe0;
  --board-dark: #b8bec6;
  --stone-black: #171410;
  --stone-white: #f9f6ef;
  --success: #1d6c45;
  --error: #8d2b2b;
  --shadow-lg: 0 24px 60px rgba(27, 33, 41, 0.12);
  --shadow-md: 0 14px 30px rgba(27, 33, 41, 0.08);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.78), transparent 32%),
    linear-gradient(180deg, #d9dee6 0%, #eef1f5 38%, #e4e8ee 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(90deg, transparent 0, transparent 48%, rgba(255, 255, 255, 0.18) 50%, transparent 52%, transparent 100%),
    linear-gradient(0deg, transparent 0, transparent 48%, rgba(67, 79, 96, 0.03) 50%, transparent 52%, transparent 100%);
  background-size: 140px 140px;
  opacity: 0.55;
  pointer-events: none;
}

.page-shell {
  width: min(1100px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.app-shell {
  display: grid;
  gap: 24px;
}

.hero-card,
.board-card,
.sidebar-card {
  border: 1px solid rgba(44, 52, 64, 0.08);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 244, 247, 0.96));
  box-shadow: var(--shadow-lg);
}

.hero-card {
  padding: 28px;
}

.landing-card {
  display: grid;
  justify-items: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-title,
.game-title {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-weight: 700;
  line-height: 0.96;
}

.hero-title {
  max-width: 12ch;
  font-size: clamp(2.8rem, 9vw, 5.8rem);
}

.hero-copy,
.sidebar-copy,
.meta-copy,
.status-copy,
.field-label,
.field-hint,
.empty-hint,
.inline-message,
.copy-note {
  color: var(--muted);
  line-height: 1.55;
}

.hero-grid {
  display: grid;
  gap: 22px;
  align-items: start;
}

.game-form {
  display: grid;
  gap: 18px;
  width: min(100%, 420px);
  padding: 22px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(239, 242, 246, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.field-row {
  display: grid;
  gap: 10px;
}

.field-label {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.text-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(73, 82, 96, 0.16);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.text-input:focus,
.button:focus,
.size-option input:focus + span {
  outline: 2px solid rgba(104, 113, 129, 0.28);
  outline-offset: 2px;
}

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

.size-option {
  display: block;
}

.size-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.size-option span {
  display: block;
  padding: 12px 14px;
  border: 1px solid rgba(73, 82, 96, 0.12);
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-align: center;
  background: rgba(255, 255, 255, 0.64);
  cursor: pointer;
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    border-color 120ms ease;
}

.size-option input:checked + span {
  border-color: rgba(104, 113, 129, 0.34);
  background: rgba(104, 113, 129, 0.1);
  transform: translateY(-1px);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  color: #f7f8fa;
  font: inherit;
  font-weight: 700;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  box-shadow: 0 12px 24px rgba(60, 69, 81, 0.16);
  cursor: pointer;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(60, 69, 81, 0.2);
}

.button.secondary {
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(235, 239, 244, 0.96));
  box-shadow: none;
  border: 1px solid rgba(73, 82, 96, 0.12);
}

.button.ghost {
  padding-inline: 14px;
  color: var(--accent-strong);
  background: transparent;
  box-shadow: none;
  border: 1px solid rgba(104, 113, 129, 0.2);
}

.button[disabled] {
  cursor: not-allowed;
  filter: grayscale(0.2);
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

.message-banner {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
}

.message-banner.error {
  color: var(--error);
  background: rgba(168, 52, 52, 0.08);
  border-color: rgba(168, 52, 52, 0.18);
}

.message-banner.success {
  color: var(--success);
  background: rgba(29, 108, 69, 0.08);
  border-color: rgba(29, 108, 69, 0.18);
}

.game-layout {
  display: grid;
  gap: 16px;
}

.board-section {
  display: grid;
  gap: 12px;
}

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.game-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-turn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(42, 50, 63, 0.06);
}

.stone-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.stone-button {
  position: relative;
  appearance: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    opacity 120ms ease;
}

.stone-button.black {
  border: 1px solid rgba(16, 18, 22, 0.18);
  background: radial-gradient(circle at 30% 30%, #49423c, var(--stone-black));
}

.stone-button.white {
  border: 1px solid rgba(68, 78, 92, 0.22);
  background: radial-gradient(circle at 30% 30%, #ffffff, #ece7de);
}

.stone-button.active {
  box-shadow: 0 0 0 2px rgba(49, 58, 72, 0.9);
  transform: scale(1.04);
}

.stone-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.toolbar-button {
  appearance: none;
  border: 1px solid rgba(57, 66, 80, 0.14);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

.toolbar-button:hover {
  border-color: rgba(57, 66, 80, 0.24);
  background: rgba(255, 255, 255, 0.92);
}

.toolbar-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.toolbar-feedback {
  margin: -2px 0 0;
}

.board-card {
  overflow: hidden;
  padding: 14px;
}

.board-frame {
  position: relative;
  border: 1px solid rgba(72, 82, 96, 0.12);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 36%),
    linear-gradient(180deg, var(--board), var(--board-dark));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -10px 22px rgba(91, 101, 116, 0.12);
}

.board-frame.is-blocked::after {
  position: absolute;
  inset: 0;
  content: "";
  border-radius: inherit;
  background: rgba(73, 82, 96, 0.18);
  pointer-events: none;
}

.board-svg {
  display: block;
  width: 100%;
  height: auto;
}

.board-svg.blocked {
  cursor: not-allowed;
}

.board-svg .grid-line {
  stroke: rgba(56, 64, 78, 0.82);
  stroke-width: 0.42;
}

.board-svg .star-point {
  fill: rgba(56, 64, 78, 0.86);
}

.board-svg .intersection {
  fill: transparent;
  cursor: pointer;
  transition: fill 120ms ease;
}

.board-svg .intersection:hover {
  fill: rgba(255, 255, 255, 0.18);
}

.board-svg .intersection.blocked {
  cursor: not-allowed;
}

.board-svg .intersection.blocked:hover {
  fill: transparent;
}

.board-svg .stone.black {
  fill: var(--stone-black);
}

.board-svg .stone.white {
  fill: var(--stone-white);
}

.board-svg .stone {
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.18));
}

.board-svg .last-move-mark.black {
  fill: rgba(255, 250, 243, 0.92);
}

.board-svg .last-move-mark.white {
  fill: rgba(20, 16, 12, 0.85);
}

.turn-stone {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.14);
}

.turn-stone.black {
  background: radial-gradient(circle at 30% 30%, #423a31, var(--stone-black));
}

.turn-stone.white {
  background: radial-gradient(circle at 30% 30%, #ffffff, #e9e2d5);
  border: 1px solid rgba(36, 25, 16, 0.08);
}

.inline-message {
  min-height: 1.5em;
  font-weight: 600;
}

.empty-hint {
  margin: 0;
}

@media (max-width: 560px) {
  .game-toolbar {
    align-items: start;
    flex-direction: column;
  }

  .toolbar-actions {
    width: 100%;
  }
}

@media (min-width: 860px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  }
}

@media (max-width: 859px) {
  .page-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 18px;
  }

  .hero-card,
  .board-card {
    border-radius: 24px;
  }

  .hero-card {
    padding: 20px;
  }
}
