:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #536175;
  --line: rgba(28, 41, 64, 0.14);
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #facc15;
  --shadow: 0 18px 45px rgba(27, 38, 59, 0.18);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.68) 0 25%, transparent 25% 50%, rgba(255, 255, 255, 0.55) 50% 75%, transparent 75%) 0 0 / 36px 36px,
    linear-gradient(135deg, #dff7ef 0%, #eaf3ff 45%, #fff4d7 100%);
}

button {
  font: inherit;
}

.pattern-game {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100svh;
  min-height: 100svh;
  padding: clamp(10px, 1.8vw, 22px);
  gap: clamp(8px, 1.4vw, 16px);
  overflow: hidden;
}

.asset-loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 18%),
    radial-gradient(circle at 78% 22%, rgba(255, 191, 61, 0.42), rgba(255, 191, 61, 0) 24%),
    linear-gradient(135deg, #073b30 0%, #0f766e 46%, #102033 100%);
  transition: opacity 240ms ease, visibility 240ms ease;
  backdrop-filter: blur(10px);
}

.pattern-game:not(.is-loading) .asset-loader {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loader-card {
  width: min(520px, 100%);
  padding: clamp(20px, 5vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 26px 80px rgba(8, 37, 26, 0.28);
  text-align: center;
}

.brand-loader {
  position: relative;
  overflow: hidden;
  border-color: rgba(255, 255, 255, 0.74);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 253, 247, 0.92));
}

.brand-loader::before {
  content: "";
  position: absolute;
  inset: -45% -18% auto;
  height: 140px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.78), transparent);
  transform: rotate(-8deg) translateX(-55%);
  animation: loaderSweep 2.2s ease-in-out infinite;
  pointer-events: none;
}

.loader-eyebrow,
.small-label,
.overlay-kicker {
  margin: 0;
  color: #2563eb;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.loader-eyebrow {
  margin: 0 0 12px;
  color: #0e6b40;
  font-size: 11px;
  font-weight: 950;
  line-height: 1.2;
  letter-spacing: 0.12em;
}

.loader-brand {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0;
  width: 100%;
  max-width: 100%;
  margin: 0;
  overflow: visible;
  color: #0f2438;
  font-size: clamp(28px, 10vw, 58px);
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
}

.loader-brand span {
  flex: 0 0 auto;
  display: inline-block;
  color: transparent;
  background: linear-gradient(135deg, #102033 0%, #0f766e 52%, #ffbf3d 100%);
  background-clip: text;
  opacity: 0;
  transform: translateX(-28px) translateY(8px) rotate(-5deg);
  animation: brandLetterIn 0.68s cubic-bezier(0.18, 0.86, 0.25, 1.18) forwards;
  animation-delay: calc(var(--i) * 0.075s);
  -webkit-background-clip: text;
}

.loader-card p:not(.loader-eyebrow) {
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.55;
}

.loader-bar {
  height: 10px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #dceee7;
}

.loader-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1f8a4c, #27c6a1, #ffbf3d);
  transition: width 0.25s ease;
}

.game-topbar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: clamp(8px, 1.4vw, 16px);
  padding: clamp(10px, 1.4vw, 14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 26px rgba(27, 38, 59, 0.09);
  backdrop-filter: blur(18px);
}

.game-title {
  min-width: 0;
}

.game-title span {
  display: block;
  color: #2563eb;
  font-size: clamp(0.66rem, 1.4vw, 0.75rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.game-title strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #14213d;
  font-size: clamp(1rem, 2.2vw, 1.45rem);
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud {
  display: flex;
  gap: 8px;
}

.hud-item {
  min-width: clamp(58px, 7.6vw, 86px);
  padding: 8px 10px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 16px;
  background: #f7fbff;
  text-align: center;
}

.hud-item span {
  display: block;
  color: var(--muted);
  font-size: clamp(0.62rem, 1.2vw, 0.72rem);
  font-weight: 800;
}

.hud-item strong {
  display: block;
  color: #12325f;
  font-size: clamp(1rem, 2.2vw, 1.45rem);
  line-height: 1.02;
}

.finish-btn,
.primary-action,
.secondary-action,
.icon-action {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.finish-btn {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  color: white;
  background: #111827;
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(17, 24, 39, 0.16);
}

.finish-btn:hover,
.primary-action:hover,
.secondary-action:hover,
.icon-action:hover,
.object-token:hover {
  transform: translateY(-1px);
}

.finish-btn:active,
.primary-action:active,
.secondary-action:active,
.icon-action:active,
.object-token:active {
  transform: translateY(1px);
}

.game-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 0.62fr);
  gap: clamp(10px, 1.6vw, 18px);
  min-height: 0;
  flex: 1;
}

.pattern-panel,
.choice-card,
.hint-card,
.actions-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(27, 38, 59, 0.1);
  backdrop-filter: blur(16px);
}

