:root {
  color-scheme: light;
  --sky: #22343c;
  --cream: #fff4d7;
  --gold: #f4d38c;
  --ink: #263a41;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-family: system-ui, sans-serif;
  color: var(--cream);
  background: var(--sky);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 5px; }
svg { display: block; width: 100%; height: 100%; }
.definitions, .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
h1, h2, h3, p { margin: 0; }

.shelf, .activity {
  --edge: clamp(12px, 3vmin, 30px);
  position: relative;
  min-height: 100dvh;
  padding:
    max(var(--edge), env(safe-area-inset-top))
    max(var(--edge), env(safe-area-inset-right))
    max(var(--edge), env(safe-area-inset-bottom))
    max(var(--edge), env(safe-area-inset-left));
  background:
    radial-gradient(circle at 16% 28%, #ced6c29c 1px, transparent 1.8px),
    radial-gradient(circle at 77% 24%, #ced6c262 1px, transparent 1.75px),
    radial-gradient(circle at 68% 73%, #ced6c278 1px, transparent 1.6px),
    radial-gradient(ellipse at 50% 38%, #425e62 0%, #2e454c 43%, var(--sky) 86%);
  background-size: 191px 197px, 269px 223px, 419px 241px, 100% 100%;
}

.corner-button {
  position: absolute;
  z-index: 5;
  top: max(var(--edge), env(safe-area-inset-top));
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 1px solid #fbebc8;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  box-shadow: 0 4px 0 #152930, 0 8px 18px #11232980;
  cursor: pointer;
}
.corner-button svg { width: 28px; height: 28px; }
.corner-button:hover { background: #ffe3a5; }
.corner-button:active { transform: translateY(2px); }
.back-button { left: max(var(--edge), env(safe-area-inset-left)); }
.repeat { right: max(var(--edge), env(safe-area-inset-right)); }

.shelf { display: grid; place-items: center; }
.shelf-menu { display: grid; justify-items: center; gap: clamp(12px, 3vmin, 27px); width: min(100%, 800px); }
.brand-mark { display: block; width: clamp(49px, 9vmin, 68px); height: auto; border-radius: 24%; box-shadow: 0 6px 16px #1428307d; }
.shelf h1 { font: 700 clamp(2.35rem, 7vw, 4.4rem)/1.04 var(--serif); text-align: center; letter-spacing: -.052em; }
.game-grid {
  --tile-gap: clamp(10px, 2vmin, 20px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--tile-gap);
  width: 100%;
  padding-block: 5px 9px;
}
.game-tile {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: min(226px, calc((100% - 2 * var(--tile-gap)) / 3));
  aspect-ratio: 1;
  padding: clamp(5px, 1.1vmin, 9px);
  border: 1px solid #f4db9b;
  border-radius: clamp(16px, 3vmin, 27px);
  background: #efe2be;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  box-shadow: 0 5px 0 #b6a479, 0 13px 24px #16282ebd;
  transition: transform 200ms ease;
}
.game-tile:hover { transform: translateY(-3px); }
.game-tile:active { transform: translateY(3px); }
.tile-art { border-radius: clamp(11px, 2.2vmin, 18px); overflow: hidden; background: #324f56; }
.tile-shapes .tile-art { background: radial-gradient(ellipse, #9c695b, #6f4b50); }
.tile-sizes .tile-art { background: radial-gradient(ellipse, #566d6a, #3a5357); }
.tile-label { padding: clamp(5px, 1.5vmin, 12px) 2px clamp(0px, .5vmin, 4px); font-weight: 750; font-size: clamp(1rem, 3vmin, 1.45rem); line-height: 1.1; }
.illustration-rocket, .tile-pieces { fill: #92a38a; filter: drop-shadow(3px 6px 3px #182e366b); }

body.is-playing { overflow: hidden; }
.activity { position: fixed; inset: 0; min-height: 0; }
.play-area {
  --dock-height: clamp(82px, 23dvh, 198px);
  --piece-width: min(34cqw, 34cqh, var(--dock-height), 225px);
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--dock-height);
  gap: clamp(5px, 1.25vmin, 14px);
  container-type: size;
  user-select: none;
}
.game-mat {
  grid-row: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
}
.assembly { position: relative; width: var(--piece-width); aspect-ratio: 160 / 296; }
.assembly::before {
  content: "";
  position: absolute;
  width: 226%;
  aspect-ratio: 1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid #c7d1b542;
  border-radius: 50%;
  background: radial-gradient(circle, #c3d5b716 30%, #c3d5b709 65%, transparent 71%);
  box-shadow: inset 0 0 0 10px #acbda009, 0 0 0 12px #acbda009;
  pointer-events: none;
}
.play-area.is-horizontal {
  --piece-width: min(28cqw, 42cqh, calc(var(--dock-height) * .86), 174px);
}
.is-horizontal .assembly { aspect-ratio: 160 / 120; }
.is-horizontal .assembly::before { width: 322%; aspect-ratio: 3; border-radius: 999px; }

.piece-tray {
  grid-row: 2;
  position: relative;
  width: min(100%, 780px);
  justify-self: center;
  border: 1px solid #d3bb87;
  border-radius: clamp(18px, 4vmin, 32px);
  background: linear-gradient(180deg, #e6d5b0, #ccba90);
  box-shadow: 0 4px 0 #907b54, 0 12px 26px #15262eaa, inset 0 0 0 5px #f8edcf68;
}
.piece, .socket {
  position: absolute;
  width: calc(var(--piece-width) * var(--piece-width-factor));
  padding: 0;
  border: 0;
  background: transparent;
  aspect-ratio: var(--piece-ratio);
  color: #243d45;
  fill: currentColor;
}
.piece { top: 50%; left: var(--tray-x); transform: translate(-50%, -50%); touch-action: none; cursor: grab; }
.piece svg { overflow: visible; pointer-events: none; filter: drop-shadow(0 5px 3px #52432e60); }
.piece[aria-pressed="true"] { outline: 2px dashed #314a50; border-radius: 10px; outline-offset: 3px; }
.piece:focus-visible { outline-color: #314a50; }
.piece.is-dragging { z-index: 3; cursor: grabbing; }
.piece.is-dragging svg { filter: drop-shadow(0 9px 6px #1827338a); }
.piece.is-settling { z-index: 2; }
.socket {
  --piece-detail-display: none;
  left: calc(50% + var(--piece-width) * var(--slot-x));
  top: calc(var(--piece-width) * var(--slot-y));
  transform: translateX(-50%);
  cursor: pointer;
}
.piece-detail { display: var(--piece-detail-display, inline); }
.socket svg {
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(1px 1px 0 #cbd8c2b3) drop-shadow(-1px -1px 0 #cbd8c269);
}
.socket.is-filled { --piece-detail-display: inline; pointer-events: none; }
.socket.is-filled svg { filter: drop-shadow(0 4px 4px #18293199); }
.play-area.has-selection .socket:not(.is-filled):hover { color: #34535a; }

@media (max-width: 520px) and (orientation: portrait) {
  .shelf-menu { width: min(100%, 430px); }
  .game-tile { width: calc((100% - var(--tile-gap)) / 2); }
}
@media (max-height: 500px) and (orientation: landscape) {
  .shelf-menu { gap: 8px; }
  .shelf .brand-mark { display: none; }
  .shelf h1 { font-size: clamp(2rem, 9dvh, 3.25rem); }
  .game-tile { max-width: min(49dvh, 226px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; }
}
