:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: #d7dee8;
  --line-strong: #9aa8ba;
  --blue: #2f6fed;
  --blue-dark: #194eb8;
  --green: #0f9f7c;
  --red: #d94b62;
  --shadow: 0 18px 45px rgba(21, 32, 56, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  width: min(1120px, calc(100% - 32px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.84rem;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.game-layout {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 18px 0 48px;
}

.content-layout {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  flex: 1;
  padding: 28px 0 48px;
}

.game-panel {
  width: min(100%, 560px);
  padding: clamp(18px, 4vw, 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.content-panel {
  padding: clamp(18px, 4vw, 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.game-head {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.content-panel h1 {
  font-size: 2.25rem;
  line-height: 1.05;
}

.content-panel h2 {
  margin: 28px 0 8px;
  font-size: 1.12rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.content-panel p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.62;
}

.game-status {
  min-height: 28px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
}

.turn-badge {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 1.55rem;
  font-weight: 900;
}

.turn-badge.is-o {
  background: var(--green);
}

.turn-badge.is-finished {
  background: var(--red);
}

.board {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 12px);
}

.cell {
  width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  background: #f9fbfe;
  color: var(--ink);
  cursor: pointer;
  font-size: clamp(2.6rem, 16vw, 6.4rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.cell:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--blue);
  background: #eef4ff;
}

.cell:focus-visible,
.button:focus-visible,
.invite input:focus-visible {
  outline: 3px solid rgba(47, 111, 237, 0.28);
  outline-offset: 3px;
}

.cell:disabled {
  cursor: default;
}

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

.cell.is-o {
  color: var(--green);
}

.cell.is-win {
  border-color: var(--red);
  background: #fff2f4;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 800;
}

.button:hover:not(:disabled) {
  border-color: var(--blue);
}

.button:disabled {
  cursor: default;
  opacity: 0.48;
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.button.primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.invite {
  margin-top: 12px;
}

.invite input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #f9fbfe;
}

.notice {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
}

.footer {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 24px;
  display: flex;
  justify-content: center;
}

.footer a {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  text-decoration: none;
}

.footer a:hover,
.footer a:focus-visible {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

@media (max-width: 560px) {
  .topbar {
    width: min(100% - 24px, 1120px);
    min-height: 64px;
  }

  .brand {
    font-size: 0.92rem;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 0.76rem;
  }

  .mode-pill {
    max-width: 126px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .game-layout {
    width: min(100% - 24px, 1120px);
    align-items: start;
    padding-top: 10px;
  }

  .content-layout {
    width: min(100% - 24px, 760px);
    padding-top: 10px;
  }

  .game-panel {
    padding: 16px;
  }

  .content-panel {
    padding: 16px;
  }

  .content-panel h1 {
    font-size: 1.9rem;
  }

  .game-head {
    min-height: 58px;
    margin-bottom: 14px;
  }

  .turn-badge {
    width: 48px;
    height: 48px;
    font-size: 1.32rem;
  }

  .actions {
    grid-template-columns: 1fr;
  }
}
