/* ============================================================
   ---------------- Snake Club / Visual Foundation -------------
   ============================================================ */
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&family=Outfit:wght@400;500;600;700;800;900&display=swap");
:root {
  --ink: #202942;
  --muted: #777e94;
  --blue: #346df1;
  --line: #e2e6ef;
  --paper: #fff;
  --board-a: #eaf0ff;
  --board-b: #e3ebfc;
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background: #f4f6fc;
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
}
button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button {
  color: inherit;
  border: 0;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #f3b83f;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button:active {
  transform: translateY(2px);
}
button,
a {
  touch-action: manipulation;
}
button {
  transition:
    background 0.18s,
    box-shadow 0.18s,
    transform 0.18s;
}
a {
  color: inherit;
  text-decoration: none;
}
[hidden] {
  display: none !important;
}
.app {
  max-width: 1480px;
  padding: 0 40px;
  margin: auto;
}
.header {
  height: 98px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: flex;
  gap: 13px;
  align-items: center;
}
.wordmark > svg {
  width: 42px;
  height: 42px;
  color: var(--blue);
}
.wordmark > span {
  font:
    800 31px/1 "Outfit",
    sans-serif;
  letter-spacing: -1.3px;
}
.logo-club {
  color: var(--blue);
}
.wordmark small {
  display: block;
  font:
    700 8px/1.8 "DM Sans",
    sans-serif;
  letter-spacing: 3px;
  margin-top: 5px;
}
.header-actions {
  display: flex;
  gap: 9px;
  align-items: center;
}
.local-label {
  font-size: 9px;
  letter-spacing: 1.5px;
  font-weight: 700;
  color: #9499a9;
  margin-right: 20px;
}
.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  font-size: 20px;
  flex-shrink: 0;
}
.icon-button:hover {
  background: #eaf0ff;
}
.game-shell {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 42px;
  margin-top: 32px;
}
.setup {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 23px;
  align-self: start;
  max-height: calc(100dvh - 160px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #d8deeb transparent;
}
.eyebrow {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #858ba0;
}
.setup-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.setup h1 {
  font:
    700 27px/1.2 "Outfit",
    sans-serif;
  letter-spacing: -0.8px;
  margin: 6px 0 19px;
}
.mobile-close {
  display: none;
}
.tabs {
  display: flex;
  background: #f1f3f9;
  border-radius: 11px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 20px;
}
.tabs button {
  flex: 1;
  background: none;
  border-radius: 8px;
  padding: 9px 6px;
  font-weight: 700;
  font-size: 12px;
  color: #858ba0;
}
.tabs button[aria-pressed="true"] {
  color: #26324d;
  background: #fff;
  box-shadow: 0 2px 5px #26324d0c;
}
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.preset {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 12px;
  border: 1.5px solid #e9ecf3;
  border-radius: 12px;
  background: white;
  gap: 8px;
  min-height: 83px;
  position: relative;
}
.preset .preset-icon {
  font:
    600 22px "Outfit",
    sans-serif;
  color: var(--blue);
}
.preset strong {
  font-size: 11px;
  font-weight: 700;
}
.preset:hover {
  background: #f4f7ff;
}
.preset[aria-pressed="true"] {
  border-color: #7299ff;
  background: #f0f5ff;
}
.preset[aria-pressed="true"]:after {
  content: "";
  position: absolute;
  right: 10px;
  top: 13px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--blue);
}
.selected-note {
  display: flex;
  align-items: start;
  gap: 8px;
  margin: 15px 0;
}
.selected-note p {
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0;
}
.mini-dot {
  width: 5px;
  height: 5px;
  background: #f2b858;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.secondary {
  padding: 11px 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 11px;
  font-weight: 700;
}
.secondary:hover {
  background: #f1f5ff;
}
.full {
  width: 100%;
}
.quiet {
  font-size: 10px;
  line-height: 1.65;
  color: #9297a8;
}
.primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 15px 22px;
  color: #fff;
  background: var(--blue);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 0 #2250be;
}
.primary:hover {
  background: #255ee1;
  box-shadow: 0 5px 0 #1a49b6;
}
.primary:active {
  box-shadow: 0 1px 0 #2250be;
}
.setup-footer {
  position: sticky;
  bottom: -23px;
  background: white;
  padding: 16px 0 8px;
  margin-top: 5px;
  border-top: 1px solid var(--line);
  z-index: 2;
}
.setup-footer p {
  font-size: 9px;
  text-align: center;
  color: #9a9faf;
  margin: 12px 0 0;
}
.arena-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.arena-heading h2 {
  font:
    700 32px/1.1 "Outfit",
    sans-serif;
  letter-spacing: -1px;
  margin: 6px 0 0;
}
.arena-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.arena-actions .secondary {
  padding: 13px 15px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.play-area {
  min-width: 0;
}
.game-card {
  background: white;
  border: 1px solid #dde3f0;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 12px 34px #30446908;
}
.scorebar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 17px 24px;
  height: 72px;
}
.fruit-score {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.fruit-score img {
  width: 32px;
  height: 32px;
}
.fruit-score strong {
  font:
    700 29px "Outfit",
    sans-serif;
}
.fruit-score > span {
  color: #a1a7b8;
  font-size: 13px;
}
.progress {
  height: 5px;
  width: 100%;
  max-width: 180px;
  background: #edf0f7;
  border-radius: 5px;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  background: var(--blue);
  width: 0%;
  transition: width 0.3s;
}
.best-score {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}
.best-score span {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #949bae;
}
.best-score strong {
  font:
    600 21px "Outfit",
    sans-serif;
}
.board-wrap {
  position: relative;
  margin: 0 14px;
  border-radius: 13px;
  overflow: hidden;
  background: var(--board-a);
  height: clamp(300px, calc(100dvh - 400px), 640px);
  min-height: 300px;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none !important;
}
.board-bottom {
  height: 43px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 0 24px;
  font-size: 9px;
  color: #8f98ae;
}
.board-bottom i {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: #69af90;
  border-radius: 50%;
  margin-right: 6px;
}
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #eaf0ff70;
  backdrop-filter: blur(2px);
}
.overlay-card {
  text-align: center;
  padding: 20px;
  max-width: 360px;
}
.overlay-eyebrow {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #627ba9;
}
.overlay h2 {
  font:
    800 clamp(44px, 5.3vw, 74px) / 0.95 "Outfit",
    sans-serif;
  letter-spacing: -3px;
  margin: 17px 0;
}
.overlay h2 span {
  color: var(--blue);
}
.overlay p {
  font-size: 12px;
  line-height: 1.7;
  color: #7182a0;
}
.overlay .primary {
  margin: 22px auto 16px;
  min-width: 190px;
}
.overlay-keys {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.overlay-keys span {
  margin-left: 8px;
  font-size: 10px;
}
kbd {
  font:
    600 9px "DM Sans",
    sans-serif;
  border: 1px solid #d6dfef;
  border-radius: 5px;
  min-width: 22px;
  padding: 4px;
  display: inline-block;
  background: #ffffff90;
  color: #687990;
  text-align: center;
}
.play-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin: 17px 3px;
  font-size: 10px;
  color: #8b94a9;
}
.play-footer b {
  margin: 0 6px;
  color: #b6becc;
}
.footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 0;
  font-size: 9px;
  color: #969db0;
}
.footer > span:nth-child(2) {
  font-size: 8px;
  letter-spacing: 2px;
}
.text-button {
  background: none;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}
