:root {
  color-scheme: dark;
  --page: #11100e;
  --panel: rgba(20, 19, 16, 0.72);
  --text: #f8efe2;
  --muted: #c8b69f;
  --accent: #e8b65d;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 30%, rgba(242, 176, 89, 0.16), transparent 32rem),
    linear-gradient(135deg, #17120f, var(--page) 58%, #060606);
  color: var(--text);
  touch-action: pan-y;
  overscroll-behavior: none;
  user-select: none;
  font-family:
    Montserrat, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.game-shell {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vmin, 22px);
  padding: clamp(10px, 2vmin, 22px);
}

.site-header {
  width: min(100%, 900px);
  text-align: center;
}

.site-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: clamp(10px, 1.35vmin, 12px);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.site-header h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(24px, 4vmin, 40px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
}

.table-wrap {
  --board-size: min(92vw, calc(100dvh - clamp(136px, 18vmin, 184px)), 860px);
  width: var(--board-size);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.4vmin, 14px);
}

canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
  border-radius: 8px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.44),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  touch-action: none;
  user-select: none;
  cursor: grab;
}

canvas.is-aiming {
  cursor: grabbing;
}

.hud {
  position: static;
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.1vmin, 12px);
  width: min(100%, 620px);
  min-width: min(100%, 500px);
  height: clamp(40px, 5.4vmin, 54px);
  padding: 0 clamp(8px, 1.4vmin, 14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(61, 49, 39, 0.86), rgba(19, 18, 16, 0.76));
  backdrop-filter: blur(12px);
  color: var(--text);
  font-weight: 700;
  line-height: 1;
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.score-side {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 6px;
  min-width: 72px;
  color: rgba(248, 239, 226, 0.72);
}

.score-side.is-active {
  color: var(--text);
}

.score-side.is-bot {
  justify-content: end;
}

.score-name {
  font-size: clamp(11px, 1.55vmin, 14px);
  font-weight: 800;
  text-transform: uppercase;
}

.score-value {
  min-width: 22px;
  text-align: center;
  font-size: clamp(20px, 3.1vmin, 30px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.turn-label {
  flex: 1;
  min-width: 94px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffe1a3;
  text-align: center;
  font-size: clamp(11px, 1.65vmin, 14px);
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.reset-button {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.difficulty-select {
  width: clamp(74px, 10vmin, 94px);
  height: 28px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  padding: 0 22px 0 9px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
  color: var(--text);
  font: inherit;
  font-size: clamp(10px, 1.45vmin, 12px);
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.difficulty-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.difficulty-select option {
  background: #241d17;
  color: var(--text);
}

.reset-button:hover {
  background: rgba(232, 182, 93, 0.32);
}

.reset-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.seo-content {
  width: min(100%, 980px);
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.8fr);
  gap: clamp(18px, 4vw, 42px);
  margin-top: clamp(18px, 5vmin, 54px);
  padding: clamp(18px, 4vmin, 34px) 0 clamp(28px, 6vmin, 56px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.seo-copy {
  color: rgba(248, 239, 226, 0.84);
}

.seo-copy h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: clamp(20px, 2.7vmin, 28px);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: 0;
}

.seo-copy h2:not(:first-child) {
  margin-top: 24px;
}

.seo-copy p,
.seo-copy li,
.seo-figure figcaption {
  font-size: clamp(14px, 1.7vmin, 16px);
  line-height: 1.65;
}

.seo-copy p {
  margin: 0;
}

.seo-copy ol {
  margin: 0;
  padding-left: 1.35rem;
}

.seo-copy li + li {
  margin-top: 6px;
}

.seo-figure {
  margin: 0;
  align-self: start;
}

.seo-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow:
    0 18px 46px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.seo-figure figcaption {
  margin-top: 10px;
  color: var(--muted);
}

@media (max-width: 680px) {
  .game-shell {
    padding: 8px;
    gap: 8px;
    justify-content: start;
  }

  .site-header {
    padding-top: 4px;
  }

  .site-header h1 {
    font-size: 24px;
  }

  .table-wrap {
    --board-size: min(calc(100vw - 16px), calc(100dvh - 122px));
    gap: 8px;
  }

  .hud {
    width: 100%;
    min-width: 0;
    gap: 5px;
    padding: 0 6px;
  }

  .score-side {
    min-width: 51px;
    gap: 4px;
  }

  .turn-label {
    min-width: 74px;
    padding: 7px 6px;
  }

  .difficulty-select {
    width: 78px;
    padding-left: 7px;
    padding-right: 17px;
    font-size: 10px;
  }

  .reset-button {
    width: 26px;
    height: 26px;
  }

  .seo-content {
    grid-template-columns: 1fr;
    gap: 18px;
    margin-top: 22px;
    padding-bottom: 34px;
  }
}

/* i18n language footer start */
.app-footer {
  width: min(100%, 980px);
  margin-top: clamp(10px, 3vmin, 28px);
  padding: clamp(16px, 3vmin, 24px) 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
}

.app-footer p {
  max-width: 640px;
  margin: 0;
  color: rgba(248, 239, 226, 0.72);
  font-size: clamp(12px, 1.45vmin, 14px);
  line-height: 1.55;
}

.app-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 900;
}

.app-footer a:hover {
  text-decoration: underline;
}

.site-footer {
  display: flex;
  align-items: center;
}

.site-language-picker {
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-language-picker svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.site-language-picker select {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(248, 239, 226, 0.95);
  color: #17120f;
  padding: 0 38px 0 16px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 850;
  cursor: pointer;
}

.site-language-picker select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

html[dir="rtl"] body {
  text-align: right;
}

html[dir="rtl"] .seo-copy ol {
  padding-left: 0;
  padding-right: 1.35rem;
}

html[dir="rtl"] .seo-figure figcaption,
html[dir="rtl"] .app-footer p {
  text-align: right;
}

html[dir="rtl"] .site-language-picker select {
  padding: 0 16px 0 38px;
}

@media (max-width: 680px) {
  .hud {
    gap: 4px;
    padding: 0 5px;
  }

  .score-side {
    min-width: 0;
    gap: 3px;
  }

  .score-name {
    font-size: 9px;
  }

  .score-value {
    min-width: 16px;
    font-size: 18px;
  }

  .turn-label {
    flex: 0 0 58px;
    min-width: 58px;
    padding: 7px 3px;
    font-size: 9px;
    line-height: 1;
    white-space: nowrap;
  }

  .difficulty-select {
    width: 68px;
    padding-left: 6px;
    padding-right: 16px;
    font-size: 9px;
  }

  .app-footer {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 14px;
  }

  .app-footer p,
  html[dir="rtl"] .app-footer p {
    max-width: none;
    text-align: center;
  }

  .site-footer {
    justify-content: center;
    width: 100%;
  }

  .site-language-picker {
    width: min(100%, 320px);
    min-width: 0;
  }
}
/* i18n language footer end */
