/* Operators: a pocket calculator. Light is a warm grey case with a green LCD;
   dark is a black case with amber segments. Light and dark follow the device
   through theme.css, which this only adds to. */

/* hidden must win over any display rule below. */
[hidden] { display: none !important; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.operators {
  --case: #d9d5cc;
  --case-edge: #b4afa3;
  --lcd: #b9c9a4;
  --lcd-ink: #1c2416;
  --key: #f2efe8;
  --key-edge: #bdb8ac;
  --key-ink: #24211c;
  --accent: #c07a2c;
  --missed: #9a3b2f;
  /* Online seats (mg #628): six inks, readable on the page in light and dark. */
  --seat0: #c0621f;
  --seat1: #2a6fb0;
  --seat2: #3c8a3a;
  --seat3: #a23f8f;
  --seat4: #1f8a8a;
  --seat5: #8a6d1c;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 16px 3rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .operators {
    --case: #262421;
    --case-edge: #0e0d0c;
    --lcd: #15130f;
    --lcd-ink: #ffb53d;
    --key: #35322d;
    --key-edge: #141312;
    --key-ink: #ece7dc;
    --accent: #ffb53d;
    --missed: #e0705f;
    --seat0: #ffb53d;
    --seat1: #7fb6ff;
    --seat2: #8fd67f;
    --seat3: #f08fd9;
    --seat4: #5fd6d2;
    --seat5: #e8d36a;
  }
}

:root[data-theme="dark"] .operators {
  --case: #262421;
  --case-edge: #0e0d0c;
  --lcd: #15130f;
  --lcd-ink: #ffb53d;
  --key: #35322d;
  --key-edge: #141312;
  --key-ink: #ece7dc;
  --accent: #ffb53d;
  --missed: #e0705f;
  --seat0: #ffb53d;
  --seat1: #7fb6ff;
  --seat2: #8fd67f;
  --seat3: #f08fd9;
  --seat4: #5fd6d2;
  --seat5: #e8d36a;
}

.masthead { text-align: center; margin: 1.5rem 0 1rem; }
.masthead h1 { margin: 0; letter-spacing: 0.04em; }
.tagline { margin: 0.3rem 0 0; opacity: 0.75; font-size: 0.95rem; }

h2 { text-align: center; font-size: 1.05rem; font-weight: 600; }

/* ---------- picking a difficulty ---------- */

.bands { display: grid; gap: 0.6rem; margin: 1rem 0; }
@media (min-width: 24rem) { .bands { grid-template-columns: repeat(3, 1fr); } }

.band {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.9rem 0.6rem;
  min-height: 44px;
  background: var(--key);
  color: var(--key-ink);
  border: 1px solid var(--key-edge);
  border-radius: 10px;
  box-shadow: 0 2px 0 var(--key-edge);
  cursor: pointer;
  font: inherit;
}
a.band { text-decoration: none; }
.band:hover { border-color: var(--accent); }
.band-name { font-weight: 700; }
.band-note { font-size: 0.82rem; opacity: 0.7; }

.fine { font-size: 0.86rem; opacity: 0.75; line-height: 1.5; }
.bests { font-size: 0.9rem; text-align: center; opacity: 0.85; }

/* ---------- the calculator ---------- */

.lcd {
  background: var(--case);
  border: 1px solid var(--case-edge);
  border-radius: 12px 12px 6px 6px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 35%);
  padding: 0.8rem;
  margin: 1rem 0;
}

.lcd-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  background: var(--lcd);
  color: var(--lcd-ink);
  border-radius: 6px;
  padding: 0.5rem 0.8rem;
  font-variant-numeric: tabular-nums;
}
.lcd-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; opacity: 0.7; }
.lcd-target { font-size: 2.1rem; font-weight: 700; line-height: 1; }
.lcd-progress { margin-left: auto; font-size: 0.85rem; opacity: 0.8; }

