:root {
  color-scheme: light;
  --game-width: 608px;
  --ink: #19130e;
  --muted: #695a4b;
  --panel: #fffaf1;
  --line: rgba(64, 38, 18, 0.45);
  --accent: #b5202d;
  --green: #285d4d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.72), transparent 24rem),
    linear-gradient(135deg, #384f48 0%, #1f2f2b 48%, #704938 100%);
}

a {
  color: #ffe08a;
}

button {
  font: inherit;
}

.game-layout {
  width: min(1128px, calc(100vw - 32px));
  margin: 0 auto;
  padding-top: 90px;
  display: grid;
  grid-template-columns: 160px minmax(0, var(--game-width)) 160px;
  gap: 100px;
  align-items: start;
  justify-content: center;
}

.side-rail {
  width: 160px;
  min-width: 160px;
  min-height: 600px;
  margin-top: 0;
}

.app {
  width: min(var(--game-width), calc(100vw - 32px));
  min-height: auto;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
}

.hidden {
  display: none !important;
}

.start-screen,
.game-screen {
  width: 100%;
}

.start-screen {
  display: grid;
  gap: 22px;
  max-width: 560px;
}

.start-screen {
  background: rgba(255, 250, 241, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 8px;
  padding: 25px 28px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.top-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 18px;
  width: 100%;
  color: var(--ink);
}

.top-panel {
  padding: 0;
}

.game-screen {
  display: grid;
  gap: 26px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 24px;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1;
}

h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1;
}

.lead {
  max-width: 34rem;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.7;
}

.control-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.control-label {
  margin: 0;
}

.segmented {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.level-btn,
.actions button,
.start-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
}

.level-btn {
  width: 100%;
  min-height: 78px;
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px;
  text-align: left;
  background: rgba(245, 234, 216, 0.92);
  border: 1px solid #dec7a3;
  font-weight: 800;
}

.level-btn.is-active {
  color: var(--ink);
  background: #fffaf1;
  border-color: #d3a82b;
  box-shadow: inset 0 0 0 2px #d3a82b;
}

.level-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 1.25rem;
  font-weight: 900;
}

.level-btn strong,
.level-btn small {
  display: block;
}

.level-btn strong {
  font-size: 1.05rem;
}

.level-btn small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.start-button {
  min-height: 56px;
  color: #fff;
  background: #271a13;
  font-weight: 900;
}

.title-row {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto;
  gap: 16px;
  align-items: end;
}

.status-box {
  display: grid;
  gap: 14px;
  align-items: center;
  margin: 0;
  padding: 15px;
  border-radius: 8px;
  background: #f5ead8;
  border: 1px solid #dec7a3;
}

.status-row {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 12px;
  align-items: center;
}

.status-box p {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
  line-height: 1.45;
}

.turn-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #171717;
  box-shadow: inset -3px -3px 7px rgba(255, 255, 255, 0.2);
}

.turn-dot.white {
  background: #f2f0ea;
  border: 1px solid #b9ada0;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, 108px);
  gap: 10px;
  justify-content: flex-end;
}

.actions button {
  width: 108px;
  min-width: 0;
  background: #271a13;
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
}

.actions button:nth-child(2) {
  background: #7e322e;
}

.actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.board-wrap {
  position: relative;
  display: grid;
  place-items: center;
}

#board {
  width: min(var(--game-width), calc(100vw - 32px));
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 8px;
  box-shadow: none;
  cursor: crosshair;
  touch-action: manipulation;
}

.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: clamp(24px, 6vw, 72px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 300ms ease, visibility 0s linear 300ms;
}

.result-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 300ms ease;
}

.result-overlay img {
  width: min(78%, 600px);
  max-height: 42%;
  object-fit: contain;
  filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.34));
}

.replay-button {
  min-width: 132px;
  min-height: 44px;
  margin-top: 14px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: #271a13;
  cursor: pointer;
  font-weight: 900;
  pointer-events: auto;
}

.site-info {
  width: 100%;
  margin-top: 10px;
  color: #ffffff;
  font-size: 0.9rem;
  line-height: 1.65;
}

.site-info p {
  margin: 0 0 8px;
}

.site-info h3 {
  margin: 18px 0 8px;
  padding-bottom: 7px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.42);
  color: #ffffff;
  font-size: 1.1rem;
}

@media (max-width: 1280px) {
  .game-layout {
    width: min(100%, calc(100vw - 32px));
    grid-template-columns: minmax(0, var(--game-width));
    gap: 0;
  }

  .side-rail {
    display: none;
  }
}

@media (max-width: 850px) {
  .game-layout {
    padding-top: 90px;
  }

  .app {
    place-items: start center;
  }

  .start-screen {
    padding: 20px;
  }

  h1 {
    margin-bottom: 18px;
  }

  .title-row {
    grid-template-columns: 1fr;
  }

  .actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .actions button {
    width: 100%;
  }
}