.pattern-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: clamp(10px, 1.5vw, 16px);
  padding: clamp(12px, 1.7vw, 20px);
}

.panel-head,
.choice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2,
.choice-head h2 {
  margin: 2px 0 0;
  color: #14213d;
  font-size: clamp(1.05rem, 2.4vw, 1.55rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.rule-pill {
  flex: 0 0 auto;
  max-width: min(220px, 36vw);
  overflow: hidden;
  padding: 9px 12px;
  border-radius: 999px;
  color: #166534;
  background: #dcfce7;
  font-size: clamp(0.72rem, 1.5vw, 0.86rem);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pattern-board {
  display: grid;
  align-items: center;
  min-height: 0;
  flex: 1;
  padding: clamp(10px, 2.2vw, 22px);
  border: 1px solid rgba(20, 33, 61, 0.1);
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(37, 99, 235, 0.08), rgba(22, 163, 74, 0.08)),
    #fbfdff;
}

.sequence-row {
  --slots: 7;
  display: grid;
  grid-template-columns: repeat(var(--slots), minmax(42px, 1fr));
  align-items: stretch;
  gap: clamp(6px, 1vw, 14px);
  width: 100%;
}

.pattern-slot {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid rgba(20, 33, 61, 0.12);
  border-radius: 18px;
  background: var(--panel-strong);
  box-shadow: inset 0 -8px 18px rgba(20, 33, 61, 0.06);
}

.pattern-slot.blank-cell {
  border-style: dashed;
  border-color: rgba(37, 99, 235, 0.38);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(250, 204, 21, 0.12)),
    #ffffff;
  cursor: pointer;
}

.pattern-slot.blank-cell::before {
  content: "";
  position: absolute;
  inset: clamp(8px, 1.5vw, 18px);
  border: 2px dashed rgba(37, 99, 235, 0.34);
  border-radius: 12px;
}

.pattern-slot.is-filled::before {
  display: none;
}

.pattern-slot.is-correct {
  border-color: rgba(22, 163, 74, 0.8);
  box-shadow: inset 0 0 0 4px rgba(22, 163, 74, 0.13), 0 10px 24px rgba(22, 163, 74, 0.16);
}

.pattern-slot.is-wrong {
  border-color: rgba(220, 38, 38, 0.82);
  box-shadow: inset 0 0 0 4px rgba(220, 38, 38, 0.12), 0 10px 24px rgba(220, 38, 38, 0.13);
}

.pattern-slot.drop-target {
  border-color: rgba(37, 99, 235, 0.9);
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.12), inset 0 -8px 18px rgba(20, 33, 61, 0.06);
}

.feedback {
  min-height: 46px;
  padding: 12px 14px;
  border-radius: 16px;
  color: #1f2937;
  background: rgba(255, 255, 255, 0.82);
  font-size: clamp(0.82rem, 1.55vw, 1rem);
  font-weight: 800;
  line-height: 1.3;
}

.feedback.good {
  color: #166534;
  background: #dcfce7;
}

.feedback.bad {
  color: #991b1b;
  background: #fee2e2;
}

.control-panel {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: clamp(10px, 1.4vw, 14px);
  min-width: 310px;
  min-height: 0;
}

.choice-card,
.hint-card,
.actions-card {
  padding: clamp(12px, 1.5vw, 16px);
}

.choice-card {
  min-height: 0;
  overflow: visible;
}

.icon-action {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 16px;
  background: #e0f2fe;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.12);
}

.audio-icon {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 5px 0 0 5px;
  background: #2563eb;
}

.audio-icon::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 13px;
  width: 12px;
  height: 18px;
  border: 4px solid #2563eb;
  border-left: 0;
  border-radius: 0 999px 999px 0;
}

.audio-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  left: -7px;
  width: 10px;
  height: 14px;
  border-radius: 4px;
  background: #2563eb;
}

.choice-tray {
  display: grid;
  grid-template-columns: repeat(4, 52px);
  justify-content: start;
  gap: 8px;
  margin-top: 12px;
}

