:root {
  --navy: #092f56;
  --ink: #233044;
  --muted: #6f788d;
  --gold: #c58a25;
  --gold-light: #f0c35b;
  --purple: #2d1b57;
  --cream: #fff8eb;
  --blue: #25aafc;
  --cell: clamp(30px, 5.9vw, 62px);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #f5ead7, #eef3f0);
  font-family: "Poppins", "Segoe UI", Arial, sans-serif;
}

body > :not(#penrose) {
  position: relative;
  z-index: 1;
}

#penrose {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

a {
  text-decoration: none;
}

.viking-header {
  display: flex;
  width: min(1180px, calc(100% - 36px));
  margin: 22px auto 0;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border: 1px solid rgba(255,255,255,0.72);
  border-radius: 28px;
  background:
    radial-gradient(circle at 12% 0%, rgba(240,195,91,0.18), transparent 34%),
    linear-gradient(135deg, rgba(255,255,255,0.78), rgba(232,244,249,0.58));
  box-shadow: 0 18px 44px rgba(5,33,62,0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: var(--navy);
  font: 800 clamp(16px, 2.2vw, 22px)/1.05 Georgia, "Times New Roman", serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: clamp(40px, 4.8vw, 52px);
  height: clamp(40px, 4.8vw, 52px);
  flex: 0 0 clamp(40px, 4.8vw, 52px);
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(12, 48, 82, 0.12);
  border-radius: 14px 14px 17px 17px;
  background: #fbf4e9;
  box-shadow: 0 8px 18px rgba(12, 48, 82, 0.16);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
  transform: none;
}

.viking-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-button {
  display: inline-flex;
  min-width: 126px;
  height: 44px;
  padding: 8px 16px;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(9,47,86,0.26);
  border-radius: 999px;
  color: var(--navy);
  background:
    radial-gradient(circle at 18% 12%, rgba(244,199,93,0.22), transparent 34%),
    linear-gradient(135deg, rgba(255,253,247,0.9), rgba(229,242,250,0.72));
  box-shadow:
    0 8px 18px rgba(5,33,62,0.11),
    inset 0 1px 0 rgba(255,255,255,0.92);
  font: 700 15px/1 "Poppins", "Segoe UI", Arial, sans-serif;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.nav-button:hover,
.nav-button:focus-visible {
  border-color: rgba(161,62,62,0.5);
  box-shadow: 0 10px 22px rgba(106,38,54,0.14);
  transform: translateY(-1px);
}

.nav-button.primary {
  border-color: rgba(197,138,37,0.42);
  color: #ffffff;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
}

.difficulty-control {
  display: grid;
  width: 176px;
  min-height: 44px;
  padding: 7px 12px 8px;
  border: 1.5px solid rgba(9,47,86,0.2);
  border-radius: 18px;
  color: var(--navy);
  background:
    radial-gradient(circle at 18% 12%, rgba(244,199,93,0.18), transparent 36%),
    linear-gradient(135deg, rgba(255,253,247,0.88), rgba(229,242,250,0.7));
  box-shadow:
    0 8px 18px rgba(5,33,62,0.1),
    inset 0 1px 0 rgba(255,255,255,0.9);
  gap: 3px;
}

.difficulty-control span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.difficulty-control strong {
  font-size: 13px;
  line-height: 1;
}

.difficulty-control input {
  width: 100%;
  accent-color: var(--gold);
  cursor: pointer;
}

.viking-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 28px auto 50px;
}

.hero-panel,
.board-card,
.rules-card {
  border: 1px solid rgba(255,255,255,0.78);
  background:
    radial-gradient(circle at 18% 8%, rgba(240,195,91,0.16), transparent 30%),
    linear-gradient(135deg, rgba(255,255,255,0.74), rgba(236,247,253,0.56));
  box-shadow:
    0 18px 44px rgba(5,33,62,0.14),
    inset 0 1px 0 rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: clamp(22px, 4vw, 36px);
  border-radius: 30px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font: 800 12px/1.2 "Poppins", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  color: var(--navy);
  font: 800 clamp(42px, 7vw, 78px)/0.92 Georgia, "Times New Roman", serif;
}

h2 {
  margin-bottom: 14px;
  color: var(--navy);
  font: 800 28px/1.05 Georgia, "Times New Roman", serif;
}

.intro {
  max-width: 600px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(16px, 2.2vw, 20px);
  line-height: 1.45;
}

.turn-card {
  min-width: min(290px, 100%);
  padding: 18px 20px;
  border: 1px solid rgba(9,47,86,0.14);
  border-radius: 22px;
  color: var(--navy);
  background: rgba(255,255,255,0.72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.88);
}

.turn-card span,
.score-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.turn-card strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.turn-card small {
  display: inline-flex;
  margin-top: 12px;
  padding: 6px 10px;
  border: 1px solid rgba(197,138,37,0.28);
  border-radius: 999px;
  color: var(--navy);
  background: rgba(255,248,235,0.74);
  font-size: 12px;
  font-weight: 800;
}

.turn-card.defenders {
  border-color: rgba(37,170,252,0.28);
}

.turn-card.finished {
  border-color: rgba(197,138,37,0.5);
  background: rgba(255,248,230,0.86);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  margin-top: 22px;
  align-items: start;
}

body.rules-hidden .game-layout {
  grid-template-columns: minmax(0, 1fr);
}

body.rules-hidden .rules-card {
  display: none;
}

.board-card,
.rules-card {
  border-radius: 30px;
}

.board-card {
  padding: clamp(16px, 3vw, 28px);
  overflow-x: auto;
}

.board-legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.board-stage {
  display: grid;
  grid-template-columns: minmax(92px, 120px) auto minmax(92px, 120px);
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: max-content;
}

.board-capture-counter {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 10px;
  border: 1px solid rgba(45, 27, 87, 0.14);
  border-radius: 20px;
  color: var(--navy);
  background:
    radial-gradient(circle at 50% 0%, rgba(240, 195, 91, 0.2), transparent 58%),
    linear-gradient(135deg, rgba(255, 252, 243, 0.78), rgba(232, 246, 255, 0.66));
  box-shadow:
    0 14px 28px rgba(5, 33, 62, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.board-capture-counter span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.25;
  text-align: center;
  text-transform: uppercase;
}

.board-capture-counter strong {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(45, 27, 87, 0.16);
  border-radius: 16px;
  font-family: "Georgia", serif;
  font-size: 26px;
  line-height: 1;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(255, 248, 235, 0.76));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.84);
}

