body { overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; }

.screen {
  position: fixed;
  inset: 0;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  overflow-y: auto;
  background: var(--bg);
}
.center { display: grid; place-content: center; text-align: center; }
.stack { display: grid; gap: 14px; width: min(calc(100vw - 40px), 380px); justify-items: center; }
.stack .field, .stack .btn { width: 100%; }
.code-field { text-transform: uppercase; letter-spacing: .15em; text-align: center; }

h1 { font-size: clamp(1.5rem, 7vw, 2rem); overflow-wrap: anywhere; }
.sub { color: var(--muted); }
.big { font-size: clamp(1.8rem, 9vw, 2.6rem); font-weight: 700; }
.huge { font-size: clamp(3.5rem, 22vw, 6rem); font-weight: 700; line-height: 1; color: var(--brand); }
.pulse { color: var(--muted); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }

.conn {
  position: fixed; z-index: 10; top: 0; left: 0; right: 0;
  padding: 8px 12px; background: var(--bad); color: #fff;
  text-align: center; font-size: .9rem; font-weight: 600;
}

.question { display: flex; flex-direction: column; gap: 8px; padding: 0; }
.timebar { height: 6px; background: var(--line); flex: none; }
.timebar i { display: block; height: 100%; background: var(--brand); transform-origin: left; }
.qn b { margin-left: .6em; color: var(--text); font-variant-numeric: tabular-nums; }
.qn { text-align: center; color: var(--muted); font-size: .95rem; flex: none; padding-top: env(safe-area-inset-top); }

.q-body { flex: none; max-height: 42vh; overflow-y: auto; padding: 4px 14px 8px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.q-text { font-size: clamp(1.05rem, 4.4vw, 1.45rem); font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.q-img { max-width: 100%; max-height: 22vh; object-fit: contain; border-radius: 8px; }

.opts {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 8px;
  padding: 0 8px max(8px, env(safe-area-inset-bottom));
  min-height: 0;
}
.opts.n2 { grid-template-columns: 1fr; }
.opts.odd > :last-child { grid-column: 1 / -1; }
.opts.many { gap: 6px; }
.opts.many .opt { gap: 4px; padding: 4px; }
.opts.many .opt .shape { font-size: clamp(1.8rem, 9vw, 2.6rem); }
.opts.many .opt span { font-size: .85rem; }

.opt {
  border: 0;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  min-height: 0;
  overflow: hidden;
  cursor: pointer;
}
.opt:active { filter: brightness(.9); }
.opt .shape { font-size: clamp(2.6rem, 16vw, 4.5rem); }
.opt span { font-size: .95rem; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }

@media (orientation: landscape) and (max-height: 500px) {
  .opt { flex-direction: row; justify-content: flex-start; padding: 8px 16px; }
  .opt .shape { font-size: 2.2rem; }
  .opt span { font-size: 1rem; }
}

#s-result .rename { background: rgba(255, 255, 255, .95); }

.wait-shape { width: 96px; height: 96px; border-radius: 18px; display: grid; place-items: center; font-size: 3.4rem; }

.correct { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 14px; border-radius: 10px; }
.correct .shape { font-size: 1.6rem; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 8px; }
.stats dt { color: var(--muted); font-size: .85rem; }
.stats dd { font-size: 1.4rem; font-weight: 700; }

#s-result.ok { background: var(--ok); color: #fff; }
#s-result.no { background: var(--bad); color: #fff; }
#s-result.ok .stats div, #s-result.no .stats div { background: rgba(255, 255, 255, .16); border-color: transparent; }
#s-result.ok .stats dt, #s-result.no .stats dt { color: rgba(255, 255, 255, .85); }
#s-result .correct { background: rgba(255, 255, 255, .95); color: var(--text); }
#s-result .correct .shape { color: inherit; }
