:root {
  --paper: #f5f3ee;
  --ink: #1d1d1b;
  --muted: #85847f;
  --line: #dedcd5;
  --lime: #c8f36a;
  --coral: #ff765e;
  --dark: #282825;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #d8d6cf;
  color: var(--ink);
  font-family: Arial, sans-serif;
}
.app-shell {
  max-width: 460px;
  min-height: 100vh;
  margin: auto;
  background: var(--paper);
  padding: 0 22px 26px;
}
button {
  font: inherit;
  border: 0;
  cursor: pointer;
  color: inherit;
  background: none;
}
.avatar {
  background: #8ac7df;
  border-radius: 50%;
  height: 35px;
  width: 35px;
  font-size: 11px;
}
.screen {
  display: none;
  padding-top: 35px;
}
.screen.active {
  display: block;
}
.eyebrow {
  font: 11px monospace;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.coral,
em {
  color: var(--coral);
  font-style: normal;
}
h1 {
  font-size: 52px;
  line-height: 0.95;
  letter-spacing: -4px;
  margin: 20px 0;
}
h2 {
  font-size: 17px;
  margin: 28px 0 12px;
}
.subcopy {
  color: #6f6e69;
  line-height: 1.55;
  max-width: 335px;
}
.actions {
  display: grid;
  gap: 10px;
  margin: 28px 0 33px;
}
.primary,
.secondary {
  height: 54px;
  padding: 0 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  border-radius: 3px;
}
.primary {
  background: var(--ink);
  color: var(--lime);
}
.secondary {
  border: 1px solid #c9c7bf;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
  padding: 17px 0;
}
.stats div {
  border-right: 1px solid var(--line);
  padding-left: 12px;
}
.stats div:first-child {
  padding-left: 0;
}
.stats div:last-child {
  border: 0;
}
.stats b {
  display: block;
  font-size: 23px;
}
.stats small,
.room small,
.chips small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
}
.room {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  padding: 13px;
}
.room i {
  background: var(--lime);
  border-radius: 50%;
  font-size: 22px;
  font-style: normal;
  padding: 7px;
}
.room div {
  flex: 1;
}
.round {
  background: var(--ink);
  color: var(--lime);
  border-radius: 50%;
  width: 32px;
  height: 32px;
}
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.section-title button {
  font-size: 11px;
  color: var(--muted);
}
.chips {
  display: flex;
  gap: 9px;
  overflow: hidden;
}
.chips article {
  min-width: 128px;
  border: 1px solid var(--line);
  padding: 13px;
  background: #efede7;
}
.chips strong {
  display: block;
  color: var(--coral);
  font-size: 22px;
  margin-bottom: 8px;
}
.chips b {
  display: block;
  font-size: 12px;
}
#toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 11px 17px;
  font: 11px monospace;
  opacity: 0;
  transition: 0.2s;
}
#toast.show {
  opacity: 1;
}
:root {
  color-scheme: light dark;
}
html[data-theme="light"] {
  color-scheme: light;
}
html[data-theme="dark"] {
  color-scheme: dark;
}
html[data-theme="dark"] body {
  background: #111311;
  color: #f3f1ea;
}
html[data-theme="dark"] .app-shell {
  background: #1b1d1a;
  --paper: #1b1d1a;
  --ink: #f3f1ea;
  --muted: #aaa99f;
  --line: #393d37;
  --dark: #0e100e;
}
html[data-theme="dark"] .subcopy,
html[data-theme="dark"] .stats small,
html[data-theme="dark"] .room small,
html[data-theme="dark"] .chips small {
  color: #aaa99f;
}
html[data-theme="dark"] .secondary {
  border-color: #555b53;
}
html[data-theme="dark"] .room,
html[data-theme="dark"] .chips article {
  background: #242823;
  border-color: #3b4239;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) body {
    background: #111311;
    color: #f3f1ea;
  }
  html:not([data-theme="light"]) .app-shell {
    background: #1b1d1a;
    --paper: #1b1d1a;
    --ink: #f3f1ea;
    --muted: #aaa99f;
    --line: #393d37;
    --dark: #0e100e;
  }
  html:not([data-theme="light"]) .subcopy,
  html:not([data-theme="light"]) .stats small,
  html:not([data-theme="light"]) .room small,
  html:not([data-theme="light"]) .chips small {
    color: #aaa99f;
  }
  html:not([data-theme="light"]) .secondary {
    border-color: #555b53;
  }
  html:not([data-theme="light"]) .room,
  html:not([data-theme="light"]) .chips article {
    background: #242823;
    border-color: #3b4239;
  }
}

