:root {
  --bg: #0d0d4a;
  --bg-dark: #060b3d;
  --text: #ffffff;
  --yellow: #ffd400;
  --red: #e60000;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column; /* footer snaps to bottom when content is short */
  background: radial-gradient(ellipse at 50% 0%, #1b1b7a 0%, var(--bg) 55%, #080838 100%) fixed;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.content {
  flex: 1 0 auto; /* grows to fill space and pushes footer down */
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 85px 20px 40px;
}

/* Logo */
.logo {
  display: block;
  max-width: 100%;
  height: auto;
  margin-bottom: 55px;
  object-fit: contain;
}

/* Links */
a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover,
a:focus-visible {
  color: var(--yellow);
}

.auth-links {
  margin: 0 0 30px;
  font-size: 17px;
}

/* Menu buttons */
.menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 324px;
}

.btn {
  display: block;
  padding: 26px 20px;
  background: linear-gradient(to bottom, #12125f 0%, var(--bg-dark) 100%);
  color: var(--text);
  text-align: center;
  text-decoration: none;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 5px 0 #02031f, 0 8px 16px rgba(0, 0, 0, 0.35);
}

.btn:hover,
.btn:focus-visible {
  background: var(--yellow);
  color: var(--red);
  outline: none;
  box-shadow: 0 5px 0 #b39400, 0 8px 16px rgba(0, 0, 0, 0.35);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #b39400, 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* Home: intro on the left, menu rows on the right */
.home {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
}

.home-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.home .logo {
  margin-bottom: 28px;
}

/* Home page: everything sits vertically centred between the top and the footer. */
.content-home {
  justify-content: center;
  padding-top: 70px;
  padding-bottom: 150px;
}

.content-home > .auth-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 0 56px;
}

.auth-prompt {
  flex-basis: 100%;
  margin-bottom: 8px;
  font-size: 54px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
  text-align: center;
}

.auth-or {
  font-size: 15px;
  opacity: 0.85;
}

.auth-user {
  margin-right: 6px;
  font-size: 15px;
  opacity: 0.85;
}

.btn-mini {
  display: inline-block;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.1em;
  background: #060b3d;
  border: 4px solid #040b31;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
}

.btn-mini:hover,
.btn-mini:focus-visible,
.btn-mini:active {
  border-color: #830000;
  background: var(--yellow);
  color: var(--red);
  box-shadow: none;
  transform: none;
}

.home .menu {
  max-width: 440px;
  margin-top: 44px;
}

.menu .btn {
  background: #060b3d;
  border: 6px solid #040b31;
  border-radius: 0;
  box-shadow: none;
  padding: 26px 20px;
  text-align: center;
}

.menu .btn:hover,
.menu .btn:focus-visible,
.menu .btn:active {
  border-color: #830000;
  background: var(--yellow);
  color: var(--red);
  box-shadow: none;
  transform: none;
}

.menu .btn:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 4px;
}

@media (min-width: 900px) {
  .home {
    display: grid;
    grid-template-columns: 1fr 440px;
    align-items: center;
    gap: 72px;
  }

  .home .menu {
    margin-top: 0;
  }
}

/* Footer */
.footer {
  flex-shrink: 0;
  background: rgb(8 8 48 / 84%);
  border-top: 6px solid #040b31;
  padding: 42px 24px 48px;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 1040px;
  margin: 0 auto;
  text-align: center;
}

.footer p {
  margin: 0;
}

.footer-credit {
  font-size: 14px;
  line-height: 1.6;
  color: #3d4783;
}

.footer-credit a {
  color: #4b57a0;
  text-decoration: none;
}

.footer-credit a:hover,
.footer-credit a:focus-visible {
  color: var(--yellow);
}

.footer-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.footer-links {
  display: flex;
  gap: 24px;
  font-size: 15px;
  font-weight: 500;
}

.footer-links a {
  color: #4b57a0;
  text-decoration: none;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--yellow);
}

.footer-icons {
  display: flex;
  gap: 18px;
  font-size: 20px;
}

.footer-icons a {
  color: #3d4783;
  text-decoration: none;
}

.footer-icons a:hover,
.footer-icons a:focus-visible {
  color: var(--yellow);
}

@media (min-width: 760px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }

  .footer-side {
    flex-direction: row;
    gap: 32px;
  }
}

@media (max-width: 480px) {
  .content {
    padding-top: 50px;
  }
}

/* Sub pages */
.logo-small {
  max-width: 220px;
  margin-bottom: 30px;
}