.clock { height: 6px; margin-top: 0.5rem; background: var(--case-edge); border-radius: 3px; overflow: hidden; }
.clock-bar { height: 100%; width: 100%; background: var(--accent); transition: width 0.1s linear; }
.clock-bar.low { background: var(--missed); }

/* ---------- the row ---------- */

/* Digits sit well apart, with a drop target between each pair. Nothing in
   the row can move a digit; it only holds operators and brackets. */
.row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.15rem;
  margin: 1.6rem 0 1.4rem;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.digit {
  min-width: 52px;
  min-height: 60px;
  padding: 0 0.2rem;
  font: 700 2rem/1 system-ui, sans-serif;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  background: none;
  color: inherit;
  border: 0;
  border-radius: 8px;
  cursor: default;
}
/* Light touches only: the digits must stay readable under a swipe. */
.row.bracketing .digit {
  cursor: crosshair;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
}
.row.bracketing .digit.swiped {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.gap {
  width: 52px;
  height: 52px;
  flex: none;
  font: 600 1.6rem/1 system-ui, sans-serif;
  font-family: inherit;
  background: none;
  color: var(--key-ink);
  border: 2px dashed var(--key-edge);
  border-radius: 10px;
  cursor: pointer;
  touch-action: none;
}
.gap.filled { border-style: solid; background: var(--key); box-shadow: 0 3px 0 var(--key-edge); }
.gap.over { border-color: var(--accent); border-style: solid; }

.paren {
  min-width: 18px;
  padding: 0;
  font: 400 2.2rem/1 system-ui, sans-serif;
  font-family: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
}

@media (max-width: 26rem) {
  .digit { min-width: 30px; font-size: 1.6rem; }
  .gap { width: 44px; height: 44px; font-size: 1.3rem; }
  .paren { min-width: 12px; font-size: 1.8rem; }
}

/* ---------- the tray and controls ---------- */

.tray { display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.op {
  width: 56px;
  height: 56px;
  font: 600 1.4rem/1 system-ui, sans-serif;
  font-family: inherit;
  background: var(--key);
  color: var(--key-ink);
  border: 1px solid var(--key-edge);
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--key-edge);
  cursor: grab;
  touch-action: none;
}
.op.brackets { width: auto; padding: 0 0.8rem; cursor: pointer; }
.op[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* The operator under the finger while it is dragged. */
.ghost {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0.9;
  cursor: grabbing;
}

.hint { text-align: center; min-height: 1.5em; margin: 0.9rem 0; font-size: 0.95rem; opacity: 0.85; }

.controls, .again { display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.controls button, .again button {
  min-height: 44px;
  padding: 0 1rem;
  font: inherit;
  background: var(--key);
  color: var(--key-ink);
  border: 1px solid var(--key-edge);
  border-radius: 8px;
  cursor: pointer;
}
.controls button:disabled { opacity: 0.4; cursor: default; }
.controls .go, .again .go { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.quiet { opacity: 0.75; }

/* ---------- the end screen ---------- */

.over-score { text-align: center; font-size: 1.05rem; font-weight: 600; margin: 0.8rem 0 1rem; }
.review { list-style: none; padding: 0; margin: 0 0 1.2rem; font-variant-numeric: tabular-nums; }
.review li { border-bottom: 1px solid var(--case-edge); font-size: 0.95rem; }
.review li.missed, .review li.skipped { color: var(--missed); }
/* Equal outer columns put "= 10" in the middle of the screen. */
.review .line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  column-gap: 0.6rem;
  align-items: baseline;
  padding: 0.35rem 0.5rem;
}
.review .expr { text-align: right; }
.review summary { cursor: pointer; list-style: none; }
.review summary::-webkit-details-marker { display: none; }
.review summary .outcome::after { content: ' ▸'; opacity: 0.6; }
.review details[open] summary .outcome::after { content: ' ▾'; }
.review .tries { padding-bottom: 0.3rem; font-size: 0.88rem; opacity: 0.75; }
.review .tries .line { padding-block: 0.1rem; }

/* ---------- saving, and the saved-results list ---------- */

.save-panel { border: 1px solid var(--case-edge); border-radius: 10px; padding: 0.6rem 0.9rem; margin: 0.8rem 0; }
.save-panel p, .save-hint, .save-msg { margin: 0.4rem 0; font-size: 0.92rem; text-align: center; }
.save-panel a, .save-hint a { color: var(--accent); overflow-wrap: anywhere; }
.again a.button {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem;
  background: var(--key); color: var(--key-ink); border: 1px solid var(--key-edge);
  border-radius: 8px; text-decoration: none;
}
.again a.button.go { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.saved-results { list-style: none; padding: 0; }
.saved-results li { padding: 0.5rem 0; border-bottom: 1px solid var(--case-edge); }
.saved-results a { color: var(--accent); font-weight: 600; }
.saved-results .actions { display: inline-flex; gap: 0.4rem; margin-left: 0.4rem; }
.who { text-align: center; margin: 0 0 0.4rem; }
.versus { margin: 0.4rem 0 0; font-size: 0.9rem; opacity: 0.75; text-align: center; }

/* A player's name chip (partials/player_name.tpl.php), as the site's styles.css draws it. */
.Handle {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  margin-left: 0.4em;
  padding: 0.05em 0.45em;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.8em;
  font-weight: normal;
  color: var(--accent);
  background: var(--card-hover);
  border: 1px solid var(--line);
  border-radius: 999px;
  vertical-align: 0.1em;
  white-space: nowrap;
}
.HandleBadge { font-size: 0.85em; }

/* ---------- Operators Online (mg #628) ---------- */

.online-pick { margin-top: 2rem; padding-top: 0.6rem; border-top: 1px solid var(--case-edge); }
.online-pick h3 { font-size: 0.95rem; text-align: center; margin: 1.2rem 0 0.4rem; }
p.online-pick { text-align: center; }
.online-pick a { color: var(--accent); }
.online-chat { display: block; text-align: center; margin: 0.6rem 0; font-size: 0.92rem; }
.again button:disabled { opacity: 0.5; cursor: default; }

.waiting-tables { list-style: none; padding: 0; margin: 0; }
.waiting-tables li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.8rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--case-edge);
}
.waiting-who { flex: 1 1 10rem; min-width: 0; overflow-wrap: anywhere; }
.waiting-band, .waiting-count { font-size: 0.88rem; opacity: 0.8; }
.waiting-tables a.button {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem;
  background: var(--key); color: var(--key-ink); border: 1px solid var(--key-edge);
  border-radius: 8px; text-decoration: none;
}

.online-share { text-align: center; font-size: 0.92rem; }
.online-share a { color: var(--accent); overflow-wrap: anywhere; margin-right: 0.4rem; }
.online-share button {
  min-height: 44px; padding: 0 1rem; font: inherit;
  background: var(--key); color: var(--key-ink); border: 1px solid var(--key-edge); border-radius: 8px; cursor: pointer;
}

/* The seats while waiting, and everyone's progress (the strip, above the
   board and on the online screen). Each row carries its seat's ink in
   --seat-ink. */
.online-seats, .strip { list-style: none; padding: 0; margin: 0.8rem 0; }
.waiting-seat {
  padding: 0.35rem 0.6rem;
  border-left: 4px solid var(--seat-ink);
  margin: 0.3rem 0;
}
.waiting-seat .PlayerName { color: var(--seat-ink); font-weight: 600; }
.waiting-seat.mine, .strip li.mine, .online-seats li.mine { background: color-mix(in srgb, var(--seat-ink) 10%, transparent); }

.strip li, .online-seats li:not(.waiting-seat) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 3.5rem;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.88rem;
}
.strip-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--seat-ink); font-weight: 600; }
.cells { display: inline-flex; gap: 2px; }
.cell {
  width: 0.8rem;
  height: 0.8rem;
  border: 1.5px solid var(--seat-ink);
  border-radius: 2px;
  box-sizing: border-box;
  position: relative;
}
.cell.solved { background: var(--seat-ink); }
.cell.missed { opacity: 0.8; }
.cell.missed::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(45deg, transparent 44%, var(--seat-ink) 44% 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--seat-ink) 44% 56%, transparent 56%);
}
.cell.open { animation: open-cell 1.2s ease-in-out infinite; }
.cell.todo { opacity: 0.25; }
@keyframes open-cell { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .cell.open { animation: none; border-style: dashed; } }
.strip-points { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 26rem) {
  .cell { width: 0.6rem; height: 0.6rem; }
  .strip li, .online-seats li:not(.waiting-seat) { grid-template-columns: minmax(0, 1fr) auto 3rem; gap: 0.3rem; }
}

