:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #171717;
  --line: #ececec;
  --line-strong: #d9d9d9;
  --muted: #6a6a6a;
  --muted-soft: #868686;
  --panel: rgba(255, 255, 255, 0.94);
  --hover: rgba(22, 22, 22, 0.06);
  --selection: rgba(22, 22, 22, 0.76);
  --success: #0f8a5f;
  --error: #c3423f;
  --shadow: 0 18px 40px rgba(17, 17, 17, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
}

button,
input,
label,
a {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  block-size: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 10px 16px;
  border-bottom: 1px solid #f1f1f1;
  background: rgba(255, 255, 255, 0.96);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-header h1 {
  margin: 0;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.paint-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.paint-control span,
#zoom-readout,
.challenge-label,
.challenge-kicker {
  font-size: 0.74rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.paint-control input[type="color"] {
  inline-size: 36px;
  block-size: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff;
  cursor: pointer;
}

.paint-control input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 3px;
}

.paint-control input[type="color"]::-webkit-color-swatch,
.paint-control input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 999px;
}

.header-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  background: #ffffff;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

.header-link:hover {
  background: #fafafa;
  transform: translateY(-1px);
}

.zoom-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.zoom-control input {
  inline-size: 150px;
  min-height: 36px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  accent-color: #1b1b1b;
}

.zoom-control input::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d9d9d9, #bdbdbd);
}

.zoom-control input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #171717;
  box-shadow: 0 4px 12px rgba(23, 23, 23, 0.16);
}

.zoom-control input::-moz-range-track {
  height: 6px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(90deg, #d9d9d9, #bdbdbd);
}

.zoom-control input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #171717;
  box-shadow: 0 4px 12px rgba(23, 23, 23, 0.16);
}

#zoom-readout {
  min-inline-size: 48px;
  text-align: end;
}

.zoom-button {
  inline-size: 34px;
  block-size: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.board-stage {
  position: relative;
  flex: 1 1 auto;
  min-block-size: 0;
  background:
    linear-gradient(180deg, rgba(247, 247, 247, 0.7), rgba(255, 255, 255, 1)),
    #ffffff;
}

.board-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(28, 28, 28, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 28, 28, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
}

#pixel-canvas {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  background: transparent;
}

#pixel-canvas.is-dragging {
  cursor: grabbing;
}

.challenge-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.challenge-modal.is-active {
  opacity: 1;
  pointer-events: auto;
}

.challenge-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.22), transparent 35%),
    rgba(10, 10, 10, 0.34);
  backdrop-filter: blur(18px) saturate(1.1);
}

.challenge-panel {
  position: relative;
  z-index: 1;
  width: min(520px, calc(100vw - 48px));
  max-height: min(640px, calc(100vh - 48px));
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 30px;
  background:
    radial-gradient(circle at top right, rgba(255, 122, 69, 0.16), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 250, 250, 0.94));
  box-shadow:
    0 34px 80px rgba(15, 15, 15, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(22px);
  transform: translateY(20px) scale(0.98);
  transition:
    transform 220ms cubic-bezier(0.2, 0.9, 0.2, 1),
    opacity 220ms ease;
}

.challenge-modal.is-active .challenge-panel {
  transform: translateY(0) scale(1);
}

.challenge-sheet-handle {
  display: none;
  align-self: center;
  width: 46px;
  height: 5px;
  margin-top: -6px;
  border-radius: 999px;
  background: rgba(22, 22, 22, 0.12);
}

.challenge-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.challenge-header h2 {
  margin: 4px 0 0;
  font-size: 1.08rem;
}

.challenge-kicker {
  margin: 0;
}