.page-title {
  margin: 0 0 16px;
  font-size: 32px;
}

.page-text {
  margin: 0 0 30px;
  max-width: 480px;
  text-align: center;
  line-height: 1.5;
}

/* Forms */
.card {
  width: 100%;
  max-width: 440px;
  padding: 40px 36px 34px;
  background: var(--bg-dark);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.card-title {
  margin: 0 0 6px;
  font-size: 28px;
  text-align: center;
}

.card-sub {
  margin: 0 0 24px;
  font-size: 14px;
  text-align: center;
  opacity: 0.7;
}

.card-title + .form-errors,
.card-title + .form {
  margin-top: 18px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form input {
  padding: 20px 20px;
  font: inherit;
  font-size: 18px;
  color: var(--text);
  background: var(--bg);
  border: 0;
  border-radius: 10px;
}

.form input::placeholder {
  color: var(--text);
  opacity: 0.5;
}

.form input:focus {
  outline: 2px solid var(--yellow);
}

.form .btn {
  margin-top: 8px;
  width: 100%;
  font-family: inherit;
  cursor: pointer;
}

.form-errors {
  margin: 0 0 20px;
  padding: 12px 14px 12px 32px;
  background: var(--red);
  border-radius: 8px;
  font-size: 14px;
}

.card-alt {
  margin: 22px 0 0;
  font-size: 15px;
  text-align: center;
}

.link-btn {
  padding: 0;
  font: inherit;
  color: var(--text);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-btn:hover,
.link-btn:focus-visible {
  color: var(--yellow);
}


/* 3D stage */
.stage {
  position: relative;
  flex: 1 0 auto;
  min-height: 100dvh;
}

.scene {
  position: absolute;
  inset: 0;
}

.scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* lets OrbitControls handle drag and pinch */
}

.scene-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  pointer-events: none;
}

/* Game room: chat column on the left, player list on the right */
:root {
  --red-text: #ff5a5a;
  --blue-text: #6fa8ff;
}

.game-title {
  margin: 0;
}

.game-code {
  display: block;
  width: 100%;
  padding: 4px 0;
  font: inherit;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
  color: var(--yellow);
  background: none;
  border: 0;
  cursor: pointer;
}

.game-code:hover,
.game-code:focus-visible {
  color: var(--text);
}

.side {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 16px 16px;
  background: transparent;
}

/* Tinted only once the conversation has started. */
.side.has-chat {
  background: rgba(6, 11, 61, 0.1);
}

.side-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.close-room {
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: rgba(224, 24, 24, 0.55);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.close-room[hidden] {
  display: none;
}

.close-room:hover,
.close-room:focus-visible {
  background: var(--yellow);
  color: var(--red);
}

.chat-log {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

/* Pushes short conversations down so the newest message sits next to the input. */
.chat-log > li:first-child {
  margin-top: auto;
}

.chat-system {
  font-size: 13px;
  font-style: italic;
  opacity: 0.7;
}

.chat-name {
  font-weight: 800;
}

.chat-name[data-role="1"] { color: var(--yellow); }
.chat-name[data-role="2"] { color: var(--red-text); }
.chat-name[data-role="0"] { color: var(--blue-text); }

.chat-form input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  border-radius: 8px;
}

.chat-form input::placeholder {
  color: var(--text);
  opacity: 0.5;
}

.chat-form input:focus {
  outline: 2px solid var(--yellow);
}

.side-logo {
  display: block;
  width: 100%;
  max-width: 170px;
  margin: 0 auto 4px;
}

.side-logo img {
  display: block;
  width: 100%;
  height: auto;
}

/* Transparent strip along the top of the game page, right-aligned. The player list sits below it; the chat pane ignores it and always starts at the very top. */
.stage {
  --bar-h: 28px;
}

.stats {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  height: var(--bar-h, 28px);
  margin: 0;
  padding: 0 16px;
  list-style: none;
  font-size: 11px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); /* stays readable over the scene without a background */
  pointer-events: none;
}

/* Home page: centred and a little larger than in-game */
.stats-home {
  --bar-h: 40px;
  top: 16px;
  justify-content: center;
  font-size: 14px;
}

.stats[hidden] {
  display: none;
}

.stage.has-stats .roster {
  top: calc(var(--bar-h) + 12px);
}

/* Wide screens: an arrow tab on the pane's right edge, halfway down the screen. */
.chat-toggle {
  position: absolute;
  top: 50%;
  left: 300px; /* the chat pane's width */
  z-index: 3;
  width: 28px;
  height: 64px;
  padding: 0;
  font: inherit;
  color: var(--text);
  background: rgba(6, 11, 61, 0.7);
  border: 0;
  border-radius: 0 10px 10px 0;
  transform: translateY(-50%);
  cursor: pointer;
  transition: left 0.25s ease;
}

.stage.chat-hidden .chat-toggle {
  left: 0;
}

.chat-toggle:hover,
.chat-toggle:focus-visible {
  color: var(--red);
  background: var(--yellow);
}

.chat-toggle-icon::before {
  content: '\2039'; /* single left-pointing angle: collapse */
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

.stage.chat-hidden .chat-toggle-icon::before {
  content: '\203A'; /* single right-pointing angle: expand */
}

/* The words are only for screen readers (and for the phone layout). */
.chat-toggle-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* A dot shows that messages arrived while the chat was hidden. */
.chat-toggle.unread::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--yellow);
  border-radius: 50%;
}

