@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Geist:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --ink: #f6f3ff;
  --muted: #a9a4ba;
  --purple: #b599ff;
  --mint: #6ae5cb;
  --edge: #302843;
  --body-font: "DM Sans", system-ui, sans-serif;
  --heading-font: "Geist", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 16px/1.45 var(--body-font);
  background:
    radial-gradient(ellipse at 50% -20%, #332351 0%, transparent 64%),
    radial-gradient(circle, #ffffff14 0.75px, transparent 1px) 0 0 / 22px 22px,
    #100e19;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 4px;
}

.site-header {
  border-bottom: 1px solid #ffffff12;
  background: #151120b8;
}

.header-inner {
  max-width: 1152px;
  min-height: 68px;
  margin: auto;
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font: 700 17px var(--heading-font);
  letter-spacing: -.04em;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 37px;
  height: 34px;
  border: 1px solid #695094;
  border-radius: 10px;
  background: linear-gradient(145deg, #523879, #2c2044);
}

.logo .mark { --size: 11px; --weight: 2.5px; }

.text-button,
.new-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #dfd8ee;
  background: #ffffff06;
  border: 1px solid #ffffff18;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}

.text-button:hover, .new-round:hover {
  background: #ffffff13;
  border-color: #ffffff3b;
}

.help-icon {
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  height: 15px;
  width: 15px;
  border-radius: 50%;
  font: 700 10px/1 var(--body-font);
  color: var(--purple);
}

.page {
  max-width: 1004px;
  margin: auto;
  padding: 44px 24px 44px;
}

.intro { text-align: center; margin-bottom: 34px; }

.intro h1 {
  margin: 0;
  font: 800 clamp(48px, 7vw, 78px)/.99 var(--heading-font);
  letter-spacing: -.077em;
}

.intro h1 span {
  color: #b79bff;
  background: linear-gradient(125deg, #dec7ff 8%, #a686fc 85%);
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.intro p { margin: 15px 0 0; color: var(--muted); font-size: 16px; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(285px, .77fr) minmax(0, 1.23fr);
  gap: 20px;
}

.panel {
  border: 1px solid var(--edge);
  border-radius: 23px;
  background: linear-gradient(155deg, #211a31, #191525 70%);
  box-shadow: 0 18px 50px #08060e45, inset 0 1px #ffffff08;
  min-width: 0;
}

.sidebar { padding: 23px; }
h2 { margin: 0; font: 700 18px/1.25 var(--heading-font); letter-spacing: -.035em; }
.modes { border: 0; padding: 0; margin: 15px 0 0; display: grid; gap: 8px; }

.mode {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 57px;
  padding: 8px 39px 8px 10px;
  cursor: pointer;
  border: 1px solid #ffffff0d;
  border-radius: 11px;
  background: #ffffff04;
  transition: background .15s, border-color .15s;
}
.mode:hover { background: #ffffff0c; border-color: #ffffff27; }
.mode:has(input:checked) { background: #392857; border-color: #9472d8; }
.mode:has(input:focus-visible) { outline: 2px solid var(--purple); outline-offset: 2px; }
.mode input {
  appearance: none;
  position: absolute;
  right: 12px;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid #685d7e;
  border-radius: 50%;
  cursor: pointer;
}
.mode input:checked { border: 5px solid #bb9cff; background: #34204f; }
.mode-text { display: grid; gap: 1px; min-width: 0; }
.mode-text strong { font-size: 14px; line-height: 1.2; }
.mode-text small { font-size: 12px; color: var(--muted); }

.mode-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 8px;
  color: var(--mode-ink);
  background: color-mix(in srgb, currentColor 13%, transparent);
}
.easy { --mode-ink: #7ce7b2; }
.medium { --mode-ink: #c9adff; }
.hard { --mode-ink: #ffb97d; }
.impossible { --mode-ink: #f59ecf; }
.friend { --mode-ink: #7bdded; }

.bars {
  width: 4px;
  height: 10px;
  border-radius: 1px;
  background: currentColor;
  position: relative;
  margin-top: 3px;
}
.bars::before, .bars::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 4px;
  border-radius: inherit;
  background: currentColor;
}
.bars::before { height: 6px; left: -6px; }
.bars::after { height: 15px; right: -6px; }
.bars.one { opacity: 1; background: #7ce7b250; }
.bars.one::after, .bars.two::after { opacity: .34; }
.bolt { width: 14px; height: 18px; background: currentColor; clip-path: polygon(58% 0, 3% 57%, 43% 57%, 34% 100%, 98% 36%, 57% 36%); }
.person { position: relative; width: 11px; height: 6px; border: 1.5px solid currentColor; border-radius: 7px 7px 2px 2px; margin-top: 8px; }
.person::before { content: ""; position: absolute; width: 6px; height: 6px; border: 1.5px solid currentColor; border-radius: 50%; left: 50%; bottom: 5px; transform: translateX(-50%); }
.person.second { width: 8px; margin-left: 1px; opacity: .6; }

.mark-choice { border: 0; padding: 0; margin: 19px 0 0; min-width: 0; }
.mark-choice[hidden] { display: none; }
.mark-choice legend { padding: 0; font: 700 15px var(--heading-font); }
.mark-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.mark-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 6px;
  border: 1px solid #ffffff18;
  border-radius: 9px;
  font-size: 13px;
  cursor: pointer;
}
.mark-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.mark-option:has(input:checked) { background: #392857; border-color: #9472d8; }
.mark-option:has(input:focus-visible) { outline: 2px solid var(--purple); outline-offset: 2px; }

.scoreboard { border-top: 1px solid #ffffff13; margin-top: 21px; padding-top: 17px; }
.scoreboard h2 { font-size: 15px; }
.scores { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 11px; }
.score {
  display: grid;
  justify-items: center;
  padding: 8px 2px 7px;
  background: #ffffff04;
  border: 1px solid #ffffff0d;
  border-radius: 9px;
}
.score strong { font: 700 22px/1.12 var(--heading-font); font-variant-numeric: tabular-nums; }
.score span { color: var(--muted); font-size: 11px; }
.score-x strong { color: var(--purple); }
.score-o strong { color: var(--mint); }
.score-draw strong { color: #dbd4e9; }

.play { padding: 21px 23px 17px; display: flex; flex-direction: column; align-items: center; }
.game-header { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.turn { display: flex; gap: 10px; align-items: center; min-width: 0; }
.turn-icon {
  display: grid;
  place-items: center;
  flex: 0 0 41px;
  height: 41px;
  border-radius: 11px;
  border: 1px solid #674e953d;
  background: #966cf026;
}
.turn-icon:has(.o) { background: #61d5bf22; border-color: #61d5bf33; }
.turn-icon .mark { --size: 19px; --weight: 4px; }
.turn-label { margin: 0; font: 700 16px/1.2 var(--heading-font); }
.turn-detail { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.new-round span { color: var(--purple); font: 20px/.8 system-ui, sans-serif; }

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 382px);
  aspect-ratio: 1;
  gap: 9px;
  margin: 17px auto 13px;
  padding: 9px;
  border: 1px solid #ffffff0d;
  border-radius: 19px;
  background: #100c1980;
}

.cell {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  position: relative;
  border: 1px solid #443657;
  border-radius: 12px;
  background: radial-gradient(ellipse at 50% 0, #302541, transparent 82%), #251d34;
  box-shadow: inset 0 1px #ffffff0a;
  transition: border-color .16s, background-color .16s;
}
.cell[aria-disabled="false"]:hover { background-color: #35234e; border-color: #9b7ac9; }
.cell[aria-disabled="true"] { cursor: default; }
.cell:focus-visible { z-index: 1; outline-offset: 1px; }
.cell:empty::before { content: ""; height: 4px; width: 4px; background: #8775a05e; border-radius: 50%; }
.cell .mark { --size: clamp(30px, 7vw, 58px); --weight: clamp(6px, 1.25vw, 11px); }
.cell.win:has(.x) { border-color: #bd9dff; background: #463261; }
.cell.win:has(.o) { border-color: #6ae5cb; background: #234443; }

.mark {
  --size: 13px;
  --weight: 2.5px;
  position: relative;
  display: inline-block;
  width: var(--size);
  height: var(--size);
  flex: none;
}
.mark.x { color: var(--purple); }
.mark.x::before, .mark.x::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 112%;
  height: var(--weight);
  border-radius: var(--weight);
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}
.mark.x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.mark.o { border: var(--weight) solid var(--mint); border-radius: 50%; }
.mark.draw { width: 16px; height: 4px; border-radius: 4px; background: #dbd4e9; }

.legend { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 12px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend .divider { width: 1px; height: 11px; background: #ffffff22; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

dialog {
  width: min(420px, calc(100% - 32px));
  color: var(--ink);
  border: 1px solid #584772;
  border-radius: 18px;
  background: #21192f;
  padding: 24px;
  box-shadow: 0 25px 80px #0007;
}
dialog::backdrop { background: #0c0817b8; backdrop-filter: blur(4px); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; }
.close { padding: 3px 10px; font-size: 22px; line-height: 1; }
dialog ol { margin: 17px 0 0; padding-left: 22px; color: #cfc7dd; }
dialog li + li { margin-top: 8px; }

@media (max-width: 700px) {
  .header-inner { min-height: 58px; padding-inline: 17px; }
  .page { padding: 30px 14px; }
  .intro { margin-bottom: 24px; }
  .intro p { margin-top: 10px; font-size: 14px; }
  .game-layout { grid-template-columns: 1fr; gap: 14px; max-width: 460px; margin: auto; }
  .play { grid-row: 1; padding: 15px; }
  .sidebar { padding: 17px; }
  .board { margin-top: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
