:root {
  color-scheme: dark;
  --bg: #050605;
  --surface: #0b0d0b;
  --surface-strong: #101410;
  --line: rgba(245, 245, 239, 0.18);
  --line-soft: rgba(245, 245, 239, 0.09);
  --text: #f5f5ef;
  --muted: #a9afa8;
  --green: #2ea35e;
  --green-bright: #44c875;
  --green-deep: #0f6f3d;
  --black: #111111;
  --max: 1800px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Helvetica Neue", Arial, system-ui, sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 auto auto 0;
  z-index: -1;
  width: 100%;
  height: 1px;
  background: rgba(245, 245, 239, 0.025);
  box-shadow:
    0 48px rgba(245, 245, 239, 0.025),
    0 96px rgba(245, 245, 239, 0.025),
    0 144px rgba(245, 245, 239, 0.025),
    0 192px rgba(245, 245, 239, 0.025),
    0 240px rgba(245, 245, 239, 0.025),
    0 288px rgba(245, 245, 239, 0.025),
    0 336px rgba(245, 245, 239, 0.025),
    0 384px rgba(245, 245, 239, 0.025),
    0 432px rgba(245, 245, 239, 0.025),
    0 480px rgba(245, 245, 239, 0.025),
    0 528px rgba(245, 245, 239, 0.025),
    0 576px rgba(245, 245, 239, 0.025),
    0 624px rgba(245, 245, 239, 0.025),
    0 672px rgba(245, 245, 239, 0.025),
    0 720px rgba(245, 245, 239, 0.025),
    0 768px rgba(245, 245, 239, 0.025),
    0 816px rgba(245, 245, 239, 0.025),
    0 864px rgba(245, 245, 239, 0.025),
    0 912px rgba(245, 245, 239, 0.025),
    0 960px rgba(245, 245, 239, 0.025),
    0 1008px rgba(245, 245, 239, 0.025);
}

img,
canvas {
  display: block;
  max-width: 100%;
}

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

p,
h1,
h2,
h3 {
  margin: 0;
}

p {
  color: var(--muted);
  font-size: clamp(1.05rem, 1.05vw, 1.34rem);
  line-height: 1.65;
}

h1,
h2 {
  font-weight: 650;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(4.25rem, 11vw, 10rem);
  line-height: 0.82;
}

h2 {
  font-size: clamp(2.15rem, 5.8vw, 5.6rem);
  line-height: 0.88;
}

.site-header,
.site-footer,
.section {
  width: min(calc(100% - clamp(48px, 5vw, 120px)), var(--max));
  margin-inline: auto;
}

