html { color-scheme: dark; }
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background: #09090b;
  color: #fafafa;
  font: 17px/1.45 "Avenir Next", Avenir, "Segoe UI", "Helvetica Neue", sans-serif;
  overflow-wrap: break-word;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
.stage {
  height: 100%;
  height: 100dvh;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(120% 80% at 8% 0%, rgba(244, 244, 245, 0.16), transparent 42%),
    radial-gradient(90% 70% at 100% 100%, rgba(63, 63, 70, 0.55), transparent 48%),
    #09090b;
}
.phone {
  width: 100%;
  max-width: 42rem;
  height: 100%;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #09090b;
}
.zone-mast {
  flex: none;
  padding: calc(0.95rem + env(safe-area-inset-top)) calc(1.15rem + env(safe-area-inset-right)) 0.8rem calc(1.15rem + env(safe-area-inset-left));
}
.zone-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0 calc(1rem + env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
}
h1 {
  margin: 0;
  font-size: 2.35rem;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.95;
}
.zone-mast { display: flex; align-items: flex-end; justify-content: space-between; gap: 0.75rem; }
.lang { display: flex; align-items: center; gap: 0.3rem; flex: none; direction: ltr; }
.lang button {
  width: auto;
  min-height: 28px;
  margin: 0;
  padding: 0.12rem 0.5rem;
  font-size: 0.82rem;
  line-height: 1.2;
}
.lang button[aria-pressed="true"] { border-color: rgba(255, 255, 255, 0.72); font-weight: 700; }
.he { display: none; }
html[lang="he"] { direction: rtl; text-align: right; }
html[lang="he"] .en { display: none; }
html[lang="he"] .he { display: inline; }
.zone-play .q {
  position: relative;
  padding-block: 1rem 1.05rem;
  padding-inline: 1.05rem 2.7rem;
}
.zone-play .q > p:first-of-type {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.25;
  padding-inline-end: 0;
}
.zone-play .q-worth {
  position: absolute;
  top: 0.85rem;
  inset-inline-end: 0.85rem;
  z-index: 1;
  box-sizing: border-box;
  min-width: 1.7rem;
  height: 1.7rem;
  padding: 0 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.45);
  color: #fafafa;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  pointer-events: none;
}
form p, .q { margin: 0 0 0.9rem; }
#play { display: flex; flex-direction: column; gap: 0.85rem; }
#play .q { margin: 0; }
#board { margin: 0 0 0.9rem; }
header.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 0 0.9rem;
  padding: 0.9rem 1rem;
}
header.bar p, .q p { margin: 0 0 0.4rem; }
header.bar p:last-child, .q p:last-child { margin-bottom: 0; }
.bar-team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin: 0 0 0.4rem;
}
.bar-team > p {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.key-wrap { white-space: nowrap; }
.leave-form { margin: 0; flex: none; }
button.leave {
  width: auto;
  min-height: 36px;
  margin: 0;
  padding: 0.35rem 0.7rem;
  font: inherit;
  font-size: 0.88rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #e4e4e7;
}
label, .meta {
  display: block;
  color: #e4e4e7;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
label { margin-bottom: 0.4rem; }
.hint {
  display: block;
  color: #a1a1aa;
  font-size: 0.84rem;
  letter-spacing: 0.01em;
}
p.hint, span.hint { margin-top: 0.4rem; }
input, select {
  font: inherit;
  width: 100%;
  min-width: 0;
  padding: 0.75rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.35);
  color: #fafafa;
  touch-action: manipulation;
}
input:-webkit-autofill {
  -webkit-text-fill-color: #fafafa;
  caret-color: #fafafa;
  transition: background-color 9999s ease-out;
}
button {
  font: inherit;
  min-height: 44px;
  margin-top: 0.45rem;
  padding: 0.6rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: #fafafa;
  touch-action: manipulation;
  transition: transform 0.12s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
button:active:not(:disabled) { transform: scale(0.96); }
form > button { width: 100%; }
button.quiet {
  width: auto;
  margin-top: 0.35rem;
  padding: 0.35rem 0;
  min-height: 44px;
  background: transparent;
  border-color: transparent;
  color: #d4d4d8;
}
.answer, .tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.answer { margin: 0.7rem 0 0; }
.answer input { flex: 1 1 8rem; }
.answer button, .tools button, .row button { width: auto; margin-top: 0; flex: none; }
.tools { margin: 0.45rem 0 0.2rem; }
.tools .answer { flex: 1 1 12rem; margin: 0; min-width: 0; }
.tools form { margin: 0; }
.team {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.q, header.bar {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 12px 32px rgba(0, 0, 0, 0.28);
}
.q { padding: 1rem 1.05rem 1.05rem; }
.mark {
  display: inline-block;
  vertical-align: -0.08em;
  box-sizing: border-box;
  margin-inline-end: 0.12rem;
  font-weight: 700;
  line-height: 1;
}
.mark.open {
  width: 0.72rem;
  height: 0.72rem;
  border: 2px solid #a1a1aa;
  border-radius: 50%;
  background: transparent;
  color: transparent;
  font-size: 0;
  vertical-align: 0.05em;
}
.mark.fail { color: #f87171; font-size: 1.05rem; }
.mark.done { color: #4ade80; font-size: 1.05rem; }
.q.is-checking .mark.open {
  border-color: rgba(255, 255, 255, 0.25);
  border-top-color: #fafafa;
  animation: spin 0.7s linear infinite;
}
.q-note { margin-top: 0.55rem; }
.you { font-weight: 700; }
.key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.team-attempts {
  margin: 0;
  border: 0;
  background: transparent;
}
.team-summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1.7rem 1.1rem minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.48rem 0.1rem;
  user-select: none;
}
.team-summary::-webkit-details-marker { display: none; }
.attempt-caret {
  display: inline-grid;
  place-items: center;
  color: #a1a1aa;
  font-size: 0.8rem;
  line-height: 1;
}
.attempt-caret::before { content: "▸"; }
.team-attempts[open] > .team-summary .attempt-caret::before { content: "▾"; }
.team-summary .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attempt-list {
  margin: 0.15rem 0 0.35rem;
  padding: 0.45rem 0.55rem 0.55rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.18);
}
.attempt-list .hint { margin-top: 0.35rem; }
.attempt-list .hint:first-child { margin-top: 0; }
.clock {
  margin: 0.55rem 0 0;
  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.progress {
  container-type: inline-size;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.progress-fill {
  display: block;
  height: 100%;
  width: calc(var(--pct) * 1%);
  background: linear-gradient(90deg, #ef4444 0%, #f59e0b 46%, #4ade80 100%);
  background-repeat: no-repeat;
  background-size: 100cqi 100%;
  transition: width 0.45s ease;
}
.progress-label { margin: 0.45rem 0 0; }
.ranks {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}
.rank {
  display: grid;
  grid-template-columns: 1.7rem minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.48rem 0.1rem;
}
.rank + .rank { border-top: 1px solid rgba(255, 255, 255, 0.08); }
.rank.you {
  margin: 0.2rem -0.35rem;
  padding: 0.55rem 0.45rem;
  border-top: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.rank.head { padding-bottom: 0.2rem; }
.place, .rank.head span {
  color: #a1a1aa;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.02em;
}
.pts {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.error { color: #fecaca; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 0.9rem; }
.row form { margin: 0; }
button.warn {
  background: transparent;
  color: #fecaca;
  border-color: rgba(254, 202, 202, 0.45);
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}
button:disabled, input:disabled { opacity: 0.5; }
.pending { display: flex; align-items: center; gap: 0.5rem; }
.pending::before {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  flex: none;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fafafa;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
form[data-sending="1"] { animation: pulse 1.15s ease-in-out infinite; }
.q:has(.mark.done) {
  border-color: rgba(134, 239, 172, 0.8);
  box-shadow: 0 0 0 1px rgba(134, 239, 172, 0.35), 0 0 28px rgba(74, 222, 128, 0.28);
}
.q:has(.error), .zone-content > .error { animation: shake 0.42s ease; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@media (min-width: 840px) {
  .stage { align-items: center; padding: 1.5rem; }
  .phone {
    width: 400px;
    height: min(844px, calc(100dvh - 3rem));
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(24, 24, 27, 0.62);
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.05),
      0 0 48px rgba(255, 255, 255, 0.06),
      0 30px 80px rgba(0, 0, 0, 0.55);
  }
}