.challenge-close {
  inline-size: 38px;
  block-size: 38px;
  border: 1px solid rgba(22, 22, 22, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(17, 17, 17, 0.08);
}

.challenge-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.challenge-meta > div {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(246, 246, 246, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.challenge-meta strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.92rem;
}

.challenge-color-swatch {
  inline-size: 16px;
  block-size: 16px;
  border-radius: 999px;
  border: 1px solid rgba(17, 17, 17, 0.16);
  background: #ffffff;
}

.challenge-prompt,
.challenge-status {
  margin: 0;
  line-height: 1.55;
  color: var(--ink);
}

.challenge-prompt {
  padding: 16px 18px;
  border: 1px solid rgba(22, 22, 22, 0.06);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(253, 253, 253, 0.96), rgba(245, 245, 245, 0.94));
}

.challenge-prompt.is-hidden {
  display: none;
}

.challenge-locked-shell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.challenge-locked-shell.is-hidden {
  display: none;
}

.challenge-locked-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.08);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.challenge-locked-badge.challenge-locked-badge-hidden {
  display: none;
}

.challenge-locked-preview {
  width: 100%;
  display: flex;
  align-items: stretch;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(22, 22, 22, 0.08);
  border-radius: 22px;
  background:
    radial-gradient(circle at top right, rgba(255, 122, 69, 0.1), transparent 26%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(246, 246, 246, 0.93));
  color: var(--ink);
  text-decoration: none;
  box-shadow:
    0 16px 30px rgba(17, 17, 17, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.challenge-locked-preview.challenge-locked-preview-hidden {
  display: none;
}

.challenge-locked-preview-image {
  flex: 0 0 116px;
  width: 116px;
  height: 116px;
  object-fit: cover;
  border-radius: 16px;
  background: rgba(17, 17, 17, 0.06);
}

.challenge-locked-preview-image.challenge-locked-preview-image-hidden {
  display: none;
}

.challenge-locked-preview-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.challenge-locked-preview-site {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.challenge-locked-preview-title {
  font-size: 1rem;
  line-height: 1.35;
}

.challenge-locked-preview-excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.challenge-game-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.challenge-game-shell.is-hidden {
  display: none;
}

.challenge-panel.is-game-mode {
  width: min(920px, calc(100vw - 48px));
  max-height: min(92svh, calc(100vh - 28px));
}

.challenge-meta.is-hidden {
  display: none;
}

.challenge-game-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.challenge-game-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.08);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.challenge-game-chip.challenge-game-chip-accent {
  background: rgba(255, 122, 69, 0.14);
}

.challenge-game-layout {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.challenge-game-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(22, 22, 22, 0.08);
  border-radius: 26px;
  background:
    radial-gradient(circle at top, rgba(255, 122, 69, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(17, 17, 17, 0.98), rgba(28, 28, 28, 0.96));
  box-shadow:
    0 18px 34px rgba(17, 17, 17, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.challenge-game-canvas {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  aspect-ratio: 1 / 2;
  border-radius: 22px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(9, 9, 14, 0.98), rgba(18, 18, 26, 0.98));
}

.challenge-game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.challenge-game-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.challenge-game-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid rgba(22, 22, 22, 0.06);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 244, 244, 0.94));
}

.challenge-game-stat span {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.challenge-game-stat strong {
  font-size: 1.12rem;
  line-height: 1.2;
}

.challenge-game-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.challenge-game-primary,
.challenge-game-secondary,
.challenge-game-control {
  min-height: 46px;
  border-radius: 16px;
  border: 1px solid rgba(22, 22, 22, 0.08);
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
  touch-action: manipulation;
}

.challenge-game-primary:hover,
.challenge-game-secondary:hover,
.challenge-game-control:hover {
  transform: translateY(-1px);
}

.challenge-game-primary {
  border: none;
  background: linear-gradient(180deg, #111111, #252525);
  color: #ffffff;
  box-shadow: 0 14px 26px rgba(17, 17, 17, 0.16);
}

.challenge-game-secondary,
.challenge-game-control {
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}

.challenge-game-primary:disabled,
.challenge-game-secondary:disabled,
.challenge-game-control:disabled {
  opacity: 0.56;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.challenge-game-status {
  margin: 0;
  padding: 13px 14px;
  border-radius: 18px;
  background: rgba(22, 22, 22, 0.04);
  color: var(--muted);
  line-height: 1.55;
}

.challenge-game-status.is-success {
  background: rgba(15, 138, 95, 0.08);
  border: 1px solid rgba(15, 138, 95, 0.1);
  color: var(--success);
}

.challenge-game-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.challenge-game-control {
  min-height: 44px;
  font-size: 0.84rem;
}

.challenge-game-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.challenge-audio-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(22, 22, 22, 0.06);
  border-radius: 20px;
  background:
    radial-gradient(circle at left top, rgba(255, 122, 69, 0.12), transparent 30%),
    linear-gradient(180deg, rgba(255, 251, 249, 0.96), rgba(246, 244, 243, 0.92));
}

.challenge-audio-shell.is-hidden {
  display: none;
}

.challenge-audio-button {
  min-height: 50px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(180deg, #111111, #252525);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 26px rgba(17, 17, 17, 0.16);
}

.challenge-audio-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.challenge-audio-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.challenge-status {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(22, 22, 22, 0.04);
  color: var(--muted);
  font-size: 0.94rem;
}

.challenge-status.is-error {
  background: rgba(195, 66, 63, 0.08);
  border: 1px solid rgba(195, 66, 63, 0.1);
  color: var(--error);
}

.challenge-status.is-success {
  background: rgba(15, 138, 95, 0.09);
  border: 1px solid rgba(15, 138, 95, 0.12);
  color: var(--success);
}

.challenge-status.challenge-status-hidden {
  display: none;
}

.challenge-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.challenge-form.challenge-form-hidden {
  display: none;
}

.challenge-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.challenge-field span {
  font-size: 0.82rem;
  font-weight: 600;
}

.challenge-field input {
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid rgba(22, 22, 22, 0.09);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  outline: none;
}

.challenge-field input:focus {
  border-color: rgba(23, 23, 23, 0.24);
}

.challenge-color-input-shell {
  display: flex;
  align-items: center;
  gap: 12px;
}

#challenge-color-input {
  flex: 0 0 auto;
  inline-size: 64px;
  block-size: 50px;
  padding: 4px;
  border: 1px solid rgba(22, 22, 22, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  cursor: pointer;
}

#challenge-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

#challenge-color-input::-webkit-color-swatch,
#challenge-color-input::-moz-color-swatch {
  border: none;
  border-radius: 13px;
}

.challenge-color-pill {
  flex: 1 1 auto;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border: 1px solid rgba(22, 22, 22, 0.08);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(245, 245, 245, 0.92));
}

.challenge-color-pill strong {
  font-size: 0.94rem;
}

.challenge-color-pill-swatch {
  inline-size: 18px;
  block-size: 18px;
  border-radius: 999px;
  border: 1px solid rgba(17, 17, 17, 0.14);
  background: #ffffff;
}

.challenge-submit {
  flex: 1 1 auto;
  min-height: 52px;
  border: none;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(29, 29, 29, 1), rgba(10, 10, 10, 1));
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 16px 28px rgba(17, 17, 17, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.challenge-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.challenge-retry {
  flex: 0 0 auto;
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid rgba(22, 22, 22, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.challenge-retry-hidden {
  display: none;
}

.challenge-submit:disabled,
.challenge-retry:disabled,
.challenge-close:disabled,
.challenge-backdrop:disabled {
  opacity: 0.6;
  cursor: default;
}

.docs-page {
  min-height: 100vh;
  overflow: auto;
  background:
    linear-gradient(180deg, #fbfbfb, #f4f4f4),
    #ffffff;
}

.docs-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.docs-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.docs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.docs-back {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  text-decoration: none;
  background: #ffffff;
  font-weight: 600;
}

.docs-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.docs-card h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.95;
}

.docs-card p {
  margin: 0;
  line-height: 1.65;
  color: var(--muted);
}

.docs-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.docs-section {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.88);
}

.docs-section h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-section p,
.docs-section li {
  color: var(--muted);
  line-height: 1.65;
}

.docs-section ul,
.docs-section ol {
  margin: 0;
  padding-left: 18px;
}

.docs-section li + li {
  margin-top: 8px;
}

.docs-code {
  margin-top: 12px;
  padding: 14px;
  overflow: auto;
  border-radius: 16px;
  background: #151515;
  color: #f2f2f2;
  font-size: 0.88rem;
  line-height: 1.6;
}

.docs-inline {
  padding: 0 6px;
  border-radius: 8px;
  background: #f3f3f3;
}

@media (max-width: 920px) {
  .app-header {
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .app-header h1 {
    order: 1;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
  }

  .header-left,
  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .header-left {
    order: 2;
    flex-wrap: wrap;
  }

  .header-right {
    order: 3;
    gap: 8px;
  }

  .zoom-control {
    flex: 1 1 auto;
  }

  .zoom-control input {
    flex: 1 1 auto;
    inline-size: auto;
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .paint-control span {
    display: none;
  }

  .header-right {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
  }

  .header-link {
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.74rem;
  }

  .zoom-button {
    inline-size: 38px;
    block-size: 38px;
  }

  .zoom-control input {
    min-height: 44px;
  }

  #zoom-readout {
    min-inline-size: 42px;
    font-size: 0.68rem;
  }

  .challenge-modal {
    align-items: flex-end;
    padding: 0;
  }

  .challenge-backdrop {
    background:
      linear-gradient(180deg, rgba(10, 10, 10, 0.08), rgba(10, 10, 10, 0.42)),
      rgba(10, 10, 10, 0.26);
  }

  .challenge-panel {
    width: 100%;
    min-height: min(56svh, 520px);
    max-height: calc(100svh - 14px);
    padding: 14px 18px calc(18px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
    transform: translateY(100%);
  }

  .challenge-panel.is-game-mode {
    min-height: auto;
    max-height: calc(100svh - 12px);
    padding: 12px 12px calc(14px + env(safe-area-inset-bottom));
  }

  .challenge-meta {
    grid-template-columns: 1fr;
  }

  .challenge-modal.is-active .challenge-panel {
    transform: translateY(0);
  }

  .challenge-sheet-handle {
    display: block;
  }

  .challenge-color-input-shell {
    align-items: stretch;
  }

  #challenge-color-input {
    inline-size: 70px;
    block-size: 52px;
  }

  .challenge-locked-preview {
    flex-direction: column;
  }

  .challenge-locked-preview-image {
    width: 100%;
    height: 150px;
    flex-basis: auto;
  }

  .challenge-game-layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .challenge-game-stage {
    padding: 8px;
    border-radius: 22px;
  }

  .challenge-game-canvas {
    width: auto;
    max-width: 100%;
    height: min(36svh, 300px);
    max-height: 300px;
  }

  .challenge-game-shell {
    gap: 10px;
  }

  .challenge-game-chips {
    gap: 6px;
  }

  .challenge-game-chip {
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.66rem;
  }

  .challenge-game-sidebar {
    gap: 10px;
  }

  .challenge-game-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .challenge-game-stat {
    gap: 4px;
    padding: 10px 10px;
    border-radius: 14px;
  }

  .challenge-game-stat span {
    font-size: 0.64rem;
    letter-spacing: 0.05em;
  }

  .challenge-game-stat strong {
    font-size: 0.94rem;
  }

  .challenge-game-actions {
    gap: 8px;
  }

  .challenge-game-status {
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 0.82rem;
    line-height: 1.42;
  }

  .challenge-game-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  #tetris-down-button {
    grid-column: 1 / 2;
  }

  #tetris-drop-button {
    grid-column: 2 / 4;
  }

  .challenge-game-control,
  .challenge-game-primary,
  .challenge-game-secondary {
    min-height: 40px;
    border-radius: 14px;
    font-size: 0.78rem;
  }

  .challenge-game-hint {
    font-size: 0.74rem;
    line-height: 1.35;
  }

  .docs-shell {
    padding: 18px 12px 36px;
  }

  .docs-card,
  .docs-section {
    padding: 18px;
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .challenge-modal,
  .challenge-panel {
    transition: none;
  }
}