.object-token {
  position: relative;
  display: grid;
  place-items: center;
  justify-items: center;
  align-items: center;
  min-width: 0;
  min-height: 76px;
  aspect-ratio: 1;
  padding: 8px;
  border: 1px solid rgba(20, 33, 61, 0.12);
  border-radius: 16px;
  color: #172033;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(27, 38, 59, 0.09);
  cursor: grab;
  overflow: visible;
  touch-action: none;
  user-select: none;
}

.choice-tray .object-token {
  width: 52px;
  min-height: 0;
  aspect-ratio: 1;
  padding: 5px;
  border-radius: 12px;
  overflow: hidden;
}

.choice-tray .object-icon {
  margin: auto;
  width: 30px;
  height: 30px;
}

.choice-tray .o-sun {
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.24), inset -5px -5px 0 rgba(180, 83, 9, 0.18);
}

.choice-tray .o-cloud {
  width: 34px;
  height: 22px;
}

.choice-tray .o-cloud::before {
  left: 6px;
}

.choice-tray .o-cloud::after {
  right: 6px;
}

.choice-tray .o-leaf {
  width: 28px;
  height: 28px;
}

.choice-tray .o-flower {
  width: 22px;
  height: 22px;
  box-shadow:
    0 -8px 0 #f472b6,
    8px 0 0 #fb7185,
    0 8px 0 #f472b6,
    -8px 0 0 #fb7185;
}

.choice-tray .o-flower::after {
  inset: 31%;
}

.choice-tray .o-kite::after {
  height: 7px;
}

.choice-tray .o-planet::after {
  left: -4%;
  width: 108%;
  border-width: 3px;
}

.choice-tray .o-cup::after {
  right: -10%;
  border-width: 3px;
}

.choice-tray .o-anchor {
  border-width: 4px;
}

.choice-tray .o-anchor::before {
  left: 44%;
  width: 12%;
}

.choice-tray .o-anchor::after {
  border-width: 4px;
}

.object-token:focus-visible,
.primary-action:focus-visible,
.secondary-action:focus-visible,
.finish-btn:focus-visible,
.icon-action:focus-visible,
.blank-cell:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 3px;
}

.object-token.is-selected {
  border-color: rgba(37, 99, 235, 0.78);
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.12), 0 8px 18px rgba(27, 38, 59, 0.09);
}

