/* Family Fictionary: index-card theme, mobile first. */
:root {
  --bg: #f7f1e3;          /* light cream page */
  --card: #fffdf6;        /* index card */
  --ink: #2b2a26;
  --muted: #6f6a5e;
  --rule: #c9dbe9;        /* faint blue ruled lines */
  --margin: #e3a8a0;      /* red margin line */
  --reader: #b23a2e;      /* "red pencil" marks the Reader everywhere */
  --accent: #2f5d62;      /* deep teal buttons */
  --accent-ink: #fff;
  --ok: #3c6e3c;
  --line: #e4dccb;
  --radius: 6px;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 var(--sans);
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: normal; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
.small { font-size: .85rem; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
.offscreen { position: fixed; left: -9999px; top: 0; }

.site-head { padding: .75rem 1rem; text-align: center; }
.brand { font-family: var(--serif); font-size: 1.3rem; color: var(--ink); text-decoration: none; letter-spacing: .02em; }
.brand::before { content: "✎ "; color: var(--reader); }
.wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 .75rem 2rem; flex: 1; }
.site-foot { text-align: center; padding: 1.25rem 1rem 2rem; font-size: .9rem; color: var(--muted); border-top: 1px solid var(--line); }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(60, 50, 30, .08), 0 3px 10px rgba(60, 50, 30, .05);
  padding: 1rem 1.1rem; margin: 0 0 .9rem;
}
.card > :last-child { margin-bottom: 0; }
/* The classic ruled index card */
.index-card {
  background-color: var(--card);
  background-image:
    linear-gradient(to bottom, transparent 2.6rem, var(--margin) 2.6rem, var(--margin) calc(2.6rem + 2px), transparent calc(2.6rem + 2px)),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.6rem - 1px), var(--rule) calc(1.6rem - 1px), var(--rule) 1.6rem);
  background-position: 0 0, 0 2.6rem;
  background-repeat: no-repeat, repeat;
  padding-top: .7rem;
}
.word { font-family: var(--serif); font-size: 2rem; text-align: center; margin: .9rem 0 .5rem; word-break: break-word; }
.hero { text-align: center; }
.hero h1 { font-size: 2rem; }
.lede { font-size: 1.05rem; color: var(--muted); }

/* Forms */
.stack { display: flex; flex-direction: column; gap: .5rem; }
label { font-weight: 600; font-size: .95rem; }
label.choice { display: flex; gap: .5rem; align-items: flex-start; font-weight: normal; }
label.choice input { margin-top: .3rem; }
label select { display: block; width: 100%; margin-top: .25rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .75rem .75rem; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
legend { font-family: var(--serif); padding: 0 .3rem; }
input[type=text], input:not([type]), input[inputmode], textarea, select {
  font: inherit; color: inherit; background: #fff; width: 100%;
  border: 1px solid #cbbfa6; border-radius: var(--radius); padding: .6rem .7rem;
}
textarea { resize: vertical; min-height: 5rem; font-family: var(--serif); font-size: 1.05rem; }
input:focus, textarea:focus, select:focus, .btn:focus-visible, .selectable:focus-visible { outline: 3px solid rgba(47, 93, 98, .35); outline-offset: 1px; }
.pin { max-width: 8rem; letter-spacing: .5em; font-size: 1.3rem; text-align: center; }
.key-input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.4rem; letter-spacing: .1em; text-transform: lowercase; }

