:root {
  color-scheme: dark;
  --ink: #f8fbff;
  --muted: #c6d5df;
  --deep: #102016;
  --night: #173327;
  --pine: #1f4a34;
  --pine-soft: rgba(31, 74, 52, 0.76);
  --glass: rgba(18, 43, 33, 0.66);
  --glass-strong: rgba(18, 43, 33, 0.86);
  --line: rgba(246, 232, 190, 0.26);
  --line-strong: rgba(255, 236, 190, 0.42);
  --snow: #f8fbff;
  --snow-soft: #e7f1f4;
  --aurora: #8fcf73;
  --aurora-dark: #3d8f4a;
  --amber: #f2b65e;
  --amber-soft: #ffe0aa;
  --berry: #d64663;
  --berry-dark: #8d2036;
  --ice: #4aa6d8;
  --ice-dark: #176a91;
  --wood: #8c5831;
  --wood-dark: #382113;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
  --inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(143, 207, 115, 0.22), transparent 28rem),
    radial-gradient(circle at 84% 18%, rgba(240, 182, 93, 0.16), transparent 24rem),
    linear-gradient(180deg, rgba(11, 28, 19, 0.08), rgba(11, 28, 19, 0.58)),
    url("assets/lapland-summer-game-bg.png") center top / cover fixed no-repeat,
    var(--deep);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(180deg, rgba(10, 28, 17, 0.06), rgba(10, 28, 17, 0.52));
  background-size: 44px 44px, 44px 44px, auto;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(228, 238, 238, 0.96));
  color: #13242a;
  cursor: pointer;
  font-weight: 850;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button.primary {
  border-color: rgba(235, 214, 132, 0.72);
  background: linear-gradient(180deg, #f0c66f, #d9852f);
  color: #031211;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.24);
}

button.ghost {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--snow);
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.9);
  color: #102127;
  box-shadow: var(--inner-glow);
}

input::placeholder {
  color: #667b82;
}

input:focus,
button:focus-visible {
  outline: 3px solid rgba(240, 198, 111, 0.36);
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar,
.score-strip,
.side-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  box-shadow: var(--shadow), var(--inner-glow);
  backdrop-filter: blur(16px) saturate(1.25);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255, 224, 170, 0.9);
  border-radius: 8px;
  color: var(--amber-soft);
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.28), transparent 34%),
    linear-gradient(135deg, #6d3f21, #2b170c);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
  font-weight: 950;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: 0;
}

.brand small {
  color: var(--muted);
}

.top-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill,
.version {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.86rem;
  font-weight: 820;
}

.status-pill.online {
  background: rgba(69, 215, 197, 0.18);
  color: #f6e6a8;
}

.status-pill.offline {
  background: rgba(214, 70, 99, 0.18);
  color: #ffb7c3;
}

.version {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
}

.lobby {
  display: grid;
  gap: 18px;
  padding-top: 30px;
}

.intro-panel {
  max-width: 790px;
  padding: 26px 0 6px;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
}

.eyebrow {
  margin: 0 0 9px;
  color: #f6e6a8;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: 3.25rem;
  line-height: 1.02;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.18rem;
}

.lead {
  max-width: 700px;
  color: var(--snow-soft);
  font-size: 1.08rem;
  line-height: 1.58;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.panel {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 18px;
}

.panel h2,
.side-panel h2 {
  color: var(--snow);
}

.panel label,
.invite-box label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.settings-field {
  display: grid;
  gap: 8px;
  margin: 2px 0 4px;
  padding: 0;
  border: 0;
}

.settings-field legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 47, 29, 0.38);
}

.segmented label {
  position: relative;
  min-width: 0;
}

.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 900;
}

.segmented input:checked + span {
  background: linear-gradient(180deg, #ffdc95, #d98c35);
  color: #2b1609;
}

.segmented input:focus-visible + span {
  outline: 3px solid rgba(240, 198, 111, 0.36);
  outline-offset: 2px;
}

.local-panel p {
  color: var(--snow-soft);
  line-height: 1.52;
}

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  padding-top: 22px;
  align-items: start;
}

.hidden {
  display: none !important;
}

.game-main {
  min-width: 0;
}

.score-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-weight: 800;
}

.player-chip.is-turn {
  color: var(--snow);
}

