:root {
  --bg-1: #f2f7ff;
  --bg-2: #fef6e4;
  --ink: #102542;
  --card: rgba(255, 255, 255, 0.86);
  --line: #0f1420;
  --x: #0ea5e9;
  --o: #fb5607;
  --accent: #ef476f;
  --muted: #5f6b7a;
  --shadow: 0 14px 34px rgba(16, 37, 66, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(14, 165, 233, 0.22), transparent 22%),
    radial-gradient(circle at 88% 82%, rgba(251, 86, 7, 0.2), transparent 25%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.app-shell {
  width: min(700px, 100%);
  background: var(--card);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 34px);
  animation: enter 420ms ease both;
}

.header {
  text-align: center;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: clamp(1.65rem, 6vw, 2.5rem);
  line-height: 1.08;
}

.payload-panel {
  margin-bottom: 12px;
  border-radius: 16px;
  padding: 12px;
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(16, 37, 66, 0.08);
}

.payload-label {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
}

.payload-text {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  white-space: pre;
  border-radius: 10px;
  padding: 10px;
  background: #f5f8fc;
  box-shadow: inset 0 0 0 1px rgba(16, 37, 66, 0.12);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #243449;
}

.hidden {
  display: none;
}

.online-panel {
  margin-bottom: 12px;
  border-radius: 16px;
  padding: 12px;
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(16, 37, 66, 0.08);
}

.meta-label {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
}

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

.room-link-input {
  width: 100%;
  border: 1px solid rgba(16, 37, 66, 0.22);
  border-radius: 10px;
  padding: 10px 11px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.92rem;
}

.meta-row {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.score-card {
  border-radius: 16px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(16, 37, 66, 0.08);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  row-gap: 6px;
}

.score-card h2 {
  margin: 0;
  font-size: 1rem;
  font-family: "Bricolage Grotesque", sans-serif;
}

.piece {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  grid-column: 2;
  grid-row: 1 / 3;
}

.bill-card .piece {
  color: var(--x);
}

.luana-card .piece {
  color: var(--o);
}

.score {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1;
}

.status-bar {
  margin-bottom: 14px;
  background: #fff;
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: inset 0 0 0 2px rgba(16, 37, 66, 0.08);
}

.status-bar p {
  margin: 0;
  text-align: center;
  font-weight: 600;
}

.board-wrap {
  display: grid;
  place-items: center;
}

.board {
  width: min(420px, calc(100vw - 70px));
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #fefefe;
}

.cell {
  border: 0;
  border-right: 4px solid var(--line);
  border-bottom: 4px solid var(--line);
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: clamp(2.3rem, 13vw, 4.4rem);
  font-weight: 700;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 180ms ease, transform 120ms ease;
}

.cell:nth-child(3n) {
  border-right: none;
}

.cell:nth-last-child(-n + 3) {
  border-bottom: none;
}

.cell:hover:enabled {
  background: rgba(16, 37, 66, 0.06);
}

.cell:active:enabled {
  transform: scale(0.98);
}

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

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

.controls {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 11px 16px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--ink);
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px rgba(16, 37, 66, 0.18);
}

@media (max-width: 480px) {
  .app-shell {
    border-radius: 20px;
    padding: 18px 14px;
  }

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

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

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