.tafl-board {
  display: grid;
  box-sizing: content-box;
  width: calc(var(--cell) * 11);
  grid-template-columns: repeat(11, var(--cell));
  grid-template-rows: repeat(11, var(--cell));
  margin: 0 auto;
  padding: 8px;
  border: 2px solid rgba(45,27,87,0.28);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 50%, rgba(240,195,91,0.18), transparent 30%),
    linear-gradient(135deg, rgba(45,27,87,0.18), rgba(255,248,235,0.5));
  box-shadow:
    0 18px 36px rgba(5,33,62,0.16),
    inset 0 0 0 8px rgba(255,255,255,0.22);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(56, 52, 74, 0.12);
  color: var(--navy);
  background:
    linear-gradient(135deg, rgba(255,252,243,0.9), rgba(226,236,230,0.74));
  cursor: default;
}

.cell:nth-child(odd) {
  background:
    linear-gradient(135deg, rgba(244,235,215,0.9), rgba(236,245,246,0.8));
}

.cell.corner,
.cell.throne {
  background:
    radial-gradient(circle, rgba(240,195,91,0.42), transparent 52%),
    linear-gradient(135deg, rgba(45,27,87,0.84), rgba(9,47,86,0.76));
}

.cell.corner::before,
.cell.throne::before {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 14px;
  background:
    rgba(255,248,235,0.9)
    url("../assets/images/psybites-logo.png")
    center 42% / 88% auto
    no-repeat;
  box-shadow:
    0 0 14px rgba(240,195,91,0.44),
    inset 0 1px 0 rgba(255,255,255,0.72);
}

.cell.corner::after {
  content: none;
}