dialog {
  border: 0;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  max-width: 340px;
  width: calc(100% - 36px);
  box-shadow: 0 20px 80px #0008;
}
dialog::backdrop {
  background: #1118;
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 20px 8px;
}
.dialog-head h2 {
  margin: 0;
}
.dialog-head button {
  font-size: 26px;
  color: var(--muted);
}
#profileForm {
  padding-bottom: 20px;
}
#profileForm label,
#profileForm input,
#profileForm .avatar-label {
  display: block;
  margin-left: 20px;
  margin-right: 20px;
}
#profileForm label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}
#profileName {
  width: calc(100% - 40px);
  margin-top: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  border-radius: 3px;
}
.avatar-label {
  margin-top: 20px !important;
}
.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 20px;
}
.avatar-picker button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 22px;
  background: transparent;
}
.avatar-picker button.chosen {
  border: 2px solid var(--coral);
  background: var(--lime);
}
.dialog-save {
  width: calc(100% - 40px);
  margin: 0 20px;
  justify-content: center;
}
.profile-auth-status {
  margin: 0 20px 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.profile-auth-actions {
  display: grid;
  gap: 8px;
  margin: 0 20px 14px;
}
.profile-provider,
.profile-logout {
  width: 100%;
  min-height: 44px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-weight: 700;
}
.profile-provider { display: flex; align-items: center; gap: 9px; }
.profile-provider:disabled {
  opacity: 0.48;
  filter: grayscale(1);
  cursor: not-allowed;
}
.profile-provider span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font: 700 15px Arial, sans-serif;
}
.profile-google { background: #fff; color: #252525; }
.profile-google span { background: #4285f4; }
.profile-facebook { background: #1877f2; color: #fff; border-color: #1877f2; }
.profile-facebook span { background: #fff; color: #1877f2; font-family: Arial, sans-serif; }
.profile-provider-hint,
.profile-form-error {
  margin: 0 20px 12px;
  font-size: 12px;
  line-height: 1.35;
}
.profile-provider-hint { color: var(--muted); }
.profile-form-error { min-height: 16px; color: var(--coral); font-weight: 700; }
.profile-logout { margin: 9px 20px 0; }

html[data-theme="dark"] .primary {
  background: var(--lime);
  color: #1d1d1b;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .primary {
    background: var(--lime);
    color: #1d1d1b;
  }
}

/* Achievement notifications stay readable in either theme and out of the board. */
#toast {
  width: min(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 13px 20px;
  text-align: center;
  line-height: 1.35;
  border: 1px solid var(--toast-border, #4b4b46);
  border-radius: 4px;
  background: var(--toast-bg, #282825);
  color: var(--toast-fg, #fff);
  z-index: 20;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition:
    opacity 0.25s,
    transform 0.25s;
}
#toast.show {
  transform: translate(-50%, 0);
}
#toast.toast-duplicate {
  border: 2px solid #2c1c37;
  background: #f6c85f;
  color: #2c1c37;
  font-weight: 900;
}
#toast.toast-wrong {
  border: 2px solid #fff;
  background: #dd2857;
  color: #fff;
  font-size: 1rem;
  font-weight: 950;
  box-shadow: 0 4px 0 #7b1737;
  animation: wrong-toast-shake .42s ease-in-out;
}
@keyframes wrong-toast-shake {
  0%, 100% { transform: translate(-50%, 0); }
  25% { transform: translate(calc(-50% - 7px), 0) rotate(-1deg); }
  75% { transform: translate(calc(-50% + 7px), 0) rotate(1deg); }
}
body:has(#gameScreen.active) #toast {
  top: 10px;
  bottom: auto;
}
html[data-theme="dark"] #toast {
  --toast-bg: #f3f1ea;
  --toast-fg: #1b1d1a;
  --toast-border: #aaa99f;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) #toast {
    --toast-bg: #f3f1ea;
    --toast-fg: #1b1d1a;
    --toast-border: #aaa99f;
  }
}
.analytics-consent {
  position: fixed;
  z-index: 1200;
  top: 50%;
  left: 50%;
  width: min(420px, calc(100vw - 36px));
  max-width: calc(100vw - 36px);
  margin: 0;
  padding: 22px;
  border: 2px solid #2c1c37;
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf7, #fff0d6);
  color: #2c1c37;
  box-shadow: 0 8px 0 #2c1c37, 0 24px 70px #0009;
  transform: translate(-50%, -50%);
  text-align: left;
}
.analytics-consent::backdrop {
  background: #171121cc;
  backdrop-filter: blur(3px);
}
.analytics-consent[open] {
  display: grid;
  gap: 14px;
}
.analytics-consent strong {
  font-size: 20px;
  line-height: 1.1;
}
.analytics-consent p {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}
.analytics-consent div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}
.analytics-consent button {
  justify-content: center;
  white-space: normal;
}
.analytics-preferences {
  width: 100%;
  justify-content: center;
  margin: 10px 0 0;
}
html[data-theme="dark"] .analytics-consent {
  border-color: #f6c85f;
  background: linear-gradient(180deg, #2b2235, #1c1723);
  color: #fff9f0;
  box-shadow: 0 7px 0 #f6c85f, 0 18px 50px #0009;
}
@media (max-width: 540px) {
  .analytics-consent { padding: 18px; }
  .analytics-consent div { grid-template-columns: 1fr; }
}
