/* Whodreamt — night UI: deep indigo, paper-cream, one violet accent. */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #151530;
  --bg2: #1c1c40;
  --ink: #f2ead9;
  --dim: #9d97b8;
  --accent: #8b7cf6;
  --accent2: #b3a7ff;
  --good: #7fe0a7;
  --bad: #ef8a8a;
  --gold: #ffd98a;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow-x: hidden;
}

/* night sky */
#stars {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1px 1px at 20% 30%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 70% 15%, #fff7 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 70%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 60%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 10% 85%, #fff4 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 60% 90%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 90% 35%, #fff8 50%, transparent 51%),
    linear-gradient(180deg, #151530 0%, #191940 60%, #151530 100%);
}

main {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto;
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
}

.screen { display: none; animation: rise .35s ease; }
.screen.on { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(44px, 12vw, 72px);
  font-style: italic; text-align: center; letter-spacing: -1px;
  background: linear-gradient(180deg, var(--ink), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tag { text-align: center; color: var(--dim); margin-bottom: 28px; font-style: italic; }

.h { font-family: Georgia, serif; font-weight: 400; font-size: 28px; margin-bottom: 8px; }
.hint { color: var(--dim); font-size: 14px; margin-bottom: 12px; }
.err { color: var(--bad); min-height: 22px; font-size: 14px; margin-top: 8px; }
.foot { color: var(--dim); font-size: 12px; text-align: center; margin-top: 28px; }
.or { text-align: center; color: var(--dim); margin: 14px 0; font-size: 14px; }

.card {
  background: var(--bg2); border: 1px solid #ffffff14; border-radius: 16px;
  padding: 20px; margin: 12px 0;
}

label { display: block; color: var(--dim); font-size: 14px; margin-bottom: 6px; }

input, textarea {
  width: 100%; background: #11112a; color: var(--ink);
  border: 1px solid #ffffff22; border-radius: 12px;
  padding: 14px; font: inherit; margin-bottom: 14px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { resize: vertical; min-height: 140px; }

#in-code {
  text-transform: uppercase; font-size: 28px; letter-spacing: 8px;
  text-align: center; font-family: Georgia, serif; width: 45%;
}

.row { display: flex; gap: 10px; align-items: center; }
.row.spread { justify-content: space-between; }
.row input { margin-bottom: 0; flex: 0 0 45%; }
.row button { flex: 1; }

button {
  font: inherit; color: var(--ink); background: #26265a;
  border: 1px solid #ffffff22; border-radius: 12px;
  padding: 14px 18px; cursor: pointer;
}
button:active { transform: scale(.98); }
button.big { width: 100%; padding: 16px; font-size: 18px; margin-top: 6px; }
button.primary {
  background: linear-gradient(180deg, var(--accent), #6c5ce0);
  border: none; font-weight: 600;
}
.hidden { display: none !important; }

.code {
  font-family: Georgia, serif; font-size: clamp(56px, 18vw, 96px);
  text-align: center; letter-spacing: 12px; color: var(--accent2);
  margin: 4px 0 8px; text-shadow: 0 0 24px #8b7cf655;
}

.roster { list-style: none; margin: 12px 0; }
.roster li {
  padding: 12px 16px; border-radius: 12px; margin-bottom: 8px;
  background: var(--bg2); border: 1px solid #ffffff10;
  display: flex; justify-content: space-between; align-items: center;
}
.roster.mini li { padding: 8px 14px; font-size: 14px; }
.roster .nm { font-weight: 600; }
.roster .st { color: var(--dim); font-size: 13px; }
.roster li.host::after { content: "host"; color: var(--gold); font-size: 12px; margin-left: 8px; }
.roster li.done .st { color: var(--good); }
.roster li.you { border-color: var(--accent); }

/* match table */
#match-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.cards { display: flex; flex-direction: column; gap: 10px; }
.rep {
  background: var(--bg2); border: 1px solid #ffffff14; border-radius: 14px;
  padding: 12px; font-size: 14px; line-height: 1.45; cursor: pointer;
  max-height: 132px; overflow: hidden; position: relative;
  transition: border-color .15s, transform .15s;
}
.rep::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 34px;
  background: linear-gradient(180deg, transparent, var(--bg2));
}
.rep .rn { font-family: Georgia, serif; color: var(--accent2); margin-bottom: 4px; }
.rep.sel { border-color: var(--accent); transform: scale(1.02); box-shadow: 0 0 0 2px #8b7cf655; }

.slots { display: flex; flex-direction: column; gap: 10px; }
.slot {
  background: #11112a; border: 1px dashed #ffffff2a; border-radius: 14px;
  padding: 10px 12px; min-height: 66px; cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.slot .nm { font-weight: 600; }
.slot .as { color: var(--accent2); font-family: Georgia, serif; font-size: 20px; margin-top: 2px; }
.slot.filled { border-style: solid; border-color: var(--accent); background: #1a1a3d; }
.slot.hot { border-color: var(--gold); box-shadow: 0 0 0 2px #ffd98a44; }

.confchip {
  display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 99px;
  font-size: 12px; background: #26265a; color: var(--ink);
}
.confchip.c2 { background: #45408a; }
.confchip.c3 { background: var(--accent); font-weight: 600; }

/* reveal */
.card.dream { font-family: Georgia, serif; font-size: 17px; line-height: 1.6; }
#reveal-author { text-align: center; font-size: 18px; }
#reveal-author b { color: var(--gold); font-size: 22px; }
.results { list-style: none; margin: 14px 0; }
.results li {
  display: flex; justify-content: space-between; padding: 10px 14px;
  border-radius: 10px; background: var(--bg2); margin-bottom: 6px; font-size: 15px;
}
.results .d { font-weight: 700; }
.results .d.pos { color: var(--good); }
.results .d.neg { color: var(--bad); }
.results li.own { border: 1px solid #ffffff22; }

.progress { display: flex; gap: 6px; justify-content: center; margin: 10px 0 14px; }
.progress i { width: 22px; height: 5px; border-radius: 3px; background: #ffffff22; }
.progress i.on { background: var(--accent); }
.progress i.done { background: var(--good); }

/* final */
.scores { list-style: none; margin: 16px 0; }
.scores li {
  display: flex; align-items: baseline; gap: 12px; padding: 14px 16px;
  background: var(--bg2); border-radius: 14px; margin-bottom: 10px;
}
.scores .rank { font-family: Georgia, serif; font-size: 24px; color: var(--dim); width: 30px; }
.scores li:first-child { border-color: var(--gold); }
.scores li:first-child .rank { color: var(--gold); }
.scores .who { flex: 1; font-weight: 600; }
.scores .pts { font-family: Georgia, serif; font-size: 24px; }
.scores .meta { color: var(--dim); font-size: 13px; }
.chance { text-align: center; color: var(--dim); font-size: 14px; margin: 8px 0 16px; }
.chance b { color: var(--ink); }
