:root {
  --ink: #29231c;
  --muted: #766d61;
  --paper: #f6f1e7;
  --panel: #fffaf0;
  --line: #dfd0bb;
  --wood: #8a5c32;
  --teal: #2f8f83;
  --teal-dark: #21685f;
  --red: #e9574f;
  --blue: #3f79cc;
  --gold: #f2b84b;
  --green: #71a95a;
  --shadow: 0 18px 45px rgba(77, 55, 30, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Noto Sans CJK SC",
    system-ui,
    sans-serif;
  background:
    radial-gradient(circle at 18% 16%, rgba(242, 184, 75, 0.18), transparent 24rem),
    linear-gradient(135deg, #f7f0df 0%, #edf4ea 45%, #f6f1e7 100%);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.app-shell {
  width: min(1220px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.brand {
  display: grid;
  gap: 2px;
}

.eyebrow,
.info-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  letter-spacing: 0;
}

.top-actions,
.panel-footer {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: stretch;
}

.table-wrap {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(138, 92, 50, 0.32);
  border-radius: 8px;
  background: #d9be8d;
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
}

.match-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.9);
  box-shadow: var(--shadow);
  padding: 14px;
}

.score-board {
  display: grid;
  gap: 8px;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 12px;
}

.score-row strong {
  display: block;
  margin-top: 2px;
  font-size: 30px;
  line-height: 1;
}

.score-row.player {
  border-left: 5px solid var(--red);
}

.score-row.ai {
  border-left: 5px solid var(--blue);
}

.side-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.shot-pips {
  display: flex;
  gap: 6px;
  min-width: 66px;
  justify-content: flex-end;
}

.shot-pips span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #c9b89f;
  background: transparent;
}

.shot-pips span.used.player {
  border-color: var(--red);
  background: var(--red);
}

.shot-pips span.used.ai {
  border-color: var(--blue);
  background: var(--blue);
}

.info-block,
.turn-box,
.event-log {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 12px;
}

.info-block {
  display: grid;
  gap: 6px;
}

.info-block h2 {
  font-size: 22px;
  line-height: 1.15;
}

.info-block p,
.turn-box {
  color: #4c4339;
  font-size: 15px;
  line-height: 1.45;
}

.turn-box {
  min-height: 52px;
  display: flex;
  align-items: center;
  font-weight: 700;
}

.event-log {
  min-height: 110px;
}

.event-log div {
  display: grid;
  gap: 7px;
}

.event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.event-item b {
  color: var(--ink);
  font-size: 14px;
}

.panel-footer {
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.panel-footer strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

.primary-button {
  padding: 0 18px;
  color: #fffaf0;
  background: var(--teal);
  box-shadow: 0 10px 18px rgba(47, 143, 131, 0.22);
}

.secondary-button {
  padding: 0 16px;
  border: 1px solid rgba(138, 92, 50, 0.35);
  background: #fffaf0;
}

.icon-button {
  width: 42px;
  background: var(--gold);
  color: #3a2812;
  font-size: 23px;
  line-height: 1;
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.secondary-button:active,
.icon-button:active {
  transform: translateY(0);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px));
  border-radius: 8px;
  background: rgba(41, 35, 28, 0.92);
  color: #fffaf0;
  padding: 12px 16px;
  box-shadow: 0 12px 30px rgba(41, 35, 28, 0.25);
  font-weight: 700;
}

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

  .match-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .score-board,
  .panel-footer {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1220px);
    padding: 12px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .match-panel {
    grid-template-columns: 1fr;
  }
}
