:root {
  --ink: #1f150f;
  --paper: #f7f0e2;
  --panel: #fbf5e9;
  --line: #d6b892;
  --accent: #cf5930;
  --accent-2: #f0a969;
  --green: #2e7c5b;
  --wood-1: #cc9863;
  --wood-2: #9f6538;
  --triangle-dark: #7d4020;
  --triangle-light: #e7b679;
  --glow: #ffe07f;
  --button-top: #ef9560;
  --button-bottom: #bf552f;
  --button-border: #7f3c22;
  --button-text: #fff6ed;
}

body[data-theme="slate"] {
  --panel: #f5f7fb;
  --line: #b8c3d2;
  --accent: #2f6ec7;
  --accent-2: #83a8e8;
  --green: #2a7d65;
  --wood-1: #9ca8be;
  --wood-2: #64728a;
  --triangle-dark: #374e75;
  --triangle-light: #d8e3f6;
  --glow: #9ec2ff;
  --button-top: #5f89d1;
  --button-bottom: #355f9e;
  --button-border: #27477d;
  --button-text: #eef5ff;
}

body[data-theme="emerald"] {
  --panel: #f4fbf7;
  --line: #9ec6b2;
  --accent: #1f8f68;
  --accent-2: #5fc6a0;
  --green: #1a8a67;
  --wood-1: #87bb9b;
  --wood-2: #40735a;
  --triangle-dark: #1f5e4c;
  --triangle-light: #bce4d2;
  --glow: #95ebbe;
  --button-top: #3ca97d;
  --button-bottom: #247154;
  --button-border: #1b5741;
  --button-text: #ebfff6;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Trebuchet MS", "Segoe UI", "Gill Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 9%, #ffefd4 0, transparent 30%),
    radial-gradient(circle at 92% 16%, #f4cb95 0, transparent 38%),
    linear-gradient(162deg, #ecd8be 0%, #d3af84 50%, #b3794a 100%);
}

body[data-theme="slate"] {
  background:
    radial-gradient(circle at 18% 8%, rgba(224, 235, 253, 0.95) 0, transparent 35%),
    radial-gradient(circle at 82% 16%, rgba(168, 189, 226, 0.65) 0, transparent 36%),
    linear-gradient(162deg, #d8dde8 0%, #bbc6d9 45%, #8a98b1 100%);
}

body[data-theme="emerald"] {
  background:
    radial-gradient(circle at 16% 8%, rgba(216, 246, 230, 0.9) 0, transparent 33%),
    radial-gradient(circle at 84% 12%, rgba(131, 210, 171, 0.55) 0, transparent 36%),
    linear-gradient(162deg, #cfe7d7 0%, #9ac7ad 45%, #5a9279 100%);
}

.hidden {
  display: none !important;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(72, 41, 16, 0.18);
}

button {
  border: 1px solid var(--button-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 32%),
    linear-gradient(180deg, var(--button-top) 0%, var(--button-bottom) 100%);
  color: var(--button-text);
  border-radius: 11px;
  padding: 0.56rem 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 3px 8px rgba(0, 0, 0, 0.18);
}

button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

button.accent {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0) 30%),
    linear-gradient(180deg, #2f9f71 0%, #216a4c 100%);
  border-color: #19543c;
}

button.danger {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 28%),
    linear-gradient(180deg, #c54545 0%, #8d2424 100%);
  border-color: #6d1c1c;
}

button.muted {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 28%),
    linear-gradient(180deg, #7a6658 0%, #655245 100%);
  border-color: #4e3c32;
}

.cover-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  padding: 1.2rem;
}

.cover-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 25% 35%, rgba(255, 242, 215, 0.52), transparent 45%),
    radial-gradient(circle at 80% 45%, rgba(255, 187, 122, 0.38), transparent 44%),
    linear-gradient(125deg, rgba(36, 20, 9, 0.72), rgba(70, 39, 18, 0.48));
}

.cover-card {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  border-radius: 24px;
  padding: clamp(1.4rem, 3vw, 2.2rem);
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 236, 209, 0.48), transparent 38%),
    linear-gradient(165deg, #2f2218 0%, #3d2b1f 40%, #26180f 100%);
  border: 1px solid rgba(242, 189, 133, 0.38);
  box-shadow: 0 20px 40px rgba(11, 8, 5, 0.42);
  color: #fdf0dc;
}

.cover-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: #f5c48e;
}

.cover-card h1 {
  margin: 0.3rem 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
}

