.home-game {
  --game-fill: #fff5df;
  --game-hover: #ffe5ad;
  --game-ink: #67410f;
  --game-edge: #b98130;
  --game-shadow: #bd8736;
  position: absolute;
  z-index: 3;
  inset: clamp(12px, 3.25cqi, 20px) auto auto 50%;
  translate: -50% 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 24px);
  min-height: 44px;
  padding: 5px 14px;
  border: 2px solid var(--game-edge);
  background: var(--game-fill);
  color: var(--game-ink);
  box-shadow: inset 0 0 0 2px #ffffff70, 3px 3px 0 var(--game-shadow);
  font-size: clamp(14px, 3.5cqi, 17px);
  text-align: center;
  text-decoration: none;
}
.home-game::before {
  content: '';
  flex: none;
  width: 16px;
  height: 16px;
  background: currentColor;
  clip-path: polygon(44% 0, 56% 0, 56% 18%, 72% 18%, 72% 35%, 100% 35%, 100% 60%, 72% 60%, 72% 77%, 56% 77%, 56% 100%, 44% 100%, 44% 77%, 28% 77%, 28% 60%, 0 60%, 0 35%, 28% 35%, 28% 18%, 44% 18%);
}
[data-theme="dungeon"] .home-game {
  --game-fill: #21182b;
  --game-hover: #392440;
  --game-ink: #ffe0b7;
  --game-edge: #a37fb4;
  --game-shadow: #100a15;
  box-shadow: inset 0 -3px #60406d, 3px 3px 0 var(--game-shadow);
}
[data-theme="dungeon"] .home-game::before {
  color: #ffa268;
  clip-path: polygon(47% 0, 62% 0, 62% 19%, 76% 19%, 76% 38%, 90% 38%, 90% 56%, 100% 56%, 100% 81%, 81% 81%, 81% 100%, 20% 100%, 20% 82%, 0 82%, 0 53%, 17% 53%, 17% 35%, 33% 35%, 33% 47%, 47% 47%);
}
.home-game:is(:hover, :focus-visible) {
  background: var(--game-hover);
  color: var(--game-ink);
}
.home-game:active { translate: calc(-50% + 2px) 2px; }

