:root {
  --red: #E01B22;
  --green: #1FA34A;
  --yellow: #F4C20D;
  --blue: #1F6FD6;
  --board-bg: #0f2e22;
  --line: rgba(0, 0, 0, 0.18);
  --panel: #13241d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at 20% 10%, #1f6b3f 0%, transparent 40%),
    radial-gradient(circle at 85% 90%, #0c5a35 0%, transparent 45%),
    linear-gradient(135deg, #08160f, #0c2419);
  color: #f4f4ef;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ============ Setup screen ============ */
.setup-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}
.setup-card {
  width: min(520px, 94vw);
  background: linear-gradient(160deg, #14352455, #0a1c13ee);
  border: 2px solid #1f6b3f;
  border-radius: 22px;
  padding: 28px 30px 32px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}
.title {
  font-size: clamp(34px, 7vw, 52px);
  letter-spacing: 3px;
  margin: 0;
  text-align: center;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 #0a1c13;
}
.title span { color: var(--green); }
.subtitle {
  text-align: center;
  margin: 6px 0 22px;
  color: #bcd9c4;
  font-size: 14px;
}
.setup-step { margin-bottom: 18px; }
.setup-step h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #d7f0dd;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.opt-btn {
  flex: 1 1 0;
  min-width: 110px;
  padding: 13px 12px;
  border-radius: 12px;
  border: 2px solid #2c6b48;
  background: #0e241a;
  color: #e7f4ea;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
}
.opt-btn:hover { transform: translateY(-2px); }
.opt-btn.active {
  border-color: var(--green);
  background: linear-gradient(180deg, #1c5e3a, #114327);
  box-shadow: 0 0 0 3px rgba(31, 163, 74, 0.25);
}
.opt-btn.club {
  border-color: var(--c);
  color: #fff;
}
.opt-btn.club.active {
  background: var(--c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 35%, transparent);
}
.team-row { flex-wrap: wrap; }
.team-row .opt-btn { flex: 1 1 40%; }
.hint { font-size: 13px; color: #9dc1a8; margin: 10px 2px 0; }
.start-btn {
  display: block;
  width: 100%;
  margin-top: 22px;
  padding: 15px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, #2bbd63, #149247);
  color: #04240f;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow: 0 10px 24px rgba(20, 146, 71, 0.4);
  transition: transform .12s;
}
.start-btn:hover { transform: translateY(-2px); }

/* ============ Game layout ============ */
.game-wrap {
  display: flex;
  gap: 26px;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  flex-wrap: wrap;
}
.board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}
.board-title {
  font-size: clamp(26px, 5vw, 40px);
  letter-spacing: 3px;
  margin: 0;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 #0a1c13;
  text-align: center;
}
.board-title span { color: #1FA34A; }
.site-url {
  text-align: center;
  font-size: 12px;
  letter-spacing: 1px;
  color: #5a9e74;
  margin: -6px 0 0;
}
.board-area { flex: 0 0 auto; }

/* ============ Board ============ */
.board {
  position: relative;
  width: min(86vw, 600px);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  background: var(--board-bg);
  border: 10px solid #b6862c;
  border-radius: 12px;
  box-shadow: 0 0 0 4px #7c5a1c, 0 26px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.cell { border: 0.5px solid var(--line); }
.cell.blank { background: transparent; border-color: transparent; }
.cell.path { background: #f6f3e9; }
.cell.start { position: relative; }
.cell.start.red { background: var(--red); }
.cell.start.green { background: var(--green); }
.cell.start.yellow { background: var(--yellow); }
.cell.start.blue { background: var(--blue); }
.cell.home-col.red { background: color-mix(in srgb, var(--red) 62%, white); }
.cell.home-col.green { background: color-mix(in srgb, var(--green) 62%, white); }
.cell.home-col.yellow { background: color-mix(in srgb, var(--yellow) 70%, white); }
.cell.home-col.blue { background: color-mix(in srgb, var(--blue) 62%, white); }

/* Yards */
.yard {
  position: absolute;
  padding: 6%;
}
.yard.red { background: var(--red); }
.yard.green { background: var(--green); }
.yard.yellow { background: var(--yellow); }
.yard.blue { background: var(--blue); }
.yard .pad {
  width: 100%;
  height: 100%;
  background: #fbfaf4;
  border-radius: 14px;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}
.club-name {
  position: absolute;
  top: 6px;
  font-size: clamp(8px, 1.7vw, 12px);
  font-weight: 800;
  color: #333;
  letter-spacing: .5px;
  text-align: center;
}
.yard .slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18%;
  width: 64%;
  height: 64%;
  margin-top: 8%;
}
.yard .slots i {
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

/* Centre home */
.center-home {
  position: absolute;
  background: conic-gradient(from -45deg,
    var(--green) 0 90deg,
    var(--yellow) 90deg 180deg,
    var(--blue) 180deg 270deg,
    var(--red) 270deg 360deg);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
}
.center-home::after {
  content: "★";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(14px, 3vw, 26px);
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* ============ Tokens ============ */
.tokens { position: absolute; inset: 0; pointer-events: none; }
.token {
  position: absolute;
  width: 5%;
  height: 5%;
  transform: translate(-50%, -50%);
  transition: left .42s cubic-bezier(.34, 1.2, .5, 1), top .42s cubic-bezier(.34, 1.2, .5, 1);
  border-radius: 50%;
  display: grid;
  place-items: center;
  z-index: 5;
  pointer-events: none;
}
.token .tk-core {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.45), inset 0 -3px 5px rgba(0, 0, 0, 0.3);
}
.token.red .tk-core { background: radial-gradient(circle at 35% 30%, #ff6168, var(--red)); }
.token.green .tk-core { background: radial-gradient(circle at 35% 30%, #56d586, var(--green)); }
.token.yellow .tk-core { background: radial-gradient(circle at 35% 30%, #ffe27a, var(--yellow)); }
.token.blue .tk-core { background: radial-gradient(circle at 35% 30%, #69a8f5, var(--blue)); }
.token.finished { z-index: 8; }
.token.blocked .tk-core { border-color: #111; box-shadow: 0 0 0 2px #111, 0 3px 5px rgba(0,0,0,.5); }
.token.movable {
  pointer-events: auto;
  cursor: pointer;
  z-index: 9;
  animation: bob .8s ease-in-out infinite;
}
.token.movable .tk-core {
  border-color: #fff;
  box-shadow: 0 0 0 3px #fff, 0 0 14px 4px rgba(255, 255, 255, 0.8);
}
@keyframes bob {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -62%) scale(1.08); }
}
.token.kill-flash .tk-core {
  animation: killpulse .6s ease;
}
@keyframes killpulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 60, 60, 0.9); }
  100% { box-shadow: 0 0 0 22px rgba(255, 60, 60, 0); }
}
.kill-emoji {
  position: absolute;
  font-size: clamp(22px, 4.5vw, 36px);
  transform: translate(-50%, -130%);
  pointer-events: none;
  z-index: 20;
  animation: emoji-pop 0.9s ease forwards;
}
@keyframes emoji-pop {
  0%   { opacity: 0; transform: translate(-50%, -80%)  scale(0.2); }
  25%  { opacity: 1; transform: translate(-50%, -155%) scale(1.4); }
  55%  { opacity: 1; transform: translate(-50%, -140%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(0.7); }
}

/* ============ Dice bar (below board) ============ */
.dice-bar {
  width: min(86vw, 600px);
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(160deg, #16352455, #0b1c13);
  border: 1px solid #235138;
  border-radius: 16px;
  padding: 14px 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  flex-wrap: wrap;
}
.dice-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dice-pair {
  display: flex;
  gap: 14px;
}
@keyframes dice-row-appear {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dice-pair.appear {
  animation: dice-row-appear 0.3s ease forwards;
}
.bar-hint {
  flex: 1;
  margin: 0;
  min-width: 120px;
  font-size: 13px;
  color: #9dc1a8;
}

/* ============ Panel ============ */
.panel {
  width: 260px;
  flex: 0 0 260px;
  background: linear-gradient(170deg, #16352455, #0b1c13);
  border: 1px solid #235138;
  border-radius: 18px;
  padding: 18px 18px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.turn-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 2px solid #888;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  font-weight: 800;
  font-size: 16px;
}
.turn-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}
.dice {
  width: 62px; height: 62px;
  background: linear-gradient(160deg, #fff, #e2e2d6);
  border-radius: 14px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4), inset 0 -4px 8px rgba(0,0,0,.12);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 9px;
  gap: 3px;
  cursor: default;
  transition: transform .15s, box-shadow .15s;
}
.dice .pip { border-radius: 50%; }
.dice .pip.on { background: #16241c; box-shadow: inset 0 1px 1px rgba(255,255,255,.4); }
.dice.empty { opacity: .35; }
.dice.used { opacity: .4; filter: grayscale(.6); }
.dice.sel {
  cursor: pointer;
  transform: translateY(-3px);
  box-shadow: 0 0 0 3px var(--green), 0 10px 16px rgba(0,0,0,.4);
}
.dice.rolling { animation: shake .15s linear infinite; }
@keyframes shake {
  0% { transform: rotate(-12deg) translateY(-2px); }
  50% { transform: rotate(12deg) translateY(2px); }
  100% { transform: rotate(-12deg) translateY(-2px); }
}
.roll-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #f4c20d, #d39e00);
  color: #2a2100;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
  transition: transform .12s, filter .12s;
  white-space: nowrap;
}
.roll-btn:hover:not(:disabled) { transform: translateY(-2px); }
.roll-btn:disabled { filter: grayscale(.7) brightness(.8); cursor: not-allowed; }

.scores {
  margin: 16px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.score-row {
  display: grid;
  grid-template-columns: 18px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 14px;
}
.score-row.current {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
}
.score-row .dot { width: 14px; height: 14px; border-radius: 50%; }
.score-row .sname { font-weight: 700; }
.score-row .sctrl { font-size: 12px; color: #a9c9b3; }
.score-row .shome { font-weight: 800; color: #ffe27a; }

.restart-btn {
  margin-top: 14px;
  width: 100%;
  padding: 11px;
  border: 2px solid #3a6b4d;
  background: transparent;
  color: #cfead7;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}
.restart-btn:hover { background: rgba(255,255,255,.06); }

/* ============ Changelog ============ */
.changelog {
  margin-top: 18px;
  border-top: 1px solid #235138;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Header --- */
.cl-header-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cl-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cl-heading {
  font-family: "Bebas Neue", "Arial Black", Impact, sans-serif;
  font-size: 18px;
  letter-spacing: .06em;
  color: #e8f5ee;
  line-height: 1;
}
.cl-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  color: #d4a832;
  border: 1.5px solid #d4a832;
  border-radius: 20px;
  padding: 3px 8px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.cl-subtitle {
  font-size: 11px;
  color: #5a8a6e;
  margin: 0;
  line-height: 1.4;
}

/* --- List container --- */
.changelog-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #235138 transparent;
  padding-right: 2px;
}
.changelog-list::-webkit-scrollbar { width: 4px; }
.changelog-list::-webkit-scrollbar-track { background: transparent; }
.changelog-list::-webkit-scrollbar-thumb { background: #235138; border-radius: 2px; }

/* --- Date group --- */
.cl-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cl-date-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: #4d7a5e;
}

/* --- Entry card --- */
.cl-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px 11px;
}
.cl-icon-wrap {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}
.cl-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cl-card-title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  color: #6ee8a4;
}
.cl-card-desc {
  font-size: 11px;
  color: #6b9e7e;
  line-height: 1.45;
}


/* ============ Win overlay ============ */
.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 12, 8, 0.82);
  display: grid;
  place-items: center;
  z-index: 30;
}
.win-card {
  text-align: center;
  background: linear-gradient(160deg, #16352455, #0a1c13);
  border: 3px solid var(--green);
  border-radius: 22px;
  padding: 36px 44px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  max-width: 420px;
  width: 90vw;
}
.win-card .trophy { font-size: 72px; }
.win-card h2 { font-size: 34px; margin: 8px 0 10px; }

.win-narrative {
  font-style: italic;
  color: #7ecb9c;
  font-size: 15px;
  margin: 0 0 18px;
  min-height: 20px;
}

.win-stats-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
  text-align: left;
}

.stats-section {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
}
.stats-section-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5a9e74;
  margin-bottom: 10px;
}
.stats-section-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 64px;
  flex: 1 1 0;
}
.stat-pill .stat-val {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
}
.stat-pill .stat-label {
  font-size: 10px;
  color: #7ecb9c;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}

.share-btn {
  display: block;
  width: 100%;
  padding: 13px 0;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #25a244, #1a7a34);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: opacity 0.15s;
}
.share-btn:hover { opacity: 0.88; }
.share-btn:active { opacity: 0.75; }

.again-btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: 2px solid #3a6b4d;
  background: transparent;
  color: #cfead7;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.15s;
}
.again-btn:hover { background: rgba(255,255,255,.06); }

.share-confirm {
  font-size: 13px;
  color: #7ecb9c;
  font-style: italic;
  margin: 0 0 10px;
}

/* ============ Online multiplayer panel ============ */
.ol-step {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ol-action-btn {
  width: 100%;
  padding: 13px 0;
  font-size: 15px;
}

/* Code display */
.ol-code-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.ol-code-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  color: #4d7a5e;
  text-transform: uppercase;
}
.ol-code-display {
  font-family: "Courier New", Courier, monospace;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: .22em;
  color: #f0c020;
  text-align: center;
  padding: 10px 18px;
  background: rgba(240, 192, 32, 0.08);
  border: 2px solid rgba(240, 192, 32, 0.3);
  border-radius: 10px;
  user-select: all;
}

/* Join code input */
.ol-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ol-code-input {
  width: 100%;
  box-sizing: border-box;
  padding: 13px 14px;
  background: rgba(255,255,255,.06);
  border: 1.5px solid rgba(255,255,255,.15);
  border-radius: 10px;
  color: #e8f5ee;
  font-size: 22px;
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  letter-spacing: .2em;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: border-color .15s;
}
.ol-code-input:focus { border-color: #1fa34a; }
.ol-code-input::placeholder { letter-spacing: .15em; opacity: .4; font-size: 18px; }

/* Status / copy */
.ol-status-msg {
  text-align: center;
  font-size: 13px;
  color: #7ecb9c;
  margin: 0;
}
.ol-copy-btn {
  width: 100%;
  font-size: 13px;
  padding: 9px;
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.15);
  color: #a0d0b0;
}
.ol-copy-btn:hover { background: rgba(255,255,255,.05); }

/* Error */
.ol-error {
  font-size: 12px;
  color: #e05555;
  text-align: center;
  margin: 0;
}

/* ============ Disconnect overlay ============ */
.disconnect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 12, 8, 0.88);
  display: grid;
  place-items: center;
  z-index: 40;
}
.disconnect-card {
  background: #0d2218;
  border: 1px solid #235138;
  border-radius: 16px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 320px;
  text-align: center;
}
.disconnect-msg {
  font-size: 16px;
  color: #e8f5ee;
  margin: 0;
}

@media (max-width: 720px) {
  .game-wrap { flex-direction: column; align-items: center; padding: 14px; }
  .panel { width: min(86vw, 600px); flex: none; }
  .dice-bar { justify-content: center; }
  .token { width: 8%; height: 8%; }
}