/* Buttons */
.btn {
  display: inline-block; font: inherit; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer;
  background: #efe7d4; color: var(--ink); border: 1px solid #d3c7ac; border-radius: var(--radius);
  padding: .6rem 1rem; min-height: 44px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.big { width: 100%; padding: .85rem 1rem; font-size: 1.05rem; }
.btn.ghost { background: transparent; }
.btn.small { padding: .3rem .6rem; min-height: 34px; font-size: .85rem; }
.btn.danger { color: var(--reader); }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; text-align: left; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.error { color: #8f1d14; background: #fbe9e6; border: 1px solid #efc2bb; border-radius: var(--radius); padding: .5rem .75rem; }
.flash { color: var(--ok); background: #eaf3e6; border: 1px solid #c7dcc0; border-radius: var(--radius); padding: .5rem .75rem; }
.alert { border-color: var(--reader); }
.net-banner { position: sticky; top: 0; z-index: 5; margin: 0; padding: .4rem; text-align: center; background: #8f1d14; color: #fff; font-size: .9rem; }

/* Game */
.game-head h1 { margin-bottom: .15rem; }
.game-head p { margin: 0; }
.game-key { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 2.1rem; letter-spacing: .12em; text-align: center; margin: .25rem 0; }
.link-line { word-break: break-all; background: #f6f0e1; border-radius: var(--radius); padding: .4rem .6rem; }
.reader-tag {
  display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--reader); border: 1.5px solid var(--reader); border-radius: 3px; padding: 0 .3rem; vertical-align: middle;
  transform: rotate(-3deg);
}
.is-reader td:first-child, li.is-reader > span:first-child { color: var(--reader); font-weight: 600; }
.reader-cell { color: var(--reader); font-weight: 700; background: rgba(178, 58, 46, .07); }
.dnf { color: var(--reader); font-weight: 700; letter-spacing: .05em; }
.removed td { color: var(--muted); text-decoration: line-through; }
.removed td.num { text-decoration: none; }
.badge { display: inline-block; font-size: .72rem; background: var(--reader); color: #fff; border-radius: 3px; padding: .05rem .35rem; }
.badge.soft { background: #d9cdb2; color: var(--ink); }
ul.plain, ul.players, ul.status-list, ul.game-list { list-style: none; padding: 0; margin: 0; }
ul.players li, ul.plain li { padding: .4rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
ul.players li:last-child { border-bottom: 0; }
.host-tools { flex-wrap: wrap; justify-content: flex-end; }
ul.game-list li a { display: flex; flex-direction: column; padding: .6rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
ul.game-list li:last-child a { border-bottom: 0; }
.settings { padding-left: 1.1rem; margin: 0; }
.status-list li { display: flex; justify-content: space-between; padding: .2rem 0; border-bottom: 1px dotted var(--line); }
.status-list li.done span:first-child::before { content: "✓ "; color: var(--ok); }
.status-list li.waiting span:first-child::before { content: "… "; color: var(--muted); }
.countdown { font-family: var(--serif); text-align: center; font-size: 1.1rem; margin: .5rem 0; }
.countdown .cd-value { font-variant-numeric: tabular-nums; }
.countdown.urgent .cd-value { color: var(--reader); }
.nudge { display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; }
.nudge.prominent { align-items: stretch; margin: 0 0 .9rem; }
.hint { font-size: .8rem; color: var(--reader); font-style: italic; }

/* Definitions */
ol.defs { list-style: none; padding: 0; margin: 0 0 .75rem; display: flex; flex-direction: column; gap: .6rem; }
.def { position: relative; display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .75rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
ol.defs:not(.voting):not(.results) .def { flex-direction: column; gap: .2rem; }
.def-text { font-family: var(--serif); font-size: 1.08rem; margin: 0; flex: 1; white-space: pre-wrap; }
.def-num { font-family: var(--serif); font-weight: bold; color: var(--accent); min-width: 1.4rem; font-size: 1.1rem; }
.def-body { flex: 1; }
.def-body p { margin: 0 0 .25rem; }
.def.dictionary { border-color: var(--ok); background: #f3f8f0; }
.dict-tag { color: var(--ok); }
.selectable { cursor: pointer; }
.selectable:hover { border-color: var(--accent); }
.def.chosen { border: 2px solid var(--accent); background: #eef5f5; }
.def.voted::after { content: "✓ your vote"; position: absolute; right: .5rem; bottom: .3rem; font-size: .75rem; color: var(--accent); }
.vote-count { display: flex; flex-direction: column; align-items: center; min-width: 3.2rem; background: #f3ecdb; border: 1px solid #d3c7ac; border-radius: var(--radius); padding: .25rem .4rem; cursor: pointer; font: inherit; color: inherit; }
.vote-count strong { font-size: 1.3rem; line-height: 1.1; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .45rem .4rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-family: var(--serif); font-weight: normal; color: var(--muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot th { color: var(--ink); font-weight: bold; border-top: 2px solid var(--line); border-bottom: 0; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.log th.num { max-width: 5.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Who are you */
.who-list { display: flex; flex-direction: column; gap: .4rem; }
.who-name { font: inherit; font-family: var(--serif); font-size: 1.15rem; text-align: left; padding: .6rem .8rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; color: inherit; }
.who-name.selected { border-color: var(--accent); background: #eef5f5; }
.who-form { padding: .5rem .25rem .75rem; }

details.personal summary { cursor: pointer; font-family: var(--serif); }
details.personal[open] summary { margin-bottom: .5rem; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(40, 32, 20, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; padding: .75rem; }
.modal-card { width: 100%; max-width: 520px; margin: 0; }
.share-text { margin: .5rem 0; font-family: var(--sans); font-size: .95rem; }

/* Rules */
ol.steps { padding-left: 1.2rem; }
ol.steps h3 { margin-top: .75rem; }

@media (min-width: 600px) {
  body { font-size: 18px; }
  .wrap { padding-top: .5rem; }
  .modal { align-items: center; }
  .btn.big { width: auto; min-width: 14rem; }
  .nudge.prominent .btn.big { width: 100%; }
}