.object-token.placed-token {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.object-icon {
  position: relative;
  display: block;
  width: clamp(32px, 4.5vw, 54px);
  height: clamp(32px, 4.5vw, 54px);
}

.placed-token .object-icon {
  width: clamp(30px, 4vw, 50px);
  height: clamp(30px, 4vw, 50px);
}

.o-sun {
  border-radius: 999px;
  background: #fbbf24;
  box-shadow: 0 0 0 7px rgba(251, 191, 36, 0.24), inset -8px -8px 0 rgba(180, 83, 9, 0.18);
}

.o-moon {
  border-radius: 999px;
  background: #fde68a;
  box-shadow: inset -10px -4px 0 rgba(245, 158, 11, 0.26);
}

.o-moon::after {
  content: "";
  position: absolute;
  top: 0;
  right: -2px;
  width: 82%;
  height: 82%;
  border-radius: 999px;
  background: #ffffff;
}

.o-star {
  background: #f97316;
  clip-path: polygon(50% 0, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
}

.o-cloud {
  width: clamp(34px, 6vw, 62px);
  height: clamp(22px, 4vw, 40px);
  border-radius: 999px;
  background: #93c5fd;
  box-shadow: inset -8px -6px 0 rgba(37, 99, 235, 0.16);
}

.o-cloud::before,
.o-cloud::after {
  content: "";
  position: absolute;
  bottom: 8px;
  border-radius: 999px;
  background: #bfdbfe;
}

.o-cloud::before {
  left: 7px;
  width: 44%;
  height: 120%;
}

.o-cloud::after {
  right: 8px;
  width: 38%;
  height: 96%;
}

.o-leaf {
  width: clamp(30px, 4vw, 50px);
  height: clamp(30px, 4vw, 50px);
  border-radius: 85% 0 85% 0;
  background: linear-gradient(135deg, #86efac, #16a34a);
  transform: rotate(-35deg);
  box-shadow: inset -7px -7px 0 rgba(21, 128, 61, 0.16);
}

.placed-token .object-icon.o-leaf {
  width: clamp(28px, 3.45vw, 44px);
  height: clamp(28px, 3.45vw, 44px);
}

.o-leaf::after {
  content: "";
  position: absolute;
  inset: 18% 44% 10% 44%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
}

.o-flower {
  width: clamp(30px, 4vw, 48px);
  height: clamp(30px, 4vw, 48px);
  border-radius: 999px;
  background: #f9a8d4;
  box-shadow:
    0 -11px 0 #f472b6,
    11px 0 0 #fb7185,
    0 11px 0 #f472b6,
    -11px 0 0 #fb7185;
}

.placed-token .object-icon.o-flower {
  width: clamp(28px, 3.5vw, 44px);
  height: clamp(28px, 3.5vw, 44px);
}

.o-flower::after {
  content: "";
  position: absolute;
  inset: 32%;
  border-radius: 999px;
  background: #facc15;
}

.o-gem {
  background: linear-gradient(145deg, #67e8f9, #2563eb 58%, #1e3a8a);
  clip-path: polygon(50% 0, 96% 32%, 78% 100%, 22% 100%, 4% 32%);
}

.o-shell {
  border-radius: 50% 50% 44% 44%;
  background:
    repeating-radial-gradient(ellipse at 50% 95%, rgba(255, 255, 255, 0.5) 0 4px, rgba(255, 255, 255, 0) 4px 8px),
    linear-gradient(135deg, #fdba74, #fb7185);
}

.o-book {
  border-radius: 7px;
  background: #2563eb;
  box-shadow: inset 8px 0 0 #93c5fd, inset -5px 0 0 rgba(30, 58, 138, 0.42);
}

.o-book::after {
  content: "";
  position: absolute;
  inset: 15% 18% auto 38%;
  height: 5px;
  border-radius: 999px;
  background: #dbeafe;
  box-shadow: 0 11px 0 #dbeafe;
}

.o-cup {
  border-radius: 7px 7px 15px 15px;
  background: linear-gradient(135deg, #a7f3d0, #0f766e);
  clip-path: polygon(13% 0, 87% 0, 74% 100%, 26% 100%);
}

.o-cup::after {
  content: "";
  position: absolute;
  top: 15%;
  right: -15%;
  width: 24%;
  height: 38%;
  border: 4px solid #0f766e;
  border-left: 0;
  border-radius: 0 999px 999px 0;
}

.o-kite {
  background: linear-gradient(135deg, #f43f5e 0 49%, #facc15 50% 100%);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.o-kite::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 3px;
  height: 12px;
  border-radius: 999px;
  background: #64748b;
}

.o-planet {
  border-radius: 999px;
  background: linear-gradient(135deg, #c4b5fd, #7c3aed);
  box-shadow: inset -8px -7px 0 rgba(76, 29, 149, 0.24);
}

.o-planet::after {
  content: "";
  position: absolute;
  left: -10%;
  top: 43%;
  width: 120%;
  height: 20%;
  border: 4px solid rgba(245, 158, 11, 0.9);
  border-left-color: transparent;
  border-right-color: transparent;
  border-radius: 999px;
  transform: rotate(-18deg);
}

.o-mushroom {
  border-radius: 52% 52% 16% 16%;
  background: #ef4444;
}

.o-mushroom::before {
  content: "";
  position: absolute;
  left: 28%;
  top: 45%;
  width: 44%;
  height: 55%;
  border-radius: 7px 7px 14px 14px;
  background: #fde68a;
}

.o-mushroom::after {
  content: "";
  position: absolute;
  left: 20%;
  top: 20%;
  width: 14%;
  height: 14%;
  border-radius: 999px;
  background: #fecaca;
  box-shadow: 13px -3px 0 #fecaca, 20px 9px 0 #fecaca;
}

.o-lantern {
  width: clamp(30px, 4vw, 50px);
  height: clamp(30px, 4vw, 50px);
  border-radius: 12px 12px 18px 18px;
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  box-shadow: inset 0 0 0 5px rgba(146, 64, 14, 0.18);
}

.placed-token .object-icon.o-lantern {
  width: clamp(28px, 3.6vw, 45px);
  height: clamp(28px, 3.6vw, 45px);
}

.o-lantern::before {
  content: "";
  position: absolute;
  left: 25%;
  top: -13%;
  width: 50%;
  height: 22%;
  border: 3px solid #92400e;
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
}

.o-anchor {
  border-radius: 999px;
  border: 7px solid #0f766e;
  background: transparent;
}

.o-anchor::before {
  content: "";
  position: absolute;
  left: 43%;
  top: 32%;
  width: 14%;
  height: 68%;
  border-radius: 999px;
  background: #0f766e;
}

.o-anchor::after {
  content: "";
  position: absolute;
  left: 12%;
  bottom: -4%;
  width: 76%;
  height: 30%;
  border: 7px solid #0f766e;
  border-top: 0;
  border-radius: 0 0 999px 999px;
}

.hint-card p:last-child {
  margin: 8px 0 0;
  color: #243449;
  font-size: clamp(0.82rem, 1.5vw, 0.98rem);
  font-weight: 750;
  line-height: 1.38;
}

.actions-card {
  display: grid;
  gap: 10px;
}

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

.primary-action,
.secondary-action {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 16px;
  font-weight: 950;
}

.primary-action {
  color: white;
  background: linear-gradient(135deg, #2563eb, #0f766e);
  box-shadow: 0 12px 20px rgba(37, 99, 235, 0.22);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  filter: grayscale(0.5);
  opacity: 0.58;
  transform: none;
}

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

.secondary-action {
  border: 1px solid rgba(20, 33, 61, 0.14);
  color: #172033;
  background: #ffffff;
}

.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
}

.game-overlay.is-visible {
  display: grid;
}

.overlay-card {
  width: min(560px, 94vw);
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: var(--shadow);
  text-align: center;
}

.overlay-card h2 {
  margin: 6px 0 10px;
  color: #14213d;
  font-size: clamp(1.75rem, 5vw, 3.1rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.overlay-card p {
  margin: 0 auto 18px;
  max-width: 44rem;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}

.menu-art {
  --art-size: clamp(54px, 12vw, 78px);
  display: grid;
  grid-template-columns: repeat(4, var(--art-size));
  justify-content: center;
  gap: 10px;
  margin: 0 auto 18px;
}

.art-cell {
  display: block;
  width: var(--art-size);
  height: var(--art-size);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: inset 0 0 0 2px rgba(20, 33, 61, 0.11), 0 10px 20px rgba(27, 38, 59, 0.12);
}

.art-cell.a {
  background:
    radial-gradient(circle at 50% 50%, #fbbf24 0 26%, transparent 27%),
    #fff7ed;
}

.art-cell.b {
  background:
    radial-gradient(circle at 50% 55%, #60a5fa 0 30%, transparent 31%),
    #eff6ff;
}

.art-cell.empty {
  border: 2px dashed rgba(37, 99, 235, 0.45);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(250, 204, 21, 0.12)),
    #ffffff;
  animation: emptyPulse 1.2s ease-in-out infinite;
}

.wide {
  width: min(280px, 100%);
}

.overlay-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid rgba(20, 33, 61, 0.14);
  border-radius: 14px;
  background: #f8fafc;
}

.result-labels,
.result-values {
  display: contents;
}

.result-grid span,
.result-grid strong {
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 8px 6px;
  border-left: 1px solid rgba(20, 33, 61, 0.1);
  text-align: center;
}

.result-grid span:first-child,
.result-grid strong:first-child {
  border-left: 0;
}

.result-grid strong {
  border-top: 1px solid rgba(20, 33, 61, 0.1);
}

.result-grid span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.15;
  text-transform: uppercase;
}

.result-grid strong {
  color: #14213d;
  font-size: clamp(1.05rem, 3.2vw, 1.45rem);
  line-height: 1;
}

.drag-ghost {
  position: fixed;
  z-index: 80;
  width: 58px;
  height: 58px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0.94;
}

.drag-ghost .object-token {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 5px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 24px rgba(27, 38, 59, 0.16);
}

.drag-ghost .object-icon {
  width: 32px;
  height: 32px;
  margin: auto;
}

.drag-ghost .o-flower {
  width: 23px;
  height: 23px;
  box-shadow:
    0 -8px 0 #f472b6,
    8px 0 0 #fb7185,
    0 8px 0 #f472b6,
    -8px 0 0 #fb7185;
}

.drag-ghost .o-cloud {
  width: 36px;
  height: 23px;
}

.rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.16), rgba(22, 163, 74, 0.16)),
    #f8fbff;
}

.rotate-card {
  width: min(330px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  overflow: hidden;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: var(--shadow);
  text-align: center;
}

.rotate-card strong {
  display: block;
  margin: 12px 0 6px;
  color: #14213d;
  font-size: 1.45rem;
}

.rotate-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 750;
  line-height: 1.4;
  overflow-wrap: break-word;
}

.rotate-phone {
  position: relative;
  width: 70px;
  height: 112px;
  margin: 0 auto;
  border: 7px solid #1f2937;
  border-radius: 22px;
  animation: rotatePhone 1.8s ease-in-out infinite;
}

.rotate-phone span {
  position: absolute;
  left: 50%;
  bottom: 7px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #1f2937;
  transform: translateX(-50%);
}

.noscript-card {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 120;
  padding: 14px 16px;
  border-radius: 16px;
  color: #991b1b;
  background: #fee2e2;
  font-weight: 800;
}

@media (max-width: 360px) {
  .brand-loader {
    padding-inline: 12px;
  }

  .loader-brand {
    font-size: clamp(24px, 9.6vw, 34px);
  }
}

@keyframes brandLetterIn {
  0% {
    opacity: 0;
    transform: translateX(-28px) translateY(8px) rotate(-5deg);
  }
  68% {
    opacity: 1;
    transform: translateX(3px) translateY(0) rotate(1deg);
  }
  100% {
    opacity: 1;
    transform: translateX(0) translateY(0) rotate(0);
  }
}

@keyframes loaderSweep {
  0%,
  18% {
    transform: rotate(-8deg) translateX(-62%);
  }
  62%,
  100% {
    transform: rotate(-8deg) translateX(62%);
  }
}

@keyframes emptyPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.94);
  }
}

@keyframes rotatePhone {
  0%,
  25% {
    transform: rotate(0deg);
  }
  60%,
  100% {
    transform: rotate(90deg);
  }
}

@media (max-width: 920px) and (min-height: 600px) {
  .pattern-game {
    overflow: auto;
    height: auto;
    min-height: 100svh;
  }

  body {
    overflow: auto;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr) minmax(310px, 0.62fr);
  }

  .control-panel {
    grid-template-columns: none;
    grid-template-rows: auto auto auto;
    align-content: start;
  }

  .choice-card {
    grid-row: auto;
  }
}

@media (max-width: 680px) {
  .game-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .hud {
    grid-column: 1 / -1;
    width: 100%;
  }

  .hud-item {
    flex: 1;
  }

  .control-panel,
  .secondary-grid,
  .overlay-actions,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .control-panel {
    grid-template-columns: none;
    grid-template-rows: auto auto auto;
    align-content: start;
  }
}

@media (orientation: portrait) and (max-width: 760px) {
  html,
  body {
    overflow: hidden;
  }

  .pattern-game {
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
  }

  .rotate-overlay {
    display: grid;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .pattern-game {
    padding: 8px;
    gap: 8px;
  }

  .game-topbar {
    padding: 8px;
  }

  .game-title span,
  .small-label,
  .overlay-kicker {
    font-size: 0.61rem;
  }

  .game-title strong {
    font-size: 1rem;
  }

  .hud-item {
    min-width: 56px;
    padding: 6px 8px;
  }

  .finish-btn,
  .primary-action,
  .secondary-action,
  .icon-action {
    min-height: 40px;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.62fr);
    gap: 8px;
  }

  .control-panel {
    min-width: 300px;
    grid-template-rows: auto auto;
    align-content: start;
  }

  .hint-card {
    display: none;
  }

  .pattern-panel,
  .choice-card,
  .hint-card,
  .actions-card {
    border-radius: 16px;
  }

  .pattern-panel,
  .choice-card,
  .hint-card,
  .actions-card {
    padding: 9px;
  }

  .panel-head h2,
  .choice-head h2 {
    font-size: 1rem;
  }

  .pattern-board {
    padding: 8px;
  }

  .pattern-slot {
    border-radius: 12px;
  }

  .choice-tray {
    grid-template-columns: repeat(4, 46px);
    gap: 5px;
    margin-top: 8px;
  }

  .choice-card {
    min-height: 112px;
  }

  .actions-card {
    align-self: start;
  }

  .object-token {
    min-height: 48px;
    padding: 5px;
    border-radius: 12px;
  }

  .choice-tray .object-token {
    width: 46px;
  }

  .object-icon,
  .placed-token .object-icon {
    width: 30px;
    height: 30px;
  }

  .choice-tray .o-flower {
    width: 26px;
    height: 26px;
    box-shadow:
      0 -7px 0 #f472b6,
      7px 0 0 #fb7185,
      0 7px 0 #f472b6,
      -7px 0 0 #fb7185;
  }

  .choice-tray .o-kite::after {
    height: 9px;
  }

  .hint-card p:last-child,
  .feedback {
    font-size: 0.72rem;
  }

  .feedback {
    min-height: 38px;
    padding: 8px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
