:root {
  --bg: #f3f1ec;
  --ink: #14201b;
  --muted: #5f6f68;
  --line: #d9d3c8;
  --surface: #fff;
  --accent: #0f7a5f;
  --accent-2: #c47a12;
  --danger: #c23b3b;
  --shadow: 0 16px 36px rgba(20, 32, 27, 0.08);
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --display: 'Bricolage Grotesque', Georgia, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(800px 400px at 10% -10%, rgba(15, 122, 95, 0.12), transparent 60%),
    radial-gradient(700px 360px at 100% 0%, rgba(196, 122, 18, 0.1), transparent 55%),
    var(--bg);
}

.app {
  width: min(560px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

h1,
h2 {
  font-family: var(--display);
  margin: 0;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
}

.lead {
  color: var(--muted);
  margin: 0.4rem 0 1rem;
  line-height: 1.5;
}

.field {
  display: block;
  margin-bottom: 0.85rem;
}

.field input {
  width: 100%;
  font: inherit;
  font-weight: 600;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-top: 0.25rem;
}

.players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.player-slot {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf9f6;
  min-width: 0;
}

.player-slot .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 8px;
  background: #e3f5ef;
  color: var(--accent);
  font-family: var(--display);
  font-weight: 700;
  flex-shrink: 0;
}

.player-slot .mark.mark-o {
  background: #f8ecd8;
  color: var(--accent-2);
}

.player-slot strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.join input {
  flex: 1;
  min-width: 140px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.btn.ghost {
  background: transparent;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pill {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.pill.online {
  background: #e3f5ef;
  color: var(--accent);
}

.pill.offline {
  background: #fdecec;
  color: var(--danger);
}

.meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.link {
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-left: 0.35rem;
}

.status {
  min-height: 1.4em;
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin-bottom: 0.5rem;
}

.cell {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #faf9f6;
  font-family: var(--display);
  font-size: clamp(2rem, 8vw, 2.8rem);
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.cell:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #b9d8cd;
}

.cell:disabled {
  cursor: default;
}

.cell.win {
  background: #e3f5ef;
  border-color: var(--accent);
  color: var(--accent);
}

.cell.mark-O {
  color: var(--accent-2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: #14201b;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.92rem;
  max-width: min(90vw, 420px);
  z-index: 20;
}

@media (max-width: 520px) {
  .meta {
    grid-template-columns: 1fr;
  }
}
