/* Look and colours follow sanuli.fi (Sanuli by Cadiac, MIT). */
:root {
  --present: #c9b458;
  --absent: #3e3e3e;
  --correct: #6aaa64;
  --unknown: #818384;
  --background: #121212;
  --background-transparent: #12121200;
  --text: #d7dadc;
  --white: #ffffff;
  --border: #3a3a3c;
  font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
}
html, body { height: 100%; margin: 0; padding: 0; }
body { overflow: hidden; background-color: var(--background); color: var(--white); }
* { box-sizing: border-box; }
button, input { font-family: inherit; }
.hidden { display: none !important; }

.game { width: 100%; height: 100%; margin: 0 auto; position: relative; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }

header { display: flex; flex-direction: row; align-items: center; justify-content: space-between; flex: none; width: 100%; max-width: 500px; margin: 0 auto; }
.title-icon { padding: 6px 12px 0 12px; min-width: 44px; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: .2rem; text-transform: uppercase; text-align: center; cursor: pointer; user-select: none; }
.title { margin: 6px 0 0; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: .2rem; text-transform: uppercase; text-align: center; }
.title.clock { font-size: 22px; font-variant-numeric: tabular-nums; }
.title.clock.low { color: #e45b5b; }
.label { margin: 6px 0 0; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: .2rem; text-transform: uppercase; text-align: center; }
.label.small { font-size: 12px; margin: 0; text-align: left; }
.sub { color: var(--unknown); font-size: 14px; text-align: center; margin: 6px 0 0; line-height: 1.4; }
.err { color: #e45b5b; font-weight: 700; font-size: 13px; letter-spacing: .1rem; text-transform: uppercase; text-align: center; min-height: 1.2em; margin: 4px 0 0; }
.hint { color: var(--text); font-size: 12px; font-weight: 700; letter-spacing: .15rem; text-transform: uppercase; text-align: center; min-height: 1.2em; margin: 8px 0 0; }

/* ---------- landing / lobby pages ---------- */
.page { flex: 1; overflow-y: auto; width: 100%; max-width: 500px; margin: 0 auto; padding: 16px 20px; display: flex; flex-direction: column; align-items: stretch; justify-content: center; }
.page.center { align-items: center; gap: 10px; }
.logo { display: flex; justify-content: center; gap: 5px; margin-bottom: 6px; }
.logo .tile { width: 52px; height: 52px; flex: none; font-size: 2rem; }
.form { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.field { height: 50px; background: var(--background); border: 2px solid var(--border); color: var(--white); font-size: 18px; font-weight: 700; padding: 0 14px; outline: none; border-radius: 0; width: 100%; min-width: 0; }
.field:focus { border-color: var(--unknown); }
.code-in { text-transform: uppercase; letter-spacing: .4rem; text-align: center; }
.join-row { display: flex; gap: 6px; }
.join-row .field { flex: 1.4; }
.join-row .select { flex: 1; margin: 0; }

.select {
  height: 50px; min-width: 80px; background-color: var(--background); border: 2px solid var(--unknown); border-radius: 6px;
  color: var(--white); cursor: pointer; user-select: none; font-weight: bold; padding: .5em .5em; margin: 0;
  text-transform: uppercase; font-size: 14px; letter-spacing: .05rem;
}
.select:hover { background-color: #1c1c1c; }
.select-active { background-color: var(--absent); border: 2px solid var(--correct); }
.select-go { background-color: var(--correct); border-color: var(--correct); }
.select-go:hover { background-color: #79b873; }
.select.small { height: 34px; min-width: 0; padding: 0 12px; font-size: 12px; }
.select.narrow { width: 200px; }
.select.big { height: 56px; font-size: 18px; letter-spacing: .2rem; }
.select:disabled { opacity: .45; cursor: default; }
.select-go.waiting { background: var(--absent); border-color: var(--correct); }
.credit { font-size: 11px; color: var(--unknown); text-align: center; padding: 6px 14px 10px; line-height: 1.4; flex: none; }
.credit a, .link { color: var(--text); }

.dots { display: flex; gap: 5px; margin-bottom: 6px; }
.dots span { width: 34px; height: 34px; border: 2px solid var(--border); }
.dots span:nth-child(1) { animation: dot 1.5s infinite; } .dots span:nth-child(2) { animation: dot 1.5s .15s infinite; }
.dots span:nth-child(3) { animation: dot 1.5s .3s infinite; } .dots span:nth-child(4) { animation: dot 1.5s .45s infinite; }
.dots span:nth-child(5) { animation: dot 1.5s .6s infinite; }
@keyframes dot { 0%, 60%, 100% { background: transparent; border-color: var(--border); } 30% { background: var(--correct); border-color: var(--correct); } }

/* lobby */
.page.lobby { justify-content: flex-start; gap: 18px; padding-top: 22px; max-width: 560px; }
.room { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.room .label.small { text-align: center; }
.code-tiles { display: flex; gap: 6px; }
.code-tiles .tile { width: 58px; height: 58px; flex: none; font-size: 2.1rem; background: var(--correct); border: none; }
.link-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.link-text { color: var(--unknown); font-size: 13px; margin-right: 4px; user-select: all; }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 10px; }
.vs { align-self: center; color: var(--unknown); font-weight: 700; letter-spacing: .2rem; }
.pcard { border: 2px solid var(--border); padding: 12px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.pcard.you { border-color: var(--unknown); }
.pcard.ready { border-color: var(--correct); }
.pcard .pn { font-size: 18px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .tag { font-size: 11px; font-weight: 700; letter-spacing: .15rem; text-transform: uppercase; color: var(--unknown); }
.pcard .st { font-size: 12px; font-weight: 700; letter-spacing: .15rem; text-transform: uppercase; padding: 3px 8px; background: var(--absent); }
.pcard .st.ok { background: var(--correct); }
.pcard.empty { border-style: dashed; color: var(--unknown); justify-content: center; }
.pcard.empty .pn { font-size: 14px; color: var(--unknown); font-weight: 700; letter-spacing: .1rem; white-space: normal; text-align: center; }
.pcard.empty .tag { text-align: center; }
.lobby-settings { border: 2px solid var(--border); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.opt-title { font-size: 12px; font-weight: 700; letter-spacing: .2rem; text-transform: uppercase; color: var(--text); margin-top: 8px; }
.opt-title:first-child { margin-top: 0; }
.select-container { display: flex; flex-wrap: wrap; margin: 2px -3px 0; }
.select-container .select { flex-grow: 1; margin: 3px; height: 42px; min-width: 56px; font-size: 13px; }
.select-container input.field { flex: 1 1 80px; margin: 3px; height: 42px; font-size: 15px; }
.rule-text { color: var(--unknown); font-size: 13px; line-height: 1.4; margin: 10px 0 0; }
.readonly .select { cursor: default; }
.readonly .select:not(.select-active) { opacity: .4; }

/* ---------- game ---------- */
.banner { margin: 4px auto 0; padding: 5px 12px; background: #7a2a2a; color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .1rem; text-transform: uppercase; text-align: center; flex: none; max-width: 500px; }
.boards { flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: center; gap: var(--bgap, 36px); position: relative; padding: 0 8px; }
.bcol { display: flex; flex-direction: column; align-items: stretch; flex: none; position: relative; }
.blabel { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 var(--pad, 10px); height: 30px; }
.blabel .who { font-weight: 700; font-size: 13px; letter-spacing: .15rem; text-transform: uppercase; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.blabel .pts { font-weight: 700; font-size: 24px; color: var(--white); font-variant-numeric: tabular-nums; }
.mine .blabel .who b { color: var(--correct); }
.theirs { opacity: .55; }
.theirs .blabel .who, .theirs .blabel .pts { color: var(--unknown); }
.theirs.flash { opacity: .85; }
.opp-note { position: absolute; left: 0; right: 0; bottom: -22px; text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .15rem; text-transform: uppercase; color: var(--text); }

.board-6 { display: grid; grid-template-rows: repeat(6, 1fr); width: 350px; height: 420px; gap: var(--gap, 5px); padding: var(--pad, 10px); }
.row-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--gap, 5px); }
.tile {
  width: 100%; display: inline-flex; justify-content: center; align-items: center; font-size: var(--fs, 2rem); line-height: 1;
  font-weight: bold; vertical-align: middle; background-color: var(--background); color: var(--white); text-transform: uppercase;
  border: 2px solid var(--border); user-select: none; -webkit-user-select: none;
}
.present { background-color: var(--present); border: none; }
.absent { background-color: var(--absent); border: none; }
.correct { background-color: var(--correct); border: none; }
.current { background-color: var(--unknown); border: none; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 110px; font-weight: 700; color: var(--white); background: rgba(18, 18, 18, .6); z-index: 4; }

.keyboard { z-index: 2; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative;
  width: calc(100% - 18px); max-width: 500px; margin: 0 auto 6px; padding-left: 6px; flex: none; }
#kb { width: 100%; }
.keyboard-row { display: flex; width: 100%; justify-content: center; margin-bottom: 6px; user-select: none; -webkit-user-select: none; }
.spacer { flex: .4; }
.keyboard-button {
  display: flex; justify-content: center; align-items: center; flex: 1; height: 50px; background-color: var(--unknown); border: none;
  border-radius: 6px; color: var(--white); touch-action: none; cursor: pointer; user-select: none; -webkit-user-select: none;
  font-weight: bold; padding: .5em .5em; margin-right: 6px; text-transform: uppercase; font-size: 13px;
}
.keyboard-button-submit { flex: 4; }
.keyboard-button-backspace { flex: 1.5; }
.message {
  color: var(--text); text-shadow: 2px 2px 10px #000; background: linear-gradient(180deg, var(--background-transparent), var(--background));
  position: absolute; top: -39px; height: 39px; width: 100%; font-weight: 700; font-size: 14px; letter-spacing: .2rem;
  text-transform: uppercase; text-align: center; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: .5em; pointer-events: none;
}
.message b { color: var(--correct); }

/* ---------- modal (sanuli style) ---------- */
.modal {
  position: absolute; left: 50%; transform: translate(-50%, 0); width: 80%; max-width: 390px; z-index: 10; color: var(--white);
  font-size: 16px; max-height: 80%; overflow-y: auto; padding: 20px; margin-top: 48px; border: solid 2px var(--absent); background-color: var(--background);
}
.modal-close { position: absolute; top: 0; right: 0; padding: 12px; margin: 0; border: none; background: none; cursor: pointer; font-size: 16px; line-height: 1; color: var(--text); }
.modal p, .modal li { line-height: 1.45; }
.modal .example { display: flex; gap: 4px; height: 40px; max-width: 220px; margin: 6px 0; }
.modal .example .tile { width: 40px; height: 40px; font-size: 1.4rem; }
.end-title { font-size: 26px; font-weight: 700; letter-spacing: .2rem; text-transform: uppercase; text-align: center; margin: 4px 0 2px; }
.end-score { font-size: 44px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.end-names { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; letter-spacing: .15rem; text-transform: uppercase; color: var(--unknown); margin: 0 30px; }
.end-word { text-align: center; color: var(--text); font-size: 14px; margin: 12px 0; }
.end-word b { letter-spacing: .2rem; color: var(--correct); }
.end-btns { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.end-btns .select { width: 100%; }
.end-note { text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .1rem; text-transform: uppercase; color: var(--present); min-height: 1em; }

/* lobby on laptops: two columns (room + players | settings + ready) */
.lcol, .rcol { display: flex; flex-direction: column; gap: 18px; }
.rcol { gap: 12px; }
@media (min-width: 900px) {
  .page.lobby { max-width: 980px; flex-direction: row; align-items: flex-start; justify-content: center; gap: 36px; padding-top: 0; margin-top: auto; margin-bottom: auto; flex: 0 1 auto; }
  #s-lobby { justify-content: flex-start; }
  #s-lobby .page.lobby { margin: auto; }
  .lcol, .rcol { flex: 1; min-width: 0; }
  .lcol { padding-top: 12px; }
}
/* key colours (must come after .keyboard-button) */
.keyboard-button.correct { background-color: var(--correct); }
.keyboard-button.present { background-color: var(--present); }
.keyboard-button.absent { background-color: var(--absent); }
/* typed letters show what you already know (sanuli.fi) */
.tile.current.correct { background-color: var(--unknown); border: 5px solid var(--correct); }
.tile.current.present { background-color: var(--unknown); border: 5px solid var(--present); }
.tile.current.absent { background-color: var(--unknown); border: 5px solid var(--absent); }