.chat-toggle.unread:hover::after {
  background: var(--red);
}

/* Collapses to the left; visibility flips after the slide so hidden controls can't be tabbed to. */
.side {
  transition: transform 0.25s ease, visibility 0s;
}

.stage.chat-hidden .side {
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s 0.25s;
}

.stats li[hidden] {
  display: none;
}

/* A separator before every visible stat except the first visible one. */
.stats li:not([hidden]) ~ li:not([hidden])::before {
  content: '|';
  margin: 0 8px;
  opacity: 0.6;
}

.roster {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 200px;
}

.roster-block {
  padding: 14px 16px;
  background: rgba(6, 11, 61, 0.7);
  border-radius: 12px;
}

.roster-block[hidden] {
  display: none;
}

.roster-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.7;
}

.roster-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
  font-weight: 700;
}

.roster-list li {
  padding: 3px 0;
  overflow-wrap: anywhere;
}

.roster-list li[data-role="1"] { color: var(--yellow); }
.roster-list li[data-role="2"] { color: var(--red-text); }

@media (max-width: 640px) {
  /* Phones: the pane spans the bottom, so a labelled pill sits in the top-left corner instead. */
  .chat-toggle,
  .stage.chat-hidden .chat-toggle {
    top: 8px;
    left: 8px;
    width: auto;
    height: auto;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 999px;
    transform: none;
    transition: none;
  }

  .chat-toggle-icon {
    display: none;
  }

  .chat-toggle-label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }

  .chat-toggle.unread::after {
    position: static;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
  }

  .stage.chat-hidden .side {
    display: none;
    transform: none;
  }

  /* The chat grows with its messages up to a maximum height, then scrolls. */
  .side {
    top: auto;
    width: 100%;
    height: auto;
    max-height: 60%;
  }

  .chat-log {
    flex: 0 1 auto;
    max-height: 15vh;
  }

  .roster {
    top: 10px;
    right: 10px;
    width: 150px;
  }

  .stage.has-stats .roster {
    top: calc(var(--bar-h) + 8px);
  }


  .roster-block {
    padding: 10px 12px;
  }
}