.cell.legal {
  cursor: pointer;
  background:
    radial-gradient(circle, rgba(37,170,252,0.28), transparent 45%),
    linear-gradient(135deg, rgba(255,255,255,0.92), rgba(223,243,255,0.86));
}

.cell.legal::after {
  content: "";
  position: absolute;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgba(37,170,252,0.72);
  inset: auto;
  border: 0;
  transform: none;
  box-shadow: none;
}

.piece {
  position: relative;
  z-index: 2;
  width: 96%;
  height: 96%;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  overflow: visible;
  clip-path: none;
  background: center / contain no-repeat;
  filter: drop-shadow(0 8px 7px rgba(24,24,32,0.18));
}

.piece.attacker {
  background-image: url("../assets/images/viking-rook-piece.png");
  filter:
    saturate(0.75)
    brightness(0.72)
    contrast(1.12)
    drop-shadow(0 8px 7px rgba(24,24,32,0.18));
}

.piece.defender {
  background-image: url("../assets/images/viking-rook-piece.png");
  filter:
    saturate(0.85)
    brightness(1.18)
    contrast(0.92)
    drop-shadow(0 8px 7px rgba(24,24,32,0.18));
}

.piece.attacker::before,
.piece.attacker::after,
.piece.defender::before,
.piece.defender::after {
  content: none;
}

.piece.king {
  width: 106%;
  height: 106%;
  clip-path: none;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background-image: url("../assets/images/viking-king-shield-piece.png");
  filter: drop-shadow(0 8px 7px rgba(24,24,32,0.2));
}

.piece.king::before {
  content: none;
}

.piece.king::after {
  content: none;
}

.piece.selected {
  outline: 3px solid rgba(37,170,252,0.82);
  outline-offset: 3px;
  transform: scale(1.05);
}

.piece.just-moved {
  animation: piece-move 0.22s ease-out;
}

@keyframes piece-move {
  from {
    transform: translate(
      calc(var(--move-x, 0) * var(--cell)),
      calc(var(--move-y, 0) * var(--cell))
    ) scale(0.96);
  }
  to {
    transform: translate(0, 0) scale(1);
  }
}

.notation-panel {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 14px;
  width: calc(var(--cell) * 11 + 20px);
  margin: 16px auto 0;
  padding: 14px;
  border: 1px solid rgba(9,47,86,0.12);
  border-radius: 18px;
  background: rgba(255,255,255,0.64);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.notation-panel .eyebrow {
  margin-bottom: 4px;
}

.notation-panel p:last-child {
  margin: 0;
  color: var(--navy);
  font-weight: 800;
}

.notation-panel ol {
  display: flex;
  min-width: 0;
  margin: 0;
  padding: 0;
  gap: 8px;
  align-items: center;
  list-style: none;
  overflow-x: auto;
}

.notation-panel li {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(9,47,86,0.1);
  border-radius: 999px;
  color: #3d465c;
  background: rgba(255,255,255,0.66);
  font-size: 12px;
  font-weight: 800;
}

.rules-card {
  padding: 24px;
}

.rules-card ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}

.score-grid div {
  padding: 14px;
  border: 1px solid rgba(9,47,86,0.12);
  border-radius: 18px;
  background: rgba(255,255,255,0.66);
}

.score-grid strong {
  display: block;
  margin-top: 8px;
  color: var(--navy);
  font-size: 28px;
}

@media (max-width: 900px) {
  .viking-header,
  .hero-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .viking-actions {
    width: 100%;
    justify-content: stretch;
  }

  .nav-button {
    flex: 1 1 120px;
  }

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

@media (max-width: 560px) {
  :root {
    --cell: min(7.6vw, 38px);
  }

  .viking-header,
  .viking-shell {
    width: min(100% - 18px, 1180px);
  }

  .brand {
    font-size: 15px;
  }

  .board-legend {
    display: none;
  }

  .notation-panel {
    width: calc(var(--cell) * 11 + 10px);
    grid-template-columns: 1fr;
  }

  .board-stage {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    min-width: 0;
  }

  .board-capture-counter {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 8px;
  }

  .board-capture-counter strong {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    font-size: 22px;
  }

  .tafl-board {
    grid-column: 1 / -1;
    padding: 5px;
    border-radius: 18px;
  }
}
