html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(circle at 50% 12%, #344b68 0, #202a42 48%, #141725 100%);
}

#stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

#game-shell {
  position: relative;
  width: min(97vw, calc(97vh * 520 / 780));
  aspect-ratio: 520 / 780;
  container-type: inline-size;
  border-radius: 12px;
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.58),
    0 0 0 6px rgba(9, 12, 24, 0.34),
    0 0 0 8px rgba(238, 218, 176, 0.12);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: #d7e3df;
  touch-action: none;
}

#game:focus-visible {
  outline: 3px solid #f1b13b;
  outline-offset: 5px;
}

#loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff0ca;
  background: rgba(13, 21, 39, 0.82);
  border-radius: 10px;
  font: 700 clamp(14px, 4cqw, 19px) 'Chalkboard SE', 'Comic Sans MS', 'Trebuchet MS', sans-serif;
  letter-spacing: 0.06em;
  pointer-events: auto;
  z-index: 10;
}

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

#character-picker {
  position: absolute;
  z-index: 4;
  top: 36.5%;
  left: 5%;
  width: 90%;
  color: #281a16;
  touch-action: manipulation;
}

#character-picker[hidden] {
  display: none;
}

.picker-title {
  width: max-content;
  margin: 0 auto 1.4cqw;
  padding: 0.8cqw 2.4cqw;
  border: 1px solid rgba(55, 30, 20, 0.28);
  border-radius: 999px;
  background:
    url('../assets/art/ui/paper-materials-v2.png') 0 0 / 300% 200%,
    #fff3d8;
  box-shadow: 0 3px 7px rgba(42, 23, 15, 0.25);
  font: 800 clamp(10px, 2.8cqw, 14px) 'Chalkboard SE', 'Comic Sans MS', 'Trebuchet MS', sans-serif;
  letter-spacing: 0.08em;
}

.character-options {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 30%;
  gap: 2cqw;
  padding: 0.8cqw 0.8cqw 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-padding-inline: 0.8cqw;
  scroll-snap-type: x proximity;
  overscroll-behavior-inline: contain;
  touch-action: pan-x;
  scrollbar-width: thin;
  scrollbar-color: rgba(77, 45, 31, 0.48) rgba(255, 243, 216, 0.5);
  cursor: grab;
}

.character-options:active,
.character-options.is-dragging {
  scroll-snap-type: none;
  cursor: grabbing;
}

.character-options::-webkit-scrollbar {
  height: max(4px, 0.8cqw);
}

.character-options::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255, 243, 216, 0.5);
}

.character-options::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(77, 45, 31, 0.48);
}

.character-option {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  align-items: center;
  min-width: 0;
  aspect-ratio: 1.14;
  padding: 1.4cqw 1cqw 1.2cqw;
  overflow: hidden;
  color: #2a1b17;
  border: max(2px, 0.55cqw) solid rgba(67, 38, 27, 0.32);
  border-radius: 2.4cqw 2cqw 2.7cqw 1.8cqw;
  background:
    url('../assets/art/ui/paper-materials-v2.png') 0 0 / 300% 200%,
    #fff1d2;
  box-shadow: 0 3px 8px rgba(42, 23, 15, 0.28);
  font-family: 'Chalkboard SE', 'Comic Sans MS', 'Trebuchet MS', sans-serif;
  cursor: inherit;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
}

.character-option::after {
  content: '';
  position: absolute;
  inset: 0.8cqw;
  border: 1px dashed color-mix(in srgb, var(--accent) 48%, transparent);
  border-radius: 1.6cqw;
  pointer-events: none;
}

.character-option:hover,
.character-option:focus-visible {
  transform: translateY(-2px) rotate(-0.35deg);
  outline: none;
  border-color: var(--accent);
}

.character-option[aria-pressed='true'] {
  transform: translateY(-4px) rotate(0.5deg);
  border-color: var(--accent);
  box-shadow:
    0 5px 10px rgba(42, 23, 15, 0.32),
    0 0 0 max(2px, 0.6cqw) color-mix(in srgb, var(--accent) 35%, transparent);
}

.character-option img {
  display: block;
  width: 78%;
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(45, 24, 16, 0.27));
  pointer-events: none;
}

.character-name {
  position: relative;
  z-index: 1;
  font-size: clamp(11px, 3.5cqw, 17px);
  font-weight: 900;
  line-height: 1;
}

.character-tagline {
  position: relative;
  z-index: 1;
  margin-top: 0.7cqw;
  color: #5f493d;
  font-size: clamp(8px, 2.15cqw, 11px);
  font-weight: 700;
  line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
  .character-option {
    transition: none;
  }
}