.arcade {
  --arcade-bg: #101520;
  --arcade-panel: #1c2433;
  --arcade-ink: #f6ead7;
  --arcade-muted: #b8c6c9;
  --arcade-green: #c3f97c;
  --arcade-line: #63787b;
  --arcade-red: #fb8998;
  width: min(750px, calc(100% - 32px));
  max-height: min(94dvh, 950px);
  padding: clamp(12px, 2.5vw, 24px);
  overflow: auto;
  color: var(--arcade-ink);
  background: var(--arcade-bg);
  border: 3px solid var(--arcade-line);
  box-shadow: 5px 5px 0 #080d13;
  font: inherit;
  font-size: clamp(11px, 2.7vw, 14px);
  line-height: 1.5;
  opacity: 0;
  translate: 0 10px;
  transition: opacity 180ms, translate 180ms, display 180ms allow-discrete, overlay 180ms allow-discrete;
}
.arcade[open] { opacity: 1; translate: 0; }
@starting-style { .arcade[open] { opacity: 0; translate: 0 10px; } }
.arcade::backdrop { background: #070b13d9; }
body:has(.arcade[open]) { overflow: hidden; }
.arcade [hidden] { display: none; }
.arcade-header, .arcade-actions, .arcade-hud, .arcade-menu, .arcade-keys, .arcade-sequence {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.arcade-header { justify-content: space-between; margin-bottom: 14px; }
.arcade-header h2 { font-size: clamp(19px, 4.7vw, 33px); line-height: 1.13; }
.arcade-header h2 span { color: var(--arcade-green); }
.arcade button {
  appearance: none;
  border: 2px solid var(--arcade-line);
  border-radius: 0;
  background: var(--arcade-panel);
  color: var(--arcade-ink);
  padding: 7px 10px;
  min-height: 36px;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.arcade button:disabled { opacity: .6; cursor: wait; }
.arcade button:enabled:hover, .arcade button:focus-visible {
  border-color: var(--arcade-green);
  color: var(--arcade-green);
}
.arcade button:focus-visible { outline: 2px dashed var(--arcade-green); outline-offset: 2px; }
.arcade button:active { translate: 1px 1px; }
.arcade [data-start], .arcade [data-tap=" "] { color: var(--arcade-green); border-color: var(--arcade-green); }
.arcade-hud { gap: 5px 18px; margin-bottom: 12px; color: var(--arcade-muted); }
.arcade-hud strong { color: var(--arcade-ink); font-weight: normal; white-space: nowrap; }
.arcade-form strong { color: var(--arcade-green); }
.arcade progress {
  width: 100%;
  height: 7px;
  appearance: none;
  display: block;
  border: 0;
  border-radius: 0;
  background: #374351;
  color: var(--arcade-green);
}
.arcade progress::-webkit-progress-bar { background: #374351; }
.arcade progress::-webkit-progress-value { background: var(--arcade-green); }
.arcade progress::-moz-progress-bar { background: var(--arcade-green); }
.arcade-stage {
  position: relative;
  overflow: hidden;
  border: 2px solid var(--arcade-line);
  background: #141b2a;
}
.arcade-stage canvas { width: 100%; height: auto; display: block; image-rendering: pixelated; }
.arcade-scene-caption {
  position: absolute;
  inset: auto 6px 8px;
  text-align: center;
  color: var(--arcade-green);
  text-shadow: 2px 2px #080c12;
  font-size: clamp(10px, 2.6vw, 17px);
  pointer-events: none;
}
.arcade-challenge {
  min-height: 150px;
  display: grid;
  align-content: start;
  gap: 7px;
  padding-top: 12px;
}
.arcade-challenge h3 { font-size: clamp(14px, 3.2vw, 21px); }
.arcade-challenge [data-instructions] { color: var(--arcade-muted); }
.arcade-timing {
  position: relative;
  height: 20px;
  background: #8d304d;
  border: 2px solid #d396a5;
}
.arcade-target, .arcade-perfect, .arcade-marker { position: absolute; inset-block: 0; }
.arcade-target { left: var(--target-left); width: var(--target-width); background: #66c060; }
.arcade-perfect { left: 48%; width: 4%; background: #d6f58b; }
.arcade-marker { left: var(--marker, 0%); width: 4px; translate: -50% 0; background: #fff6e0; box-shadow: 1px 0 #101520; }
.arcade-sequence kbd {
  font: inherit;
  font-size: 18px;
  min-width: 2.2ch;
  text-align: center;
  padding: 1px 4px;
  background: var(--arcade-panel);
  border: 1px solid var(--arcade-line);
}
.arcade-sequence kbd[data-hit] { color: var(--arcade-green); border-color: var(--arcade-green); }
.arcade-keys { gap: 5px; }
.arcade-keys button { min-width: 42px; min-height: 42px; }
.arcade-status { min-height: 1.5em; color: var(--arcade-green); }
.arcade[data-state="miss"] .arcade-status { color: var(--arcade-red); }
.arcade[data-state="miss"] .arcade-sequence kbd { color: var(--arcade-red); border-color: var(--arcade-red); }
.arcade-results { white-space: pre-line; }
.arcade[data-state="complete"] .arcade-status { display: none; }
@media (min-width: 660px) {
  .arcade[data-state="complete"] .arcade-challenge {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 20px;
  }
  .arcade[data-state="complete"] .arcade-menu {
    grid-area: 1 / 2 / 4;
    align-self: center;
    justify-content: flex-end;
  }
}
@media (prefers-reduced-motion: reduce) {
  .arcade { transition: none; }
}

.arcade-reaction {
  position: absolute;
  top: 29%;
  left: 59%;
  max-width: 37%;
  padding: 4px 7px;
  background: #111927;
  color: #fff2d7;
  border: 1px solid #a7d59a;
  box-shadow: 2px 2px #0c111d;
  font-size: clamp(8px, 1.8vw, 14px);
  line-height: 1.25;
  pointer-events: none;
  animation: arcade-bubble-in 140ms steps(3, end) both;
}
.arcade-reaction::before {
  content: '';
  position: absolute;
  top: calc(50% - 3px);
  left: -7px;
  width: 6px;
  height: 7px;
  background: #a7d59a;
  clip-path: polygon(0 42%, 35% 42%, 35% 26%, 65% 26%, 65% 0, 100% 0, 100% 100%, 65% 100%, 65% 74%, 35% 74%, 35% 57%, 0 57%);
}
@keyframes arcade-bubble-in {
  from { opacity: 0; translate: 0 4px; }
  to { opacity: 1; translate: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .arcade-reaction { animation: none; }
}

.arcade[data-rubick-greeting] .arcade-reaction {
  left: auto;
  right: 59%;
}
.arcade[data-rubick-greeting] .arcade-reaction::before {
  left: auto;
  right: -7px;
  scale: -1 1;
}

.arcade-targets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.arcade-targets button { min-height: 44px; }
.arcade .arcade-targets button[data-active] {
  color: #111520;
  background: var(--arcade-green);
  border-color: #fff2cf;
  box-shadow: inset 0 -4px #608337;
}

.arcade button.arcade-lock:not([hidden]) {
  position: absolute;
  inset-block: 0;
  inset-inline-end: clamp(6px, 3%, 22px);
  margin-block: auto;
  display: grid;
  place-items: center;
  width: clamp(88px, 20%, 134px);
  height: min(116px, 86%);
  background: #132336;
}
.arcade-lock::before, .arcade-lock-ring {
  content: '';
  position: absolute;
  width: min(56px, 56%);
  aspect-ratio: 1;
  border: 2px solid var(--arcade-line);
  border-radius: 50%;
  pointer-events: none;
}
.arcade-lock-ring {
  border-color: #ffd470;
  transform: scale(var(--ring-scale, 1.7));
}
.arcade-lock[data-active] .arcade-lock-ring {
  border-color: var(--arcade-green);
  box-shadow: 0 0 8px var(--arcade-green);
}
.arcade-lock > :last-child { z-index: 1; }