.site-header {
  width: 100%;
  min-height: 82px;
  margin-inline: 0;
  padding: 12px max(clamp(28px, 4vw, 72px), calc((100vw - var(--max)) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(180deg, #0d3d24 0%, #17643b 100%);
  border-bottom: 1px solid rgba(245, 245, 239, 0.2);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.brand-logo {
  width: 154px;
  height: auto;
}

.site-nav,
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  column-gap: clamp(14px, 1.35vw, 22px);
  row-gap: 10px;
}

.site-nav a,
.site-footer a,
.text-link,
.document-links a {
  color: var(--text);
  font-size: clamp(0.82rem, 0.74rem + 0.18vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.site-nav a {
  color: var(--text);
}

.site-nav a[aria-current="page"],
.site-nav a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.auth-nav {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-left: 6px;
}

.auth-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.auth-menu[hidden] {
  display: none;
}

.auth-nav button,
.auth-menu-panel button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: clamp(0.82rem, 0.74rem + 0.18vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

@media (min-width: 980px) {
  .site-header {
    min-height: 100px;
    padding-block: 16px;
  }

  .brand-logo {
    width: 214px;
  }

  .site-nav,
  .site-footer nav {
    column-gap: clamp(14px, 1.3vw, 22px);
    row-gap: 10px;
  }
}

.auth-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.auth-menu-panel {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 176px;
  border: 1px solid rgba(245, 245, 239, 0.22);
  background: rgba(5, 6, 5, 0.96);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.28);
}

.auth-menu-panel[hidden] {
  display: none;
}

.auth-menu-panel a,
.auth-menu-panel button {
  display: block;
  width: 100%;
  padding: 13px 14px;
  text-align: left;
}

.auth-menu-panel a + a,
.auth-menu-panel a + button {
  border-top: 1px solid var(--line-soft);
}

.auth-nav button:hover,
.auth-menu-panel a:hover,
.auth-menu-panel button:hover {
  color: var(--green-bright);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.site-footer a:hover,
.text-link:hover,
.document-links a:hover {
  color: var(--green);
}

.section {
  padding: clamp(64px, 10vw, 132px) 0;
  border-top: 1px solid var(--line-soft);
}

.auth-hero h1 {
  font-size: clamp(4rem, 12vw, 9rem);
}

.auth-section {
  padding-top: clamp(42px, 7vw, 88px);
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.auth-card,
.profile-card,
.setup-notice {
  border: 1px solid var(--line);
  background: var(--surface);
}

.auth-card,
.profile-card {
  padding: clamp(22px, 4vw, 42px);
}

.auth-card h2 {
  font-size: clamp(2rem, 5vw, 4rem);
  margin-bottom: 28px;
}

.auth-card label {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.auth-card label span,
.profile-row span,
.profile-stat-grid span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-card input {
  border: 1px solid var(--line);
  background: #050605;
  color: var(--text);
  font: inherit;
  min-height: 48px;
  padding: 12px 14px;
}

.auth-card input:focus {
  border-color: var(--green);
  outline: 2px solid rgba(45, 143, 84, 0.34);
  outline-offset: 2px;
}

.auth-card .button {
  width: 100%;
  margin-top: 10px;
}

.auth-message,
.setup-notice {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
  margin-top: 24px;
}

.auth-message[data-type="error"] {
  color: #ffb4a9;
}

.auth-message[data-type="success"] {
  color: var(--green-bright);
}

.setup-notice {
  margin: 0 0 24px;
  padding: 16px 18px;
}

.setup-notice code {
  color: var(--text);
}

.profile-card {
  max-width: 760px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line-soft);
}

.profile-main strong {
  color: var(--green-bright);
}

.profile-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 28px;
  background: var(--line);
  border: 1px solid var(--line);
}

.profile-stat-grid div {
  display: grid;
  gap: 10px;
  min-height: 124px;
  align-content: center;
  background: #050605;
  padding: 18px;
}

.profile-row strong,
.profile-stat-grid strong {
  color: var(--text);
  font-size: clamp(1.5rem, 4vw, 3rem);
  line-height: 1;
}

.profile-action {
  margin-top: 24px;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.profile-actions .profile-action {
  margin-top: 0;
}

.leaderboard-section {
  padding-top: clamp(42px, 7vw, 88px);
}

.leaderboard-actions {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 18px;
}

.leaderboard-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--surface);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 540px;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: clamp(13px, 2vw, 18px) clamp(12px, 2.2vw, 20px);
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

.leaderboard-table th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.leaderboard-table td {
  color: var(--text);
  font-size: clamp(0.96rem, 1.6vw, 1.18rem);
  font-weight: 650;
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: 0;
}

.leaderboard-table td:first-child,
.leaderboard-table td:nth-child(3) {
  color: var(--green-bright);
}

.leaderboard-player-link {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: rgba(68, 200, 117, 0.42);
  text-underline-offset: 5px;
  transition: color 180ms ease, text-decoration-color 180ms ease;
}

.leaderboard-player-link:hover,
.leaderboard-player-link:focus-visible {
  color: var(--green-bright);
  text-decoration-color: var(--green-bright);
  outline: none;
}

.player-section {
  padding-top: clamp(42px, 7vw, 88px);
}

.public-player-card,
.match-history-card {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(13, 61, 36, 0.18) 0%, rgba(5, 6, 5, 0.92) 64%),
    var(--surface);
}

.public-player-card {
  padding: clamp(24px, 5vw, 52px);
}

.public-player-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(24px, 5vw, 72px);
  align-items: end;
  padding-bottom: clamp(24px, 4vw, 44px);
  border-bottom: 1px solid var(--line-soft);
}

.public-player-label,
.public-player-rating small,
.public-player-stats span,
.match-history-card span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.public-player-header h2 {
  margin-top: 12px;
  color: var(--text);
  font-size: clamp(3rem, 10vw, 8rem);
  line-height: 0.9;
  overflow-wrap: anywhere;
}

.public-player-share {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
}

.share-profile-button {
  min-height: 42px;
  border: 1px solid rgba(68, 200, 117, 0.46);
  background: rgba(5, 6, 5, 0.42);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  padding: 11px 14px;
  text-transform: uppercase;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.share-profile-button:hover,
.share-profile-button:focus-visible {
  border-color: var(--green-bright);
  background: rgba(15, 111, 61, 0.26);
  color: var(--green-bright);
  outline: none;
}

.share-profile-feedback {
  min-height: 1.2em;
  color: var(--green-bright);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0;
  text-transform: uppercase;
  transition: opacity 220ms ease;
}

.share-profile-feedback.is-visible {
  opacity: 1;
}

.public-player-rating {
  display: grid;
  justify-items: end;
  gap: 8px;
  text-align: right;
}

.public-player-rating span {
  width: fit-content;
  border: 1px solid rgba(68, 200, 117, 0.52);
  color: var(--green-bright);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  padding: 8px 10px;
  text-transform: uppercase;
}

.public-player-rating strong {
  color: var(--text);
  font-size: clamp(2.8rem, 7vw, 6rem);
  line-height: 0.9;
}

.public-player-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin-top: clamp(24px, 4vw, 44px);
  border: 1px solid var(--line);
  background: var(--line);
}

.public-player-stats div {
  display: grid;
  gap: 12px;
  min-height: 136px;
  align-content: center;
  background: #050605;
  padding: 18px;
}

.public-player-stats strong {
  color: var(--text);
  font-size: clamp(1.45rem, 3vw, 2.65rem);
  line-height: 1;
}

.match-history-card {
  display: grid;
  gap: 20px;
  margin-top: 24px;
  padding: clamp(22px, 4vw, 42px);
}

.match-history-card h2 {
  margin-top: 10px;
  font-size: clamp(2rem, 5vw, 4rem);
}

.match-history-card p {
  max-width: 560px;
}

.empty-state {
  display: grid;
  gap: 14px;
  align-items: start;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(13, 61, 36, 0.22) 0%, rgba(5, 6, 5, 0.96) 100%),
    var(--surface);
  padding: clamp(22px, 4vw, 42px);
}

.empty-state span,
.contact-card span {
  color: var(--green-bright);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.empty-state p {
  max-width: 560px;
  color: var(--text);
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  line-height: 1.35;
}

.empty-state .button {
  width: fit-content;
  margin-top: 8px;
}

.compact-empty {
  margin-top: 24px;
  padding: 22px;
}

.legal-section,
.contact-section {
  padding-top: clamp(42px, 7vw, 88px);
}

.legal-copy {
  display: grid;
  gap: 20px;
  max-width: 860px;
}

.legal-copy h2 {
  margin-top: 28px;
  font-size: clamp(1.6rem, 4vw, 3.2rem);
}

.legal-copy h2:first-child {
  margin-top: 0;
}

.legal-copy p {
  color: var(--text);
  font-size: clamp(1.05rem, 1.8vw, 1.28rem);
  line-height: 1.55;
}

.contact-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.55fr);
  gap: 24px;
}

.contact-card {
  display: grid;
  gap: 18px;
  align-content: start;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: clamp(24px, 4vw, 44px);
}

.contact-card strong {
  color: var(--text);
  font-size: clamp(2.2rem, 7vw, 5.6rem);
  line-height: 0.9;
  text-transform: uppercase;
}

.contact-card p {
  color: var(--text);
}

.contact-card .button {
  width: fit-content;
}

.secondary-contact {
  background:
    linear-gradient(180deg, rgba(13, 61, 36, 0.18) 0%, rgba(5, 6, 5, 0.98) 100%),
    var(--surface);
}

.hero {
  min-height: min(860px, calc(100svh - 76px));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  border-top: 0;
  padding-top: clamp(44px, 4.4vw, 84px);
}

.hero-copy {
  display: grid;
  grid-template-columns: minmax(520px, 0.9fr) minmax(480px, 0.86fr);
  align-items: start;
  justify-items: start;
  gap: clamp(56px, 7vw, 126px);
  width: 100%;
}

.hero-text {
  display: grid;
  gap: clamp(26px, 3vw, 42px);
  max-width: 860px;
}

.hero-photo {
  display: block;
  width: min(100%, 760px);
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 0;
  justify-self: end;
}

.hero-line {
  max-width: 860px;
  color: var(--ink);
  font-size: clamp(3rem, 3vw, 5rem);
  line-height: 0.98;
}

.hero-actions {
  display: grid;
  gap: 14px;
  justify-items: start;
  margin-top: 4px;
}

.hero-actions .button {
  width: 230px;
}

.hero-board,
.rules-diagram {
  border: 1px solid var(--line);
  background: var(--surface);
}

.hero-board {
  width: min(100%, 470px);
  justify-self: end;
  padding: clamp(10px, 2vw, 18px);
}

.button {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--green);
  background: linear-gradient(180deg, #0d3d24 0%, #17643b 100%);
  color: var(--text);
  padding: 0 22px;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.button.secondary {
  border-color: var(--line);
  background: transparent;
  color: var(--text);
}

.button:hover,
.button:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 3px;
}

.narrow {
  width: min(calc(100% - 32px), 880px);
}

.intro-text {
  display: grid;
  gap: 24px;
}

.intro-text p,
.page-hero p {
  color: var(--text);
  font-size: clamp(1.55rem, 3.3vw, 3.35rem);
  line-height: 1.22;
}

.split {
  display: grid;
  grid-template-columns: minmax(380px, 0.72fr) minmax(0, 1fr);
  gap: clamp(48px, 6.8vw, 118px);
  align-items: start;
}

.text-block {
  display: grid;
  gap: 22px;
}

.ranking-section {
  align-items: center;
}

.ranking-home {
  display: grid;
  gap: clamp(22px, 4vw, 38px);
}

.ranking-board {
  border: 1px solid var(--green);
  background:
    linear-gradient(180deg, rgba(13, 61, 36, 0.42) 0%, rgba(5, 6, 5, 0.98) 68%),
    var(--surface);
}

.ranking-board-header,
.ranking-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.38fr) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  min-height: 74px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-soft);
}