.cover-subtitle {
  margin: 0 0 1.3rem;
  color: #f7d8b5;
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.cover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.cover-primary {
  min-width: 170px;
}

.cover-secondary {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 26%),
    linear-gradient(180deg, #6b4f39 0%, #4f3828 100%);
  border-color: #3f2e23;
}

.cover-meta {
  margin-top: 1rem;
}

.cover-leaderboard {
  margin-top: 1rem;
  border: 1px solid rgba(245, 203, 154, 0.34);
  border-radius: 14px;
  background: rgba(255, 241, 218, 0.08);
  padding: 0.75rem;
}

.cover-leaderboard h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #ffdcb6;
}

.leaderboard-list {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.24rem;
  color: #f7e2c4;
  font-size: 0.92rem;
}

.account-row {
  margin-top: 0.65rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.account-row input {
  flex: 1;
  min-width: 180px;
  border-radius: 9px;
  border: 1px solid rgba(247, 206, 161, 0.5);
  background: rgba(255, 250, 242, 0.92);
  padding: 0.45rem 0.55rem;
  color: #2b1d13;
  font: inherit;
}

.cover-account-status {
  margin: 0.45rem 0 0;
  min-height: 1.2rem;
  color: #f4d6b3;
  font-size: 0.9rem;
}
.text-link {
  background: transparent;
  color: #f7cea1;
  border: 1px solid rgba(247, 206, 161, 0.46);
}

.game-shell {
  width: min(1700px, 100%);
  margin: 0 auto;
  padding: 0.7rem;
  display: grid;
  gap: 0.75rem;
}

.control-deck {
  padding: 0.85rem;
  background: linear-gradient(160deg, #fffaf1 0%, #f5ead7 100%);
}

.deck-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.top-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.title-cluster {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
}

.title-cluster h2 {
  margin: 0;
  font-size: 1.32rem;
}

.badge {
  border-radius: 999px;
  background: #f4e1c5;
  border: 1px solid #cda87f;
  padding: 0.26rem 0.72rem;
  font-size: 0.84rem;
  font-weight: 700;
}

.badge-turn {
  background: #ebf8ee;
  border-color: #86b493;
}

.command-row {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.danger-row {
  margin-top: 0.42rem;
  display: flex;
  justify-content: flex-end;
}

.dice-row {
  margin-top: 0.65rem;
}

.dice-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.die {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  border: 1px solid rgba(33, 26, 19, 0.68);
  background:
    radial-gradient(circle at 30% 26%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.72) 48%, rgba(238, 228, 210, 0.95) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 4px 8px rgba(0, 0, 0, 0.22);
  perspective: 420px;
}

.die-grid {
  width: 80%;
  height: 80%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.pip {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #2a1b10;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32);
  justify-self: center;
  align-self: center;
}

.p1 {
  grid-column: 1;
  grid-row: 1;
}

.p2 {
  grid-column: 2;
  grid-row: 1;
}

.p3 {
  grid-column: 3;
  grid-row: 1;
}

.p4 {
  grid-column: 1;
  grid-row: 2;
}

.p5 {
  grid-column: 2;
  grid-row: 2;
}

.p6 {
  grid-column: 3;
  grid-row: 2;
}

.p7 {
  grid-column: 1;
  grid-row: 3;
}

.p8 {
  grid-column: 2;
  grid-row: 3;
}

.p9 {
  grid-column: 3;
  grid-row: 3;
}

.die.selected {
  box-shadow: inset 0 0 0 2px rgba(53, 141, 97, 0.7), 0 0 0 2px rgba(53, 141, 97, 0.32), 0 4px 8px rgba(0, 0, 0, 0.22);
}

.die.used {
  opacity: 0.45;
}

@keyframes dieSwap {
  0% {
    transform: rotateY(0deg);
  }

  50% {
    transform: rotateY(180deg) scale(1.05);
  }

  100% {
    transform: rotateY(360deg);
  }
}

.die.swapping {
  animation: dieSwap 360ms cubic-bezier(0.18, 0.78, 0.3, 1);
}

@keyframes diceShake {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  18% {
    transform: translate(-2px, -1px) rotate(-8deg) scale(1.04);
  }

  37% {
    transform: translate(3px, 2px) rotate(10deg) scale(1.07);
  }

  56% {
    transform: translate(-2px, 2px) rotate(-8deg) scale(1.03);
  }

  75% {
    transform: translate(2px, -1px) rotate(7deg) scale(1.05);
  }

  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

.die.rolling {
  animation: diceShake 120ms linear infinite;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 9px 16px rgba(0, 0, 0, 0.26);
}

.move-guide {
  margin: 0.65rem 0 0;
  color: #4f4537;
  background: #fff2df;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}

.board-stage {
  padding: 0.75rem;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.score-card {
  border: 1px solid #d6b892;
  border-radius: 11px;
  background: #fffdf8;
  padding: 0.45rem 0.62rem;
}

.score-card p {
  margin: 0.18rem 0;
}

.board-layout {
  display: grid;
  grid-template-columns: minmax(130px, 160px) 1fr minmax(130px, 160px);
  grid-template-areas: "black board white";
  gap: 0.55rem;
  align-items: stretch;
}

.board-layout.turn-flipped {
  grid-template-areas: "white board black";
}

#blackOffTray {
  grid-area: black;
}

#whiteOffTray {
  grid-area: white;
}

#board {
  grid-area: board;
}

.off-tray.side {
  min-height: 620px;
  border: 2px solid #744a2d;
  border-radius: 14px;
  background: linear-gradient(180deg, #f3ddbf 0%, #e2c198 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  color: #3a2719;
  position: relative;
}

.off-tray .tray-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.off-tray .tray-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.off-tray .tray-value {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.08;
}

.off-tray .tray-sub {
  font-size: 0.85rem;
  color: #5b4635;
}

.off-tray .checker.ghost-preview {
  margin-top: 0.45rem;
}

.board {
  background: linear-gradient(180deg, var(--wood-1), var(--wood-2));
  border: 5px solid #714628;
  border-radius: 16px;
  padding: 0.7rem;
  box-shadow: inset 0 0 0 2px rgba(255, 243, 220, 0.22);
  transition: transform 260ms ease;
}

.board.is-flipped {
  transform: rotate(180deg);
}

.board.is-flipped .point-label,
.board.is-flipped .checker,
.board.is-flipped .checker-count,
.board.is-flipped .bar-slot,
.board.is-flipped .block-marker {
  transform: rotate(180deg);
}

.board-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr) 0.92fr repeat(6, 1fr);
  gap: 0.33rem;
  min-height: 302px;
}

.board-row + .board-row {
  margin-top: 0.33rem;
}

.point {
  position: relative;
  border-radius: 9px;
  border: 1px solid rgba(72, 35, 12, 0.45);
  background: rgba(255, 245, 227, 0.12);
  cursor: pointer;
  overflow: hidden;
}

.point.top {
  display: flex;
  flex-direction: column;
}

.point.bottom {
  display: flex;
  flex-direction: column-reverse;
}

.point::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 71%;
  opacity: 0.38;
  z-index: 0;
}

.point.top::before {
  top: 0;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}

.point.bottom::before {
  bottom: 0;
  clip-path: polygon(0 100%, 100% 100%, 50% 0);
}

.point.dark::before {
  background: var(--triangle-dark);
}

.point.light::before {
  background: var(--triangle-light);
}

.point-label {
  position: absolute;
  left: 5px;
  right: 5px;
  z-index: 3;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(28, 17, 10, 0.88);
  text-shadow: 0 1px 0 rgba(255, 244, 227, 0.6);
}

.point.top .point-label {
  bottom: 4px;
}

.point.bottom .point-label {
  top: 4px;
}

.checker-stack {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0.24rem;
  min-height: 100%;
}

.point.top .checker-stack {
  flex-direction: column;
  justify-content: flex-start;
}

.point.bottom .checker-stack {
  flex-direction: column-reverse;
  justify-content: flex-start;
}

.checker {
  width: min(62px, 100%);
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  border: 1px solid rgba(29, 21, 15, 0.7);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.34), 0 2px 3px rgba(0, 0, 0, 0.4);
}

.checker.white {
  background: radial-gradient(circle at 30% 28%, #fffefc 0%, #eee7de 58%, #d6cabd 100%);
}

.checker.black {
  background: radial-gradient(circle at 30% 28%, #625953 0%, #2e2723 60%, #171412 100%);
}

.checker.ghost-preview {
  opacity: 0.34;
  border-style: dashed;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.28), 0 0 0 2px rgba(255, 227, 140, 0.25);
}

.checker-count {
  min-width: 34px;
  border-radius: 999px;
  padding: 0 0.45rem;
  background: rgba(18, 11, 7, 0.84);
  color: #fff5e7;
  font-size: 0.72rem;
  text-align: center;
}

.block-marker {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 6;
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  font-size: 0.67rem;
  font-weight: 700;
  color: #fff;
  background: rgba(36, 138, 99, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.point.source-available,
.bar-slot.source-available {
  outline: 2px solid #7ce3a7;
  outline-offset: -2px;
}

.point.source-selected,
.bar-slot.source-selected {
  outline: 3px solid #ffe298;
  outline-offset: -3px;
}

.point.preview-destination,
.off-tray.preview-destination {
  box-shadow: inset 0 0 0 2px rgba(255, 224, 127, 0.45);
}

.point.destination-available,
.off-tray.destination-available {
  outline: 3px solid var(--glow);
  outline-offset: -3px;
}

@keyframes recentSourcePulse {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }

  45% {
    transform: scale(0.985);
    filter: brightness(1.14);
  }

  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes recentDestPulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 rgba(255, 216, 110, 0);
  }

  40% {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 216, 110, 0.56);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(255, 216, 110, 0);
  }
}

.point.recent-source,
.bar-slot.recent-source {
  animation: recentSourcePulse 350ms ease;
}

.point.recent-dest .checker-stack,
.off-tray.recent-dest,
.bar-slot.recent-dest {
  animation: recentDestPulse 420ms ease;
}

.bar-cell {
  border: 1px solid rgba(67, 31, 12, 0.55);
  border-radius: 10px;
  background: rgba(47, 23, 8, 0.36);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.3rem;
}

.bar-slot {
  width: 100%;
  border-radius: 8px;
  border: 1px dashed rgba(255, 236, 203, 0.34);
  padding: 0.35rem;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.76rem;
  color: #f8e8cf;
  font-weight: 700;
  background: rgba(50, 20, 5, 0.38);
}

.bar-slot.clickable {
  box-shadow: inset 0 0 0 2px rgba(116, 227, 160, 0.5);
  cursor: pointer;
}

.hint {
  margin: 0.7rem 0 0;
  color: #5b4f3e;
  font-size: 0.92rem;
}

.status-text {
  margin: 0.5rem 0 0;
  background: #fff3df;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  min-height: 2.2rem;
  padding: 0.56rem 0.72rem;
  color: #6b3920;
}

.rules-dialog {
  border: none;
  padding: 0;
  background: transparent;
}

.rules-dialog::backdrop {
  background: rgba(9, 8, 6, 0.62);
}

.rules-card {
  width: min(700px, 94vw);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff9ee;
  padding: 1rem;
  box-shadow: 0 16px 28px rgba(20, 11, 6, 0.32);
}

.rules-card h3 {
  margin: 0 0 0.6rem;
}

.rules-content p {
  margin: 0.45rem 0;
  color: #4f463b;
}

.settings-card {
  width: min(840px, 96vw);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  font-weight: 700;
  color: #4a3c2f;
}

.settings-grid select,
.settings-grid input[type="number"] {
  border: 1px solid #bda286;
  border-radius: 9px;
  padding: 0.45rem 0.52rem;
  font: inherit;
  background: #fff;
  color: #2f2418;
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 0.45rem !important;
  font-weight: 700;
  border: 1px solid #e6d4bc;
  border-radius: 10px;
  background: #fffaf2;
  padding: 0.52rem;
}

.rules-card menu {
  margin: 0.8rem 0 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  padding: 0;
}

.ghost-checker {
  position: fixed;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(34, 25, 16, 0.7);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2500;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.35), 0 4px 8px rgba(0, 0, 0, 0.35);
}

