:root {
  --bg: #f6f3ed;
  --ink: #202124;
  --muted: #64666a;
  --line: #d8d2c8;
  --surface: #fffdf8;
  --dark-square: #4f684f;
  --light-square: #e8d8bc;
  --accent: #1f6f78;
  --danger: #9f3030;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.landing {
  display: grid;
  place-items: center;
  padding: 1rem;
}

.landing-panel,
.app-shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
}

.landing-panel {
  display: grid;
  gap: 1rem;
}

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

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 8vw, 5rem);
  line-height: 1;
}

.landing-panel p {
  max-width: 38rem;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.primary-button {
  color: #fff;
  background: var(--accent);
}

.secondary-button {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.danger-button {
  color: #fff;
  background: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  padding: 1rem 0;
}

.game-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.status-line {
  margin: 0.6rem 0 0;
  color: var(--muted);
}

.game-title {
  color: var(--ink);
  font-size: clamp(2.2rem, 8vw, 4.6rem);
  font-weight: 900;
  line-height: 0.95;
  text-decoration: none;
}

.game-title:hover {
  text-decoration: underline;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.16em;
}

.header-actions,
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(280px, 72vh) minmax(260px, 1fr);
  gap: 1rem;
  align-items: start;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  border: 2px solid #243525;
  width: min(100%, 72vh);
  touch-action: manipulation;
  overflow: hidden;
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  aspect-ratio: 1;
}

.light {
  background: var(--light-square);
}

.dark {
  background: var(--dark-square);
}

.selected {
  outline: 4px solid #f3ce4d;
  outline-offset: -4px;
}

.movable .piece {
  outline: 3px solid rgba(243, 206, 77, 0.95);
  outline-offset: 3px;
}

.waiting-movable .piece {
  outline: 3px solid rgba(243, 206, 77, 0.95);
  outline-offset: 3px;
}

.target::after {
  content: "";
  width: 26%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.piece {
  display: grid;
  place-items: center;
  width: 72%;
  aspect-ratio: 1;
  border-radius: 999px;
  font-size: clamp(0.75rem, 3vw, 1.2rem);
  font-weight: 900;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.14), 0 6px 12px rgba(0, 0, 0, 0.22);
}

.anim-hidden .piece {
  visibility: hidden;
}

.animated-piece {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  transition: transform 200ms ease-in-out;
}

.white-piece {
  color: #202124;
  background: #f6f3e7;
}

.black-piece {
  color: #fff;
  background: #202124;
}

.king {
  border: 3px solid #d9b744;
}

.side-panel {
  display: grid;
  gap: 1rem;
}

.players {
  display: grid;
  gap: 0.6rem;
}

.player-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.player-row span,
.message {
  color: var(--muted);
}

.message {
  min-height: 1.4rem;
  margin: 0;
}

@media (max-width: 760px) {
  .game-header,
  .game-layout {
    display: grid;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .board {
    width: 100%;
  }

  .header-actions,
  .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