.ranking-row:last-child {
  border-bottom: 0;
}

.ranking-board-header {
  min-height: 110px;
}

.ranking-board span,
.ranking-board-header span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ranking-board strong {
  color: var(--text);
  font-size: clamp(1.2rem, 2.7vw, 2.4rem);
  line-height: 1;
  text-transform: uppercase;
}

.ranking-board-header strong {
  color: var(--green-bright);
  font-size: clamp(2.4rem, 7vw, 5.6rem);
  letter-spacing: 0.02em;
}

.ranking-home .button {
  width: fit-content;
}

.archive-facts {
  display: grid;
  border: 1px solid var(--line);
}

.archive-facts p {
  min-height: 78px;
  display: grid;
  grid-template-columns: minmax(120px, 0.32fr) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.archive-facts p:last-child {
  border-bottom: 0;
}

.archive-facts strong {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.archive-facts span {
  color: var(--text);
}

.section-heading {
  display: grid;
  gap: 14px;
  margin-bottom: clamp(32px, 6vw, 72px);
}

.rule-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.rule-grid li {
  min-height: 260px;
  padding: clamp(16px, 3vw, 24px);
  background: var(--surface);
  display: grid;
  align-content: space-between;
  gap: 24px;
}

.rule-grid canvas {
  width: 100%;
  aspect-ratio: 1 / 1;
}

.rule-grid span,
.rule-slide span,
.coming-soon,
.timeline span,
.rules-list span {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.rules-slides-section {
  overflow: hidden;
}

.rules-slides {
  list-style: none;
  display: grid;
  grid-auto-columns: minmax(260px, 380px);
  grid-auto-flow: column;
  gap: 18px;
  margin: 0;
  margin-right: calc((100vw - 100%) / -2);
  padding: 0 32px 18px 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline mandatory;
  scrollbar-color: var(--green) transparent;
}

.rule-slide {
  display: block;
  padding: 0;
  border: 1px solid var(--line);
  background: #08773d;
  scroll-snap-align: start;
}

.rule-slide img {
  display: block;
  width: 100%;
  height: auto;
}

.howto-section .section-heading p {
  max-width: 640px;
  color: var(--text);
  font-size: clamp(1.25rem, 2.4vw, 2.2rem);
  line-height: 1.2;
}

.howto-list {
  display: grid;
  gap: clamp(72px, 10vw, 132px);
}

.howto-step {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(250px, 0.52fr);
  gap: clamp(32px, 5.8vw, 82px);
  align-items: center;
}

.howto-step:nth-child(even) {
  grid-template-columns: minmax(250px, 0.52fr) minmax(340px, 1fr);
}

.howto-step:nth-child(even) .howto-diagram {
  order: 2;
}

.howto-step:nth-child(even) .howto-copy {
  order: 1;
}

.howto-copy {
  display: grid;
  gap: 18px;
  max-width: 460px;
}

.howto-copy h3 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.4rem, 3vw, 3rem);
  font-weight: 650;
  line-height: 0.96;
  text-transform: uppercase;
}

.howto-copy p {
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.22rem);
  line-height: 1.55;
}

