:root {
  color-scheme: light;
  --bg: #f7f8f8;
  --paper: #ffffff;
  --paper-soft: rgba(255, 255, 255, 0.8);
  --ink: #121820;
  --muted: #66717c;
  --quiet: #8d949d;
  --line: rgba(18, 24, 32, 0.13);
  --line-strong: rgba(18, 24, 32, 0.22);
  --gold: #b28a46;
  --teal: #1e6a78;
  --teal-bright: #20b2aa;
  --teal-soft: rgba(32, 178, 170, 0.14);
  --green: #287d54;
  --coral: #c96c5b;
  --shadow: 0 24px 70px rgba(18, 24, 32, 0.09);
  --max: 1180px;
  --radius: 8px;
  --ease: cubic-bezier(0.19, 1, 0.22, 1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 16% 18%, rgba(32, 178, 170, 0.17), transparent 18rem),
    radial-gradient(circle at 82% 16%, rgba(178, 138, 70, 0.15), transparent 16rem),
    linear-gradient(135deg, #ffffff 0%, var(--bg) 52%, #eef4f3 100%);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

svg {
  display: block;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header,
.blocks-shell,
.site-footer {
  width: min(var(--max), calc(100% - 44px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
}

.brand,
.site-nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 14px;
  color: #075f68;
  font-size: 18px;
  font-weight: 560;
}

.brand-mark {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 2px solid var(--teal-bright);
  border-radius: 999px;
  background: linear-gradient(145deg, #ffffff, rgba(32, 178, 170, 0.14));
  box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.72);
}

.site-nav {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 28px;
  color: var(--muted);
  font-size: 14px;
}

.site-nav a {
  position: relative;
  display: inline-flex;
  min-height: 38px;
  align-items: center;
}

.site-nav a::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: var(--gold);
  content: "";
  opacity: 0;
  transform: scaleX(0.4);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
}

.site-nav a[aria-current="page"]::after {
  opacity: 1;
  transform: scaleX(1);
}

.blocks-shell {
  display: grid;
  gap: 14px;
  padding: clamp(18px, 3vw, 36px) 0 42px;
}

.intro-panel,
.board-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-soft);
  box-shadow: var(--shadow);
}

.intro-panel {
  position: relative;
  display: grid;
  overflow: hidden;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  gap: 28px;
  align-items: end;
  padding: clamp(20px, 3vw, 32px);
}

.intro-panel::before {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, transparent 0 44%, rgba(32, 178, 170, 0.1) 44% 45%, transparent 45% 100%),
    radial-gradient(circle at 80% 22%, rgba(178, 138, 70, 0.15), transparent 15rem);
  content: "";
  pointer-events: none;
}

.intro-panel > * {
  position: relative;
  min-width: 0;
}

.back-link {
  display: inline-flex;
  margin-bottom: 20px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 650;
}

h1,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  color: #075f68;
  font-size: clamp(38px, 5vw, 64px);
  font-weight: 590;
  letter-spacing: 0;
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.intro-panel p {
  max-width: 660px;
  margin-top: 16px;
  color: var(--muted);
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.55;
}

.sponsor-slot {
  display: grid;
  min-height: 86px;
  align-content: center;
  gap: 6px;
  padding: 18px;
  border: 1px dashed rgba(30, 106, 120, 0.32);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(32, 178, 170, 0.07), rgba(178, 138, 70, 0.06)),
    rgba(255, 255, 255, 0.62);
}

.sponsor-slot span,
.panel-heading span,
.hud-row span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sponsor-slot strong {
  font-size: 15px;
  font-weight: 680;
}

.sponsor-slot small,
.panel p,
.rules-list {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
  gap: 14px;
  align-items: start;
}

.board-panel {
  display: grid;
  gap: 14px;
  overflow: hidden;
  padding: clamp(14px, 2vw, 20px);
}

.hud-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.hud-row article {
  display: grid;
  min-height: 68px;
  place-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.84);
}

.hud-row strong {
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 610;
  line-height: 1;
}

.canvas-wrap {
  position: relative;
  display: grid;
  min-height: clamp(520px, 72vw, 760px);
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(30, 106, 120, 0.18);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(240, 248, 247, 0.92)),
    repeating-linear-gradient(90deg, rgba(30, 106, 120, 0.06) 0 1px, transparent 1px 32px);
}

#blocksCanvas {
  display: block;
  width: min(100%, 420px);
  max-height: 76vh;
  aspect-ratio: 1 / 2;
  touch-action: none;
}

.start-overlay {
  position: absolute;
  inset: auto clamp(16px, 6vw, 72px);
  top: 50%;
  display: grid;
  gap: 8px;
  padding: 22px;
  border: 1px solid rgba(30, 106, 120, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 50px rgba(18, 24, 32, 0.1);
  text-align: center;
  transform: translateY(-50%);
  transition:
    opacity 160ms ease,
    transform 160ms var(--ease),
    visibility 160ms ease;
}

.start-overlay.is-hidden {
  opacity: 0;
  transform: translateY(-44%);
  visibility: hidden;
}

.start-overlay span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.start-overlay strong {
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 640;
}

.start-overlay p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.block-actions,
.touch-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.block-actions button,
.touch-controls button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(30, 106, 120, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  color: var(--teal);
  font-weight: 720;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms var(--ease);
}

.block-actions button {
  padding: 0 16px;
}

.touch-controls button {
  width: 54px;
}

.touch-controls svg {
  width: 21px;
}

.touch-controls path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.block-actions button:hover,
.block-actions button:focus-visible,
.touch-controls button:hover,
.touch-controls button:focus-visible {
  border-color: rgba(178, 138, 70, 0.54);
  background: #ffffff;
  outline: none;
  transform: translateY(-1px);
}

.primary-action {
  background: linear-gradient(135deg, var(--teal), var(--teal-bright)) !important;
  color: #ffffff !important;
}

body[data-page="game"] .block-actions button:not(.primary-action),
body[data-page="game"] .touch-controls button {
  border-color: rgba(241, 241, 238, 0.2);
  background: rgba(0, 0, 0, 0.34);
  color: #f1f1ee;
}

body[data-page="game"] .block-actions button:not(.primary-action):hover,
body[data-page="game"] .touch-controls button:hover {
  border-color: rgba(240, 232, 128, 0.48);
  background: rgba(241, 241, 238, 0.1);
  color: #ffffff;
}

body[data-page="game"] .block-actions button:focus-visible,
body[data-page="game"] .touch-controls button:focus-visible {
  outline: 2px solid #f0e880;
  outline-offset: 3px;
}

.side-stack {
  display: grid;
  gap: 14px;
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.panel-heading {
  display: grid;
  gap: 6px;
}

.panel-heading strong {
  font-size: 18px;
  font-weight: 650;
}

#nextCanvas {
  width: 100%;
  max-width: 190px;
  justify-self: center;
  border: 1px solid rgba(30, 106, 120, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.rules-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 18px;
}

.site-footer {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  color: var(--quiet);
  font-size: 13px;
}

.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 520ms ease,
    transform 520ms var(--ease);
}

.js .reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 920px) {
  .site-header,
  .blocks-shell,
  .site-footer {
    width: min(100% - 28px, var(--max));
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding: 16px 0;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 18px;
    font-size: 13px;
  }

  .intro-panel,
  .play-layout {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    min-height: min(720px, 150vw);
  }

  .hud-row {
    grid-template-columns: repeat(5, minmax(58px, 1fr));
    overflow-x: auto;
  }

  .hud-row article {
    min-width: 58px;
  }

  #blocksCanvas {
    width: min(100%, 360px);
  }

  .site-footer {
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
