:root {
  color-scheme: light;
  --ink: #1e2528;
  --muted: #667074;
  --paper: #f7f4ec;
  --surface: #fffdf8;
  --line: #d9d5ca;
  --yellow: #f4c95d;
  --coral: #ef765f;
  --green: #5e9c76;
  --shadow: 0 12px 30px rgba(30, 37, 40, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(30, 37, 40, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 37, 40, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font-family: Georgia, "Times New Roman", serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  width: min(100% - 32px, 440px);
  margin-inline: auto;
  padding-block: 32px;
}

.login-form {
  width: 100%;
  padding: clamp(24px, 7vw, 40px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.loading-content {
  display: flex;
  align-items: center;
  gap: 16px;
  font: 0.95rem/1.4 Arial, sans-serif;
}

.loading-content p { margin: 0; }

.loading-indicator {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border: 3px solid var(--line);
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.login-form h1 {
  font-size: clamp(2.5rem, 12vw, 4.5rem);
}

.login-copy {
  margin: 18px 0 28px;
  color: var(--muted);
  font: 0.95rem/1.55 Arial, sans-serif;
}

.primary-button,
.sign-out-button {
  min-height: 42px;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 4px;
  font: 700 0.8rem/1 Arial, sans-serif;
  cursor: pointer;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding-inline: 16px;
  background: #fff;
}

.primary-button:hover {
  background: #f5f5f5;
}

.primary-button:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.google-mark {
  color: #4285f4;
  font-size: 1rem;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.form-message {
  min-height: 1.4em;
  margin: 14px 0 0;
  color: var(--coral);
  font: 0.82rem/1.4 Arial, sans-serif;
}

.site-header,
main {
  width: min(100% - 32px, 1040px);
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
}

.sign-out-button {
  min-height: 34px;
  padding: 0 12px;
  background: transparent;
}

main {
  padding: clamp(32px, 7vw, 64px) 0 64px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--coral);
  font: 700 0.75rem/1 Arial, sans-serif;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(2.8rem, 10vw, 5rem);
  font-weight: 400;
  line-height: 1;
  text-wrap: balance;
}

.room-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.room-heading .eyebrow {
  margin-bottom: 8px;
}

.room-status {
  color: var(--muted);
  font: 0.85rem/1.4 Arial, sans-serif;
  text-align: right;
}

.room-players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.room-empty {
  padding: 32px 0;
  color: var(--muted);
  font: 0.95rem/1.5 Arial, sans-serif;
}

.player-seat {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.seat-number {
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--green);
  border-radius: 50%;
  color: #fff;
  font: 700 0.85rem/1 Arial, sans-serif;
}

.seat-details {
  display: grid;
  gap: 6px;
  min-width: 0;
  font: 0.85rem/1.35 Arial, sans-serif;
}

.seat-details strong {
  overflow-wrap: anywhere;
}

.seat-status {
  color: var(--green);
}

.match-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
  font: 0.88rem/1.4 Arial, sans-serif;
}

.match-actions button {
  min-height: 42px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--yellow);
  border: 1px solid var(--ink);
  border-radius: 4px;
  font: 700 0.82rem/1 Arial, sans-serif;
  cursor: pointer;
}

.match-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.match-actions button:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 2px;
}

.match-actions #decline-button,
.match-actions #leave-button {
  background: var(--surface);
}

#invitation {
  display: flex;
  gap: 8px;
}

#match-status {
  margin: 0;
  color: var(--muted);
}

.active-game {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.active-game h2 {
  margin: 0 0 20px;
  font-size: 1.6rem;
}

#game-frame {
  display: block;
  width: 100%;
  min-height: 480px;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.playing .room-heading h1 {
  font-size: 1.5rem;
}

.playing .room-players {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.playing .player-seat {
  padding: 8px 12px;
}

.playing .seat-number {
  flex-basis: 24px;
  width: 24px;
  height: 24px;
}

.playing .seat-details {
  font-size: 0.75rem;
}

.playing .seat-status {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@media (max-width: 640px) {
  .site-header,
  main {
    width: min(100% - 24px, 1040px);
  }

  .room-players {
    grid-template-columns: 1fr;
  }

  .room-heading {
    align-items: start;
    flex-direction: column;
  }

  .room-status {
    text-align: left;
  }

  #game-frame {
    min-height: 420px;
    aspect-ratio: 3 / 4;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}