.howto-diagram {
  width: 100%;
}

.giorgio-board {
  --board-green: #1f7846;
  --board-border-line: var(--green);
  position: relative;
  width: min(100%, 660px);
  aspect-ratio: 1 / 1;
  overflow: visible;
  border: 1px solid var(--board-border-line);
  background:
    linear-gradient(rgba(0, 0, 0, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.18) 1px, transparent 1px),
    var(--board-green);
  background-size: calc(100% / 9) calc(100% / 9);
}

.board-piece,
.preview-piece,
.floating-tile {
  position: absolute;
  z-index: 2;
  display: block;
  width: calc(100% / 9);
  aspect-ratio: 1 / 1;
  transform: rotate(var(--rot, 0deg)) scale(var(--piece-scale, 1));
  transform-origin: center;
}

.css-tile {
  --board-green: #1f7846;
  --tile-green: #1a643a;
  --tile-grid-line: rgba(0, 0, 0, 0.18);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--tile-grid-line);
  background: var(--tile-green);
}

.tile-unit {
  min-width: 0;
  min-height: 0;
  background: var(--tile-green);
}

.tile-unit-p {
  background: #f7f7f4;
}

.tile-unit-v {
  background: #030303;
}

.board-piece {
  left: calc((var(--c) - 1) * 100% / 9);
  top: calc((var(--r) - 1) * 100% / 9);
}