/* Login and create account: flat card, inputs and buttons match the home menu */
.auth-card {
  max-width: 440px;
  padding: 44px 36px 36px;
  background: rgb(8 8 48 / 84%);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.auth-card .card-title {
  margin: 0 0 28px;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  text-align: left;
}

.auth-card .card-title + .form,
.auth-card .card-title + .form-errors {
  margin-top: 0;
}

.auth-card .form {
  gap: 14px;
}

.auth-card .form input {
  padding: 16px 18px;
  font-size: 17px;
  background: #00000021;
  border: 6px solid #00000012;
  border-radius: 0;
}

.auth-card .form input::placeholder {
  opacity: 0.3;
}

.auth-card .form input:focus {
  outline: none;
  border-color: var(--yellow);
}

.auth-card .form-errors {
  margin: 0 0 20px;
  padding: 12px 16px 12px 32px;
  font-size: 14px;
  color: #ffb4b4;
  background: rgba(230, 0, 0, 0.14);
  border-radius: 0;
}

.auth-card .form .btn {
  margin-top: 10px;
  padding: 22px 20px;
  font-size: 18px;
  background: #00000021;
  border: 6px solid #00000012;
  border-radius: 0;
  box-shadow: none;
}

.auth-card .form .btn:hover,
.auth-card .form .btn:focus-visible,
.auth-card .form .btn:active {
  border-color: #830000;
  background: var(--yellow);
  color: var(--red);
  box-shadow: none;
  transform: none;
}

.auth-card .card-alt {
  margin: 28px 0 0;
  text-align: center;
  font-size: 15px;
  opacity: 0.75;
}

@media (max-width: 480px) {
  .auth-card {
    padding: 32px 20px 28px;
  }
}

/* Join page: flat, hairline-divided, quiet */
.join-card {
  max-width: 960px;
  padding: 44px 40px 36px;
  background: rgb(8 8 48 / 84%);
  border-radius: 0;
  box-shadow: none;
}

.join-card .card-title {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  text-align: left;
}

.join-card .card-sub {
  margin: 10px 0 0;
  font-size: 15px;
  text-align: left;
  opacity: 0.65;
}

.join-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.join-card .btn-small {
  width: auto;
  padding: 16px 24px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  background: #00000021;
  border: 6px solid #00000012;
  border-radius: 0;
  box-shadow: none;
}

.join-card .btn-small:hover,
.join-card .btn-small:focus-visible,
.join-card .btn-small:active {
  border-color: #830000;
  background: var(--yellow);
  color: var(--red);
  box-shadow: none;
  transform: none;
}

.code-form {
  display: flex;
  gap: 12px;
  margin: 32px 0 0;
}

.code-form input {
  flex: 1;
  min-width: 0;
  padding: 15px 18px;
  font: inherit;
  font-size: 17px;
  text-align: left;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--yellow);
  background: #00000021;
  border: 6px solid #00000012;
  border-radius: 0;
}

.code-form input::placeholder {
  letter-spacing: normal;
  text-transform: none;
  font-weight: 400;
  color: var(--text);
  opacity: 0.5;
}

.code-form input:focus {
  outline: none;
  border-color: var(--yellow);
}

.code-error {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--red-text, #ff5a5a);
}

.table-wrap {
  margin-top: 40px;
  overflow-x: auto;
}

.rooms {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  white-space: nowrap;
}

.rooms th {
  padding: 0 16px 12px;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  opacity: 0.6;
}