.player-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.symbol,
.draw-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid currentColor;
  border-radius: 999px;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.18) 32%, transparent 34%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(205, 225, 232, 0.95));
  font-weight: 950;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
}

.symbol.x {
  color: var(--berry);
}

.symbol.o {
  color: var(--ice);
}

.score-count {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 30px;
  border-radius: 999px;
  background: rgba(255, 224, 170, 0.96);
  color: #291408;
  font-weight: 950;
}

.presence-badge {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.presence-online {
  border-color: rgba(143, 207, 115, 0.48);
  background: rgba(143, 207, 115, 0.16);
  color: #d9ffc8;
}

.presence-idle {
  border-color: rgba(242, 182, 94, 0.5);
  background: rgba(242, 182, 94, 0.15);
  color: var(--amber-soft);
}

.presence-left {
  border-color: rgba(214, 70, 99, 0.52);
  background: rgba(214, 70, 99, 0.16);
  color: #ffb7c3;
}

.turn-label {
  min-width: 132px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 860;
}

.board {
  --size: 15;
  display: grid;
  grid-template-columns: repeat(var(--size), minmax(0, 1fr));
  gap: 2px;
  width: min(100%, 700px);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 10px;
  border: 3px solid rgba(255, 224, 170, 0.72);
  border-radius: 8px;
  background: #183b2c;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.46), inset 0 0 0 7px rgba(10, 38, 25, 0.72);
}

.cell {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 0;
  aspect-ratio: 1;
  border: 0;
  border-radius: 4px;
  background: rgba(247, 232, 190, 0.12);
  color: var(--snow);
  font-size: 1.02rem;
  font-weight: 950;
  line-height: 1;
  text-shadow: none;
  box-shadow: none;
}

.cell:hover:not(:disabled) {
  background: rgba(246, 230, 168, 0.24);
  box-shadow: inset 0 0 0 2px rgba(246, 230, 168, 0.46);
  transform: none;
}

.cell.x,
.cell.o {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.18) 30%, transparent 31%),
    linear-gradient(145deg, #f8fbff, #d9e7ec);
  border: 1px solid rgba(255, 255, 255, 0.62);
  text-shadow: none;
  box-shadow: 0 4px 11px rgba(0, 0, 0, 0.32), inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}

.cell.x {
  color: var(--berry-dark);
}

.cell.o {
  color: var(--ice-dark);
}

.cell.win {
  background:
    radial-gradient(circle at 50% 50%, #fff7d7, #ffcf6f);
  color: #221204;
  box-shadow: 0 0 0 3px rgba(255, 224, 170, 0.8), 0 0 24px rgba(255, 205, 95, 0.72);
}

.side-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
  position: sticky;
  top: 16px;
}

.message {
  min-height: 64px;
  margin-bottom: 0;
  color: var(--snow-soft);
  line-height: 1.5;
}

.score-board {
  display: grid;
  gap: 10px;
  padding: 4px 0 2px;
}

.score-board-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
}

.score-board-title span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--amber-soft);
  font-size: 0.78rem;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.score-grid div {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 0;
}

.score-grid strong {
  color: var(--snow);
  font-size: 1.55rem;
  line-height: 1;
}

.score-grid small {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-grid .symbol,
.draw-mark {
  width: 28px;
  height: 28px;
  border-radius: 999px;
}

.draw-mark {
  border: 2px solid var(--amber);
  background: linear-gradient(145deg, #fff7dc, #f2b65f);
  color: #351b08;
  font-weight: 950;
}

.invite-box {
  display: grid;
  gap: 8px;
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.actions {
  display: grid;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  max-width: min(360px, calc(100% - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--glass-strong);
  color: var(--snow);
  box-shadow: var(--shadow);
  font-weight: 800;
  backdrop-filter: blur(14px);
}

@media (max-width: 900px) {
  .setup-grid,
  .game {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  body {
    background-position: center top;
    background-attachment: scroll;
  }

  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 2.1rem;
  }

  .score-strip {
    grid-template-columns: 1fr;
  }

  .turn-label {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

  .board {
    gap: 1px;
    padding: 6px;
  }

  .cell {
    border-radius: 3px;
    font-size: 0.86rem;
  }

  .copy-row {
    grid-template-columns: 1fr;
  }
}