.block-composition {
  position: relative;
  width: min(100%, 560px);
  aspect-ratio: 2 / 1;
  margin: 0 auto;
}

.composition-tile {
  position: absolute;
  left: calc(var(--x) * 25%);
  top: calc(var(--y) * 50%);
  width: 25%;
  aspect-ratio: 1 / 1;
  transform: rotate(var(--rot, 0deg));
  transform-origin: center;
}

.preview-piece {
  opacity: 0.62;
  outline: 2px solid rgba(245, 245, 239, 0.65);
  outline-offset: -2px;
}

.floating-tile {
  left: 72%;
  top: 12%;
  z-index: 4;
  width: 15%;
}

.valid-space,
.blocked-gap {
  position: absolute;
  z-index: 1;
  left: calc((var(--c) - 1) * 100% / 9);
  top: calc((var(--r) - 1) * 100% / 9);
  width: calc(100% / 9);
  aspect-ratio: 1 / 1;
  border: 2px solid rgba(245, 245, 239, 0.58);
  background: rgba(245, 245, 239, 0.08);
}

.diagram-place .preview-piece {
  --piece-scale: 1.32;
  opacity: 0.76;
  outline-width: 3px;
}

.diagram-place .valid-space {
  transform: scale(1.32);
  transform-origin: center;
  border-color: rgba(245, 245, 239, 0.82);
  background: rgba(245, 245, 239, 0.13);
}