.countdown {
  text-align: center;
  font-size: 4rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 1rem 0;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.results-wrap { overflow-x: auto; }
.online-results { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.online-results th, .online-results td { padding: 0.4rem 0.4rem; border-bottom: 1px solid var(--case-edge); text-align: left; }
.online-results th { font-size: 0.8rem; font-weight: 600; opacity: 0.75; }
.online-results .num { text-align: right; }
.online-results .total { font-weight: 700; }
.online-results .who { color: var(--seat-ink); font-weight: 600; }
.online-results .place small { opacity: 0.7; }
.online-results tr.mine { background: color-mix(in srgb, var(--seat-ink) 10%, transparent); }
.online-results a { color: var(--accent); }

/* ---------- chat (mg #528), drawn by /js/chat.js; as SOS's, in this file's tokens ---------- */

.chat-box { margin-top: 1.5rem; padding: 0.75rem 0 1rem; border-top: 1px solid var(--case-edge); }
.chat-line { margin: 0; color: var(--muted); }
.chat-head { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.5rem; }
.chat-head button {
  min-height: 36px; padding: 0 0.8rem; font: inherit;
  background: var(--key); color: var(--key-ink); border: 1px solid var(--key-edge); border-radius: 8px; cursor: pointer;
}
.chat-badge { color: var(--accent); }
.chat-people { margin: 0 0 0.5rem; color: var(--muted); }
.chat-log {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0.6rem;
  max-height: 14rem;
  overflow-y: auto;
  border: 1px solid var(--case-edge);
  border-radius: 6px;
}
.chat-log li { margin: 0.15rem 0; overflow-wrap: anywhere; }
.chat-log time { color: var(--muted); font-size: 0.85rem; }
.chat-chip, .chat-more {
  font: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 0.3rem;
}
.chat-chip { text-decoration: underline dotted; }
.chat-more { color: var(--muted); }
.chat-more:hover, .chat-more:focus { color: inherit; }
.chat-act, .chat-notice {
  margin: 0.6rem 0 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--case-edge);
  border-radius: 6px;
}
.chat-act { border-color: var(--accent); }
.chat-act p, .chat-notice p { margin: 0 0 0.4rem; overflow-wrap: anywhere; }
.chat-act input[type="text"] { width: calc(100% - 0.4rem); margin: 0; font-family: inherit; font-size: 1rem; }
.chat-act .again, .chat-notice .again { justify-content: flex-start; margin-top: 0.5rem; }
.chat-say { display: flex; gap: 0.5rem; margin-top: 0.6rem; align-items: stretch; }
.chat-say input { flex: 1; min-width: 0; width: auto; margin: 0; font-family: inherit; font-size: 1rem; padding: 0 0.5rem; }
.chat-say button {
  min-height: 44px; padding: 0 1rem; font: inherit; font-weight: 600;
  background: var(--accent); border: 1px solid var(--accent); color: #fff; border-radius: 8px; cursor: pointer;
}
.chat-box .msg { margin: 0.4rem 0 0; font-size: 0.9rem; color: var(--muted); }
