:root {
  --bg: #15171e;
  --card: #1f222c;
  --card-2: #282c38;
  --line: #343949;
  --text: #f2f3f7;
  --muted: #a3a9ba;
  --accent: #f2cc40;
  --accent-text: #1c1a10;
  --danger: #ff7a70;
  --good: #6fdc8c;
  --common: #a3a9ba;
  --uncommon: #6fdc8c;
  --rare: #6aa8ff;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.loading { text-align: center; color: var(--muted); padding: 48px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }

/* ---- Buttons and inputs ---- */

button {
  font: inherit;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }
button.big { width: 100%; font-size: 1.1rem; min-height: 54px; }
button.quiet { background: none; border-color: transparent; color: var(--muted); padding: 8px 10px; }
button.link { background: none; border: none; color: var(--accent); padding: 8px 0; min-height: 0; text-decoration: underline; }

label { display: block; font-size: 0.875rem; color: var(--muted); margin: 12px 0 6px; }
input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  min-height: 48px;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.error { color: var(--danger); margin: 12px 0 0; min-height: 1.45em; }
.form-actions { margin-top: 18px; }
.switch { text-align: center; margin-top: 14px; }

/* ---- Input with a button beside it ---- */

.inline { display: flex; gap: 8px; align-items: stretch; }
.inline input { flex: 1; min-width: 0; }
.links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; }

/* ---- Join banner ---- */

.join { border-color: var(--accent); }
.join.done { border-color: var(--good); }
.join .player { font-size: 1.35rem; font-weight: 700; margin-bottom: 6px; }

/* ---- Character ---- */

.character { display: flex; gap: 16px; align-items: center; }
.avatar {
  flex: none;
  width: 56px;
  height: 104px;
  border-radius: 6px;
  position: relative;
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.18);
}
.avatar::after { content: ""; position: absolute; right: 9px; top: 20px; width: 10px; height: 10px; background: #111; }

.stats { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--card-2); border-radius: 10px; padding: 8px 10px; }
.stat .value { font-size: 1.2rem; font-weight: 700; }
.stat .label { font-size: 0.75rem; color: var(--muted); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.swatch { width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; border: 3px solid transparent; }
.swatch[aria-pressed="true"] { border-color: var(--text); }

/* ---- Items ---- */

.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: none; padding-top: 0; }
.row:last-child { padding-bottom: 0; }
.row .info { flex: 1; min-width: 0; }
.row .name { font-weight: 600; }
.row .slot { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.row .effect { font-size: 0.875rem; color: var(--muted); }

.pill { display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 1px 7px; border-radius: 999px; border: 1px solid currentColor; margin-left: 6px; vertical-align: 2px; }
.pill.common { color: var(--common); }
.pill.uncommon { color: var(--uncommon); }
.pill.rare { color: var(--rare); }
.count { color: var(--muted); font-weight: 400; margin-left: 4px; }

.chooser { background: var(--card-2); border-radius: 10px; padding: 4px 12px; margin: 10px 0 2px; }
.chooser .row { border-color: var(--bg); }
.chooser .row:first-of-type { padding-top: 12px; }
.chooser .row:last-child { padding-bottom: 12px; }

/* ---- Toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