.diagram-block .board-piece {
  --piece-scale: 1.18;
}

.blocked-gap {
  border-color: rgba(17, 17, 17, 0.75);
  background: rgba(17, 17, 17, 0.22);
}

.placement-arrow {
  position: absolute;
  z-index: 5;
  left: 65%;
  top: 22%;
  width: 15%;
  height: 1px;
  background: rgba(245, 245, 239, 0.76);
  transform: rotate(140deg);
  transform-origin: right center;
}

.placement-arrow::after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 9px;
  height: 9px;
  border-left: 1px solid rgba(245, 245, 239, 0.76);
  border-bottom: 1px solid rgba(245, 245, 239, 0.76);
  transform: translateY(-50%) rotate(45deg);
}

.side-marker {
  position: absolute;
  z-index: 3;
  background: #f7f7f4;
  pointer-events: none;
}

.howto-section .side-marker {
  display: none;
}

.side-top,
.side-bottom {
  left: calc(100% / 9);
  width: calc(7 * 100% / 9);
  height: 5px;
}

.side-top {
  top: -10px;
}

.side-bottom {
  bottom: -10px;
}

.side-left,
.side-right {
  top: calc(100% / 9);
  width: 5px;
  height: calc(7 * 100% / 9);
  background: #030303;
}

.side-left {
  left: -10px;
}

.side-right {
  right: -10px;
}

.opponent-line {
  filter: saturate(0.9);
}

.blocker-piece {
  z-index: 4;
  outline: 2px solid rgba(46, 163, 94, 0.95);
  outline-offset: -2px;
}

.winning-piece {
  z-index: 4;
  outline: 2px solid rgba(245, 245, 239, 0.78);
  outline-offset: -2px;
  box-shadow: 0 0 0 1px rgba(245, 245, 239, 0.18);
}

.diagram-win .winning-piece {
  outline: 0;
  box-shadow: none;
}

.winning-path-line {
  position: absolute;
  inset: 0;
  z-index: 8;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.winning-path-line polyline {
  fill: none;
  stroke: #d51f1f;
  stroke-width: 0.48;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter:
    drop-shadow(0 0 0.1px rgba(0, 0, 0, 0.92))
    drop-shadow(0 0 0.16px rgba(213, 31, 31, 0.34));
}

.rotation-study {
  width: min(100%, 560px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(16px, 4vw, 42px);
  border: 0;
  background: transparent;
}

.rotation-study .css-tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  transform: rotate(var(--rot, 0deg));
}

.entry-section {
  min-height: 360px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 24px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  border-left: 0;
  border-right: 0;
  padding-inline: clamp(24px, 7vw, 84px);
  background: transparent;
}

.entry-section p {
  max-width: 560px;
  color: var(--text);
  font-size: clamp(1.2rem, 2.6vw, 2.1rem);
  line-height: 1.28;
}

.entry-section .button.secondary {
  border-color: var(--green);
  background: linear-gradient(180deg, #0d3d24 0%, #17643b 100%);
  color: var(--text);
}

.physical-layout {
  display: grid;
  gap: 26px;
}

.physical-study {
  position: relative;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: clamp(10px, 1.4vw, 18px);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(245, 245, 239, 0.05) 0%, rgba(5, 6, 5, 0.98) 100%),
    var(--surface);
}

.physical-study img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 0;
  filter: saturate(0.88) contrast(1.05);
}

