:root {
  --background: #15130f;
  --surface: #221f19;
  --text: #f1ece2;
  --muted: #c9c0ae;
  --accent: #e2b04a;
  --border: #5c5446;
  --focus: #ffd56b;
  --danger: #ff8a7a;
  --rarity-common: #d6d6d6;
  --rarity-uncommon: #7fd67f;
  --rarity-rare: #8ab8ff;
  color-scheme: dark;
}

/* Light colors: from the device setting unless the player picked Dark, or picked Light. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --background: #f7f3ea;
    --surface: #ffffff;
    --text: #1d1a14;
    --muted: #4d463a;
    --accent: #7a5200;
    --border: #9b907c;
    --focus: #0b57d0;
    --danger: #a32014;
    --rarity-common: #4a4a4a;
    --rarity-uncommon: #1d6b1d;
    --rarity-rare: #1f4fa8;
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --background: #f7f3ea;
  --surface: #ffffff;
  --text: #1d1a14;
  --muted: #4d463a;
  --accent: #7a5200;
  --border: #9b907c;
  --focus: #0b57d0;
  --danger: #a32014;
  --rarity-common: #4a4a4a;
  --rarity-uncommon: #1d6b1d;
  --rarity-rare: #1f4fa8;
  color-scheme: light;
}

/* High contrast: from the setting, which starts on when the device asks for more contrast. */
:root[data-contrast="high"] {
  --background: #000000;
  --surface: #000000;
  --text: #ffffff;
  --muted: #ffffff;
  --accent: #ffff00;
  --border: #ffffff;
  --focus: #ffff00;
  --danger: #ffff00;
  --rarity-common: #ffffff;
  --rarity-uncommon: #7dff7d;
  --rarity-rare: #8fd3ff;
}

@media (prefers-color-scheme: light) {
  :root[data-contrast="high"]:not([data-theme="dark"]) {
    --background: #ffffff;
    --surface: #ffffff;
    --text: #000000;
    --muted: #000000;
    --accent: #000000;
    --border: #000000;
    --focus: #0000c0;
    --danger: #a00000;
    --rarity-common: #000000;
    --rarity-uncommon: #005000;
    --rarity-rare: #00008a;
  }
}

:root[data-contrast="high"][data-theme="light"] {
  --background: #ffffff;
  --surface: #ffffff;
  --text: #000000;
  --muted: #000000;
  --accent: #000000;
  --border: #000000;
  --focus: #0000c0;
  --danger: #a00000;
  --rarity-common: #000000;
  --rarity-uncommon: #005000;
  --rarity-rare: #00008a;
}

:root[data-contrast="high"] button,
:root[data-contrast="high"] section {
  border-width: 3px;
}

/* Windows high contrast and other forced-color modes: let the system colors through. */
@media (forced-colors: active) {
  button {
    border: 2px solid ButtonText;
  }
  :focus-visible {
    outline: 3px solid Highlight;
  }
}

* {
  box-sizing: border-box;
}

html {
  /* --text-scale comes from the Text size setting. Everything else is sized in rem. */
  font-size: calc(112.5% * var(--text-scale, 1));
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.page-header,
main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.page-header {
  padding-top: 1rem;
}

h1 {
  margin: 0;
  color: var(--accent);
  font-size: 1.6rem;
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1.3rem;
}

h3 {
  margin: 1rem 0 0.25rem;
  font-size: 1.1rem;
}

section {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

p {
  margin: 0.25rem 0 0.75rem;
}

.prototype-note,
.hint,
.zone-name,
#connection-status {
  color: var(--muted);
}

.hint {
  font-size: 0.95rem;
}

button {
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: 0.4rem;
  background: var(--background);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[tabindex="-1"]:focus {
  outline: none;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.button-list button {
  width: 100%;
}

.button-list .is-target {
  border-color: var(--accent);
}

.button-list .is-winding-up {
  border-color: var(--danger);
  border-style: dashed;
}

.message-log {
  max-height: 18rem;
  overflow-y: auto;
  margin: 0;
  padding-left: 1.5rem;
}

.message-log .urgent {
  color: var(--danger);
  font-weight: 600;
}

.bag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.bag-list li {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.bag-list .button-row {
  margin-top: 0.25rem;
}

/* Color is only a bonus here. The rarity word is always in the text. */
.rarity-common { color: var(--rarity-common); }
.rarity-uncommon { color: var(--rarity-uncommon); }
.rarity-rare { color: var(--rarity-rare); }

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.5rem;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.3rem;
  height: 1.3rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
}

th,
td {
  text-align: left;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- account pages */

.nav-links {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}

a {
  color: var(--accent);
}

/* A link that looks like the game's buttons. It's a link because it goes to another page. */
.button-link {
  display: block;
  min-height: 2.75rem;
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: 0.4rem;
  background: var(--background);
  color: var(--text);
  text-decoration: none;
}

.button-link:hover {
  border-color: var(--accent);
}

.field {
  margin: 0 0 1rem;
}

.field label {
  display: block;
  min-height: 0;
  font-weight: 600;
}

.field .hint {
  margin: 0 0 0.25rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  max-width: 24rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.6rem;
  border: 2px solid var(--border);
  border-radius: 0.4rem;
  background: var(--background);
  color: var(--text);
  /* 16px or more stops Safari on iPhone zooming in when a field is chosen. */
  font: inherit;
  font-size: max(1rem, 16px);
}

input[aria-invalid="true"] {
  border-color: var(--danger);
  border-width: 3px;
}

.form-error {
  color: var(--danger);
  font-weight: 600;
}

.account-message:empty {
  display: none;
}

.account-message {
  margin: 1rem 0 0;
  font-weight: 600;
}

#logout-button {
  margin-top: 1rem;
}

.nav-links #logout-button {
  margin-top: 0;
}