.rooms td {
  padding: 18px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.rooms tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.rooms .num {
  font-variant-numeric: tabular-nums;
}

.rooms .name-host { color: var(--yellow); font-weight: 600; }
.rooms .name-opponent { color: var(--red-text, #ff5a5a); font-weight: 600; }
.rooms .muted { opacity: 0.6; }

.tag {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.tag-live {
  color: #9be3a8;
  background: rgba(155, 227, 168, 0.12);
}

.rooms-empty {
  padding: 48px 16px;
  text-align: center;
  opacity: 0.7;
}

.rooms-join {
  display: inline-block;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text);
  background: #00000021;
  border: 4px solid #00000012;
  border-radius: 0;
}

.rooms-join:hover,
.rooms-join:focus-visible {
  color: var(--red);
  background: var(--yellow);
  border-color: #830000;
}

@media (max-width: 640px) {
  .join-card {
    padding: 24px 16px;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Short centered announcement over the 3D scene */
.toast {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: calc(100% - 32px);
  padding: 18px 28px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: var(--yellow);
  background: rgba(6, 11, 61, 0.85);
  border-radius: 12px;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.toast.show {
  opacity: 1;
}

.toast-title {
  font-size: 18px;
  color: var(--text);
}

.toast-subtitle {
  margin-top: 6px;
  font-size: 34px;
  line-height: 1.15;
}

/* "Your turn!" across the top, shown only to the player whose move it is */
.turn-banner {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--yellow);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.turn-banner[hidden] {
  display: none;
}

@media (max-width: 640px) {
  /* Bottom of the screen, just above the chat pane when it is showing (--side-h is set in game.js). */
  .turn-banner {
    top: auto;
    bottom: calc(var(--side-h, 0px) + 16px);
    font-size: 30px;
  }
}

/* Long-form pages (privacy policy, terms): one quiet reading column */
.legal {
  width: 100%;
  max-width: 680px;
  padding: 24px 0 40px;
  font-size: 16px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.82);
}

.legal h1 {
  margin: 0 0 8px;
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.legal-updated {
  margin: 0 0 40px;
  font-size: 14px;
  opacity: 0.55;
}

.legal h2 {
  margin: 48px 0 12px;
  padding-top: 32px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text);
}

.legal h3 {
  margin: 24px 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.legal p,
.legal ul {
  margin: 0 0 16px;
}

.legal ul {
  padding-left: 20px;
}

.legal li {
  margin-bottom: 8px;
}

.legal li::marker {
  color: rgba(255, 255, 255, 0.35);
}

.legal strong {
  font-weight: 600;
  color: var(--text);
}

.legal a {
  text-decoration-color: rgba(255, 255, 255, 0.35);
}

.legal a:hover,
.legal a:focus-visible {
  text-decoration-color: currentColor;
}

@media (max-width: 640px) {
  .legal {
    padding: 8px 4px 24px;
  }

  .legal h1 {
    font-size: 32px;
  }

  .legal h2 {
    margin-top: 36px;
    padding-top: 24px;
  }
}

/* Local match page */
.local-logo {
  position: absolute;
  top: 12px;
  left: 16px;
  z-index: 3;
  width: 130px;
}

.local-logo img {
  display: block;
  width: 100%;
  height: auto;
}

.local-restart {
  position: absolute;
  top: 36px; /* just below the stats strip */
  right: 16px;
  z-index: 3;
  padding: 10px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  background: rgba(6, 11, 61, 0.8);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.local-restart:hover,
.local-restart:focus-visible {
  color: var(--red);
  background: var(--yellow);
}

.turn-banner[data-player="2"] {
  color: var(--red-text);
}

/* Public / private room switch, top-left of the game page */
.privacy-toggle {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: rgba(6, 11, 61, 0.7);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.privacy-toggle:not(:disabled):hover,
.privacy-toggle:not(:disabled):focus-visible {
  color: var(--red);
  background: var(--yellow);
}

.privacy-toggle:disabled {
  cursor: default;
  opacity: 0.8;
}

/* Leaves room for the toggle above the logo in the chat pane. */
.side {
  padding-top: 52px;
}

@media (max-width: 640px) {
  .side {
    padding-top: 18px;
  }

  /* Sits beside the chat button, which holds the top-left corner on phones. */
  .privacy-toggle {
    left: 120px;
    top: 8px;
  }
}


/* End-of-match popup, near the top so the board stays visible underneath */
.match-popup {
  position: absolute;
  top: 44px;
  left: 50%;
  z-index: 4;
  width: min(460px, calc(100% - 32px));
  padding: 18px 20px 16px;
  text-align: center;
  background: rgba(6, 11, 61, 0.92);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%);
}

.match-popup[hidden] {
  display: none;
}

.match-title {
  margin: 0 0 4px;
  font-size: 30px;
  color: var(--yellow);
}

.match-note {
  margin: 0 0 14px;
  min-height: 1.3em;
  font-size: 14px;
  opacity: 0.8;
}

.match-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.popup-btn {
  flex: 1 1 auto;
  padding: 11px 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.popup-btn-primary {
  color: var(--red);
  background: var(--yellow);
}

.popup-btn:not(:disabled):hover,
.popup-btn:not(:disabled):focus-visible {
  color: var(--red);
  background: var(--yellow);
}

.popup-btn:disabled {
  cursor: default;
  opacity: 0.6;
}

/* Settings page: builds on .auth-card */
.settings-card {
  max-width: 480px;
}

.settings-card .card-title {
  margin-bottom: 8px;
}

.settings-card .card-sub {
  margin: 0;
  font-size: 15px;
  text-align: left;
  opacity: 0.75;
}

.settings-section {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-section h2 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text);
}

.settings-hint {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.6;
  opacity: 0.65;
  overflow-wrap: anywhere;
}

.settings-section .form .btn-small,
.settings-card .form .btn-small {
  align-self: flex-start;
  width: auto;
  padding: 16px 24px;
  font-size: 15px;
}

.form-ok {
  margin: 0 0 20px;
  padding: 12px 16px 12px 32px;
  font-size: 14px;
  color: #9be3a8;
  background: rgba(155, 227, 168, 0.12);
  border-radius: 0;
}

.settings-card .form .btn-danger {
  color: #ffb4b4;
  background: rgba(230, 0, 0, 0.14);
}

.settings-card .form .btn-danger:hover,
.settings-card .form .btn-danger:focus-visible,
.settings-card .form .btn-danger:active {
  border-color: #830000;
  background: var(--yellow);
  color: var(--red);
}

/* Leaderboard */
.leaderboard .num {
  text-align: right;
}

.leaderboard tr.is-you td {
  color: var(--yellow);
  font-weight: 700;
}

/* Game and local views: buttons and the chat field follow the home menu style
   (dark translucent fill, thick translucent border, straight corners, yellow on hover). */
.close-room,
.privacy-toggle,
.popup-btn,
.local-restart,
.chat-toggle,
.stage.chat-hidden .chat-toggle {
  color: var(--text);
  background: #00000021;
  border: 4px solid #00000012;
  border-radius: 0;
  box-shadow: none;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.close-room,
.privacy-toggle {
  font-size: 12px;
}

.popup-btn {
  font-size: 14px;
}

.close-room {
  padding: 9px 12px;
}

.chat-toggle {
  border-left: 0;
}

.stage.chat-hidden .chat-toggle {
  border-left: 0;
}

.popup-btn-primary {
  color: var(--text);
  background: #00000021;
  border-color: var(--yellow);
}

.close-room:hover,
.close-room:focus-visible,
.privacy-toggle:not(:disabled):hover,
.privacy-toggle:not(:disabled):focus-visible,
.popup-btn:not(:disabled):hover,
.popup-btn:not(:disabled):focus-visible,
.local-restart:hover,
.local-restart:focus-visible,
.chat-toggle:hover,
.chat-toggle:focus-visible {
  color: var(--red);
  background: var(--yellow);
  border-color: #830000;
}

.chat-form input {
  padding: 12px 14px;
  background: #00000021;
  border: 4px solid #00000012;
  border-radius: 0;
}

.chat-form input:focus {
  outline: none;
  border-color: var(--yellow);
}

@media (max-width: 640px) {
  .chat-toggle,
  .stage.chat-hidden .chat-toggle {
    border: 4px solid #00000012;
    border-radius: 0;
  }

  .chat-toggle:hover,
  .chat-toggle:focus-visible {
    border-color: #830000;
  }
}

/* The public/private switch now sits in the chat pane, right under the logo. */
.privacy-toggle {
  position: static;
  align-self: center;
  padding: 8px 16px;
}

.side {
  padding-top: 18px;
}

@media (max-width: 640px) {
  .privacy-toggle {
    left: auto;
    top: auto;
  }
}

/* The logo lives outside the chat pane so it stays when the pane is hidden. */
.side-logo {
  position: absolute;
  top: 18px;
  left: 65px; /* centred over the 300px pane */
  z-index: 3;
  width: 170px;
  max-width: none;
  margin: 0;
  transition: left 0.25s ease;
}

.stage.chat-hidden .side-logo {
  left: 16px;
}

.side {
  padding-top: 143px; /* room for the logo above the pane's content */
}

@media (max-width: 640px) {
  .side-logo,
  .stage.chat-hidden .side-logo {
    top: 52px; /* below the Hide/Show chat pill */
    left: 8px;
    width: 100px;
    transition: none;
  }

  .side {
    padding-top: 18px;
  }
}

/* Home page: the live 3D board sits behind everything, blurred and dimmed. */
.scene-bg {
  position: fixed;
  inset: -4%; /* the blur and slight overscan keep soft edges off screen */
  z-index: -1;
  pointer-events: none;
  opacity: 0.55;
  filter: blur(7px);
}

/* Dark overlay over the blurred board so the menu stays readable. */
.scene-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 24, 0.6);
  pointer-events: none;
}

/* "Remember me" checkbox on the login form */
.auth-card .form .remember {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  cursor: pointer;
}

.auth-card .form .remember input {
  appearance: none;
  display: grid;
  place-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  margin: 0;
  background: #00000021;
  border: 3px solid #00000012;
  border-radius: 0;
  cursor: pointer;
}

.auth-card .form .remember input::before {
  content: '';
  width: 10px;
  height: 6px;
  margin-top: -2px;
  border-left: 3px solid var(--yellow);
  border-bottom: 3px solid var(--yellow);
  transform: rotate(-45deg) scale(0);
}

.auth-card .form .remember input:checked::before {
  transform: rotate(-45deg) scale(1);
}

.auth-card .form .remember input:focus-visible {
  outline: none;
  border-color: var(--yellow);
}

/* Phones: the welcome text gets its own line, with Settings and Logout beneath it. */
@media (max-width: 640px) {
  .auth-user {
    flex-basis: 100%;
    margin-right: 0;
    text-align: center;
  }
}

/* Phones: the logo and the New game button are half size in the game views. */
@media (max-width: 640px) {
  .local-logo {
    width: 65px;
  }

  .local-restart {
    top: 26px;
    transform: scale(0.9);
    transform-origin: top right;
  }

  .side-logo,
  .stage.chat-hidden .side-logo {
    width: 50px;
  }
}