.ghost-checker.white {
  background: radial-gradient(circle at 30% 28%, #fffefc 0%, #eee7de 58%, #d6cabd 100%);
}

.ghost-checker.black {
  background: radial-gradient(circle at 30% 28%, #625953 0%, #2e2723 60%, #171412 100%);
}

.ghost-checker.hit {
  box-shadow: 0 0 0 3px rgba(255, 188, 111, 0.35), inset 0 2px 3px rgba(255, 255, 255, 0.32), 0 4px 9px rgba(0, 0, 0, 0.35);
}

@media (max-width: 1320px) {
  .off-tray.side {
    min-height: 520px;
  }

  .board-row {
    min-height: 250px;
  }

  .checker {
    width: min(50px, 100%);
  }
}

@media (max-width: 1024px) {
  .game-shell {
    padding: 0.5rem;
  }

  .board-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "black"
      "board"
      "white";
  }

  .board-layout.turn-flipped {
    grid-template-areas:
      "white"
      "board"
      "black";
  }

  .off-tray.side {
    min-height: 96px;
  }

  .off-tray .tray-inner {
    flex-direction: row;
    gap: 0.6rem;
  }

  .board-row {
    min-height: 190px;
    gap: 0.23rem;
  }

  .checker {
    width: min(37px, 100%);
  }
}

@media (max-width: 760px) {
  .cover-card {
    border-radius: 16px;
  }

  .die {
    width: 50px;
    height: 50px;
  }

  .pip {
    width: 7px;
    height: 7px;
  }

  .board-row {
    min-height: 148px;
    gap: 0.14rem;
  }

  .point-label {
    font-size: 0.6rem;
  }

  .checker {
    width: min(27px, 100%);
  }

  .ghost-checker {
    width: 26px;
    height: 26px;
  }
}