.physical-study figcaption {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.document-links {
  display: grid;
  border: 1px solid var(--line);
}

.document-links a {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.document-links a:last-child {
  border-bottom: 0;
}

.document-links a::after {
  content: "->";
  font-size: 1rem;
}

.site-footer {
  padding: 44px 0 max(36px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  gap: 32px;
}

.site-footer strong {
  display: block;
  margin-bottom: 10px;
  font-size: 1rem;
  letter-spacing: 0.16em;
}

.site-footer p {
  max-width: 430px;
  font-size: 0.95rem;
}

.page-hero {
  display: grid;
  gap: 22px;
  border-top: 0;
  padding-top: clamp(52px, 9vw, 96px);
}

@media (min-width: 1180px) {
  .site-header {
    min-height: 104px;
    padding-block: 16px;
  }

  .brand-logo {
    width: clamp(214px, 10vw, 252px);
  }

  .site-nav a,
  .site-footer a,
  .text-link,
  .document-links a,
  .auth-nav button,
  .auth-menu-panel button {
    font-size: clamp(0.76rem, 0.46vw, 0.9rem);
    letter-spacing: 0.1em;
  }

  .site-nav,
  .site-footer nav {
    column-gap: clamp(14px, 1.15vw, 20px);
  }

  .section {
    padding: clamp(88px, 6.8vw, 150px) 0;
  }

  .hero {
    min-height: min(900px, calc(100svh - 96px));
  }

  .hero-line {
    font-size: clamp(4.1rem, 3.45vw, 5.75rem);
  }

  .hero-actions .button {
    width: 268px;
    min-height: 60px;
  }

  .text-block {
    gap: 28px;
  }

  .text-block p {
    font-size: clamp(1.34rem, 1.16vw, 1.7rem);
    line-height: 1.56;
  }

  .entry-section p {
    max-width: 760px;
  }

  .leaderboard-section,
  .player-section,
  .auth-section {
    padding-top: clamp(62px, 5.2vw, 108px);
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: clamp(22px, 1.7vw, 34px) clamp(22px, 2.4vw, 44px);
  }

  .leaderboard-table th {
    font-size: clamp(0.92rem, 0.6vw, 1.08rem);
  }

  .leaderboard-table td {
    font-size: clamp(1.38rem, 1vw, 1.72rem);
  }
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}

.editorial {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: clamp(36px, 8vw, 112px);
}

.timeline {
  display: grid;
  gap: 18px;
  position: sticky;
  top: 24px;
}

.timeline span {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.article {
  display: grid;
  gap: 34px;
}

.article p {
  color: var(--text);
  font-size: clamp(1.35rem, 2vw, 2.45rem);
  line-height: 1.38;
}

.rules-list {
  display: grid;
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.rules-list article {
  display: grid;
  grid-template-columns: 84px minmax(160px, 0.34fr) minmax(0, 1fr);
  gap: clamp(18px, 4vw, 44px);
  align-items: start;
  background: var(--surface);
  padding: clamp(22px, 5vw, 44px);
}

.rules-list h2 {
  font-size: clamp(1.55rem, 3vw, 2.7rem);
}

.rules-list p {
  font-size: clamp(1rem, 1.7vw, 1.2rem);
}

.rules-diagram {
  width: min(100%, 360px);
  padding: 12px;
}

@media (max-width: 980px) {
  .hero,
  .hero-copy,
  .split,
  .editorial {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .hero-board {
    justify-self: start;
  }

  .hero-photo {
    justify-self: start;
    width: min(100%, 520px);
  }

  .rule-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rule-grid li:last-child {
    grid-column: 1 / -1;
  }

  .timeline {
    position: static;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    border: 1px solid var(--line);
    background: var(--line);
  }

  .timeline span {
    border-bottom: 0;
    background: var(--surface);
    padding: 14px;
  }

  .howto-step,
  .howto-step:nth-child(even) {
    grid-template-columns: 1fr;
  }

  .howto-step:nth-child(even) .howto-diagram,
  .howto-step:nth-child(even) .howto-copy {
    order: initial;
  }

  .howto-copy {
    max-width: 680px;
  }
}

@media (orientation: portrait) and (max-width: 1100px) {
  .site-header {
    gap: clamp(10px, 2.4vw, 18px);
    padding-inline: clamp(18px, 4vw, 40px);
  }

  .brand-logo {
    width: clamp(140px, 22vw, 190px);
  }

  .site-nav {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: clamp(8px, 1.6vw, 14px);
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .site-nav::-webkit-scrollbar {
    display: none;
  }

  .site-nav a,
  .site-nav .auth-nav button {
    font-size: clamp(0.58rem, 1.55vw, 0.74rem);
    letter-spacing: 0.08em;
  }

  .auth-nav {
    flex: 0 0 auto;
    margin-left: 0;
  }
}

@media (max-width: 700px) {
  .site-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-header {
    gap: 12px;
    min-height: 0;
    padding-block: 12px;
  }

  .site-nav,
  .site-footer nav {
    justify-content: flex-start;
  }

  .site-nav {
    width: 100%;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .site-nav::-webkit-scrollbar {
    display: none;
  }

  .site-nav a,
  .site-nav .auth-nav button {
    font-size: clamp(0.58rem, 2.35vw, 0.72rem);
    letter-spacing: 0.08em;
  }

  .auth-nav {
    width: auto;
    flex: 0 0 auto;
    margin-left: 0;
  }

  .auth-menu {
    width: auto;
  }

  .auth-menu-trigger {
    width: auto;
    justify-content: flex-start;
  }

  .auth-menu-panel {
    position: static;
    width: 100%;
    margin-top: 10px;
    box-shadow: none;
  }

  .brand-logo {
    width: 132px;
  }

  .hero-actions {
    width: 100%;
  }

  .hero-actions .button {
    width: 100%;
  }

  .section {
    width: min(calc(100% - 24px), var(--max));
    padding: 56px 0;
  }

  .narrow {
    width: min(calc(100% - 24px), 880px);
  }

  .hero {
    padding-top: 26px;
  }

  .hero-line {
    font-size: clamp(1.75rem, 8.4vw, 2.75rem);
    line-height: 1;
  }

  .rule-grid,
  .timeline {
    grid-template-columns: 1fr;
  }

  .auth-grid,
  .profile-stat-grid,
  .public-player-header,
  .public-player-stats {
    grid-template-columns: 1fr;
  }

  .public-player-rating {
    justify-items: start;
    text-align: left;
  }

  .public-player-share,
  .share-profile-button {
    width: 100%;
  }

  .public-player-share {
    align-items: start;
  }

  .profile-row {
    display: grid;
  }

  .ranking-board-header,
  .ranking-row {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .ranking-home .button {
    width: 100%;
  }

  .empty-state .button,
  .contact-card .button {
    width: 100%;
  }

  .contact-section {
    grid-template-columns: 1fr;
  }

  .rule-grid li:last-child {
    grid-column: auto;
  }

  .rule-grid li {
    min-height: 220px;
  }

  .howto-list {
    gap: 74px;
  }

  .howto-step {
    gap: 22px;
  }

  .howto-copy h3 {
    font-size: clamp(1.55rem, 9vw, 2.55rem);
  }

  .giorgio-board {
    width: calc(100% - 16px);
    margin-inline: auto;
  }

  .side-top {
    top: -7px;
  }

  .side-bottom {
    bottom: -7px;
  }

  .side-left {
    left: -7px;
  }

  .side-right {
    right: -7px;
  }

  .entry-section {
    min-height: 320px;
    padding-inline: 22px;
  }

  .physical-study img {
    aspect-ratio: 1 / 1;
  }

  .rules-list article {
    grid-template-columns: 1fr;
  }

  .archive-facts p {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