.touch-pad {
  display: none;
}
.toast {
  position: absolute;
  top: 13px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 30px;
  padding: 9px 15px;
  background: #fff;
  box-shadow: 0 5px 15px #20356718;
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  animation: toast 1.8s ease forwards;
}
@keyframes toast {
  10%,
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    translate: 0 -6px;
  }
}
.world-position {
  position: absolute;
  bottom: 12px;
  left: 12px;
  font:
    600 9px "DM Sans",
    sans-serif;
  color: #7182a0;
  background: #ffffffb8;
  padding: 5px 9px;
  border-radius: 6px;
  pointer-events: none;
}
/* ============================================================
   ---------------- Rules & Visual Customization ---------------
   ============================================================ */
[data-panel] label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin: 13px 0;
  color: #64708a;
}
input[type="number"],
select {
  width: 100%;
  border: 1px solid #dce2ee;
  border-radius: 9px;
  background: #f8faff;
  color: #27364f;
  padding: 10px;
  font-size: 11px;
  margin-top: 6px;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
  margin: 12px 0 0;
}
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.field-row label {
  flex: 1;
  min-width: 0;
}
.multiply {
  margin-top: 16px;
  color: #a3aabc;
}
.field-hint {
  font-size: 10px;
  line-height: 1.65;
  color: #9aa1b2;
  margin: 0 0 15px;
}
.range-label output {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: #8c95a9;
  margin-top: 4px;
}
fieldset {
  padding: 10px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0 0;
}
legend {
  font-size: 11px;
  font-weight: 700;
  padding: 0 10px 0 0;
}
[data-panel] .check {
  display: flex;
  gap: 9px;
  align-items: start;
  line-height: 1.5;
}
.check input {
  accent-color: var(--blue);
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}
.check small {
  display: block;
  font-size: 10px;
  color: #9a9faf;
  font-weight: 400;
  line-height: 1.5;
  margin-top: 2px;
}
.field-title {
  font-size: 12px;
  margin: 22px 0 10px;
}
.fruit-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.fruit-choice {
  background: #f4f6fb;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 5px;
}
.fruit-choice img {
  width: 100%;
  display: block;
}
.fruit-choice[aria-pressed="true"] {
  border-color: var(--blue);
  background: #edf3ff;
}
.color-grid {
  display: flex;
  gap: 8px;
}
.color-choice {
  width: 32px;
  height: 32px;
  background: var(--swatch);
  border: 4px solid #fff;
  outline: 1px solid #e7eaf3;
  border-radius: 50%;
}
.color-choice[aria-pressed="true"] {
  outline: 2px solid var(--blue);
}
[data-panel] .custom-color {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
}
input[type="color"] {
  width: 35px;
  height: 28px;
  border: 0;
  background: none;
  padding: 0;
}
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.theme-choice {
  background: var(--tile);
  color: var(--tile-ink);
  border: 1px solid #dbe1ef;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  padding: 14px 4px;
}
.theme-choice[aria-pressed="true"] {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
dialog {
  max-width: 470px;
  width: 92vw;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px;
  color: var(--ink);
  box-shadow: 0 30px 100px #1d2b5044;
}
dialog::backdrop {
  background: #22315277;
  backdrop-filter: blur(5px);
}
dialog h2 {
  font:
    700 32px "Outfit",
    sans-serif;
  letter-spacing: -1px;
}
dialog p {
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
}
.close-help {
  float: right;
}
.game-card:fullscreen {
  border-radius: 0;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.game-card:fullscreen .board-wrap {
  height: auto;
  flex: 1;
  width: 100%;
  margin: 0;
}
.game-card:fullscreen .board-bottom {
  flex-shrink: 0;
}
/* ============================================================
   ---------------- Portrait & Reduced Motion ------------------
   ============================================================ */
@media (min-width: 1051px) {
  body.settings-hidden .game-shell {
    grid-template-columns: 1fr;
  }
  body.settings-hidden .setup {
    display: none;
  }
  body.settings-hidden .play-area {
    max-width: 1000px;
    width: 100%;
    margin: auto;
  }
}
@media (max-width: 1050px) {
  .app {
    padding: 0 24px;
  }
  .game-shell {
    grid-template-columns: 252px minmax(0, 1fr);
    gap: 22px;
  }
  .setup {
    padding: 18px;
  }
  .setup-footer {
    bottom: -18px;
  }
  .local-label {
    display: none;
  }
  .board-wrap {
    height: clamp(320px, calc(100dvh - 350px), 570px);
  }
  .arena-actions .secondary {
    gap: 10px;
  }
  .arena-heading h2 {
    font-size: 28px;
  }
  .scorebar {
    padding: 14px;
  }
  .board-bottom {
    padding: 0 14px;
  }
  .progress {
    max-width: 110px;
  }
  .footer > span:nth-child(2) {
    display: none;
  }
}
@media (max-width: 760px) {
  .app {
    padding: 0 15px;
  }
  .header {
    height: 78px;
  }
  .wordmark > span {
    font-size: 27px;
  }
  .wordmark svg {
    width: 35px;
  }
  .game-shell {
    display: block;
    margin-top: 22px;
  }
  .setup {
    display: none;
    position: fixed;
    inset: 12px 12px 18px;
    z-index: 10;
    max-height: none;
    box-shadow: 0 0 0 100vmax #23335480;
    border-radius: 20px;
    padding: 22px;
  }
  .setup.open {
    display: block;
  }
  .setup-heading h1 {
    font-size: 29px;
  }
  .mobile-close {
    display: grid;
  }
  .setup-footer {
    bottom: -22px;
  }
  .preset-grid {
    grid-template-columns: 1fr 1fr;
  }
  .preset {
    min-height: 85px;
  }
  .arena-heading {
    margin-bottom: 14px;
  }
  .arena-heading h2 {
    font-size: 27px;
  }
  .arena-actions .icon-button {
    width: 37px;
    height: 37px;
  }
  .arena-actions .secondary {
    padding: 10px;
    font-size: 10px;
  }
  .board-wrap {
    height: clamp(280px, calc(100dvh - 325px), 560px);
    min-height: 240px;
    margin: 0 9px;
    border-radius: 10px;
  }
  .game-card {
    border-radius: 16px;
  }
  .scorebar {
    height: 57px;
    gap: 15px;
  }
  .fruit-score img {
    width: 25px;
  }
  .fruit-score strong {
    font-size: 24px;
  }
  .fruit-score > span {
    font-size: 11px;
  }
  .best-score strong {
    font-size: 18px;
  }
  .progress {
    max-width: 130px;
  }
  .board-bottom {
    font-size: 8px;
    height: 32px;
  }
  .overlay h2 {
    font-size: 54px;
  }
  .overlay-eyebrow {
    font-size: 8px;
  }
  .overlay p {
    font-size: 11px;
  }
  .overlay .primary {
    margin: 16px auto 10px;
    padding: 13px 20px;
  }
  .overlay-keys {
    display: none !important;
  }
  .touch-pad {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
    margin: 13px auto 0;
  }
  .touch-pad > div {
    display: flex;
    gap: 9px;
  }
  .touch-pad button {
    width: 53px;
    height: 44px;
    background: #fff;
    border: 1px solid #dce3f1;
    box-shadow: 0 3px 0 #dce3f1;
    border-radius: 11px;
    font-size: 22px;
    color: #4b6395;
    touch-action: none;
  }
  .play-footer {
    margin: 13px 0;
    font-size: 9px;
    justify-content: center;
  }
  .play-footer > span:first-child {
    display: none;
  }
  .footer {
    padding: 14px 0;
    font-size: 8px;
    border-top: 1px solid var(--line);
  }
  .fruit-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  .fruit-choice img {
    max-width: 50px;
    margin: auto;
  }
  .color-grid {
    gap: 12px;
  }
  .theme-choice {
    padding: 20px;
  }
  .setup [data-panel="rules"] {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
  }
  .setup [data-panel="rules"] > .field-row,
  .setup [data-panel="rules"] > .field-hint,
  .setup fieldset,
  .setup .range-label {
    grid-column: 1/-1;
  }
  .setup .quiet {
    margin-bottom: 20px;
  }
  .setup-footer .primary {
    padding: 16px 22px;
  }
}
@media (max-width: 370px) {
  .app {
    padding: 0 10px;
  }
  .arena-actions {
    gap: 5px;
  }
  .arena-actions .secondary span {
    display: none;
  }
  .arena-heading h2 {
    font-size: 24px;
  }
  .header-actions .icon-button {
    width: 35px;
    height: 35px;
  }
  .overlay h2 {
    font-size: 45px;
  }
  .progress {
    max-width: 70px;
  }
  .wordmark small {
    letter-spacing: 2px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.overlay[data-state="ready"] {
  background: transparent;
  backdrop-filter: none;
}

@media (max-width: 760px) {
  .board-wrap {
    height: min(105vw, 43dvh);
    min-height: 260px;
  }
  .overlay-card {
    padding: 16px 24px;
  }
  .overlay h2 {
    font-size: 46px;
    margin: 12px 0;
  }
  .overlay-eyebrow {
    font-size: 7px;
    letter-spacing: 1.5px;
  }
  .overlay p {
    font-size: 10px;
  }
}
@media (max-width: 760px) {
  .setup {
    height: calc(100dvh - 30px);
    align-self: auto;
  }
  .setup [data-panel="rules"] > label {
    grid-column: 1/-1;
  }
}

.board-wrap[data-theme="midnight"] .overlay{background:#202a4860}
.board-wrap[data-theme="midnight"] .overlay h2{color:#f4f7ff}
.board-wrap[data-theme="midnight"] .overlay h2 span{color:#88aaff}
.board-wrap[data-theme="midnight"] .overlay p,.board-wrap[data-theme="midnight"] .overlay-eyebrow{color:#bdcceb}

/* Keep the endless camera square on every device. */
.board-wrap.infinite-view { aspect-ratio: 1; height: auto; width: min(100%, 65dvh); margin-inline: auto; }
