/* Direction: sunny cartoon arcade — sky blue, cream panels, chunky purple outlines, tangerine buttons */
/* Completed by the platform from the short form: both modes, every
   palette token, each text-on-ground pair at its floor. To restyle, write the
   short form again (the decisions in one :root) and it is completed again. */

:root {
  --canvas: #cfeeff;
  --surface: #fff6df;
  --surface-2: #c6e3f3;
  --border: #b7cfdc;
  --border-strong: #9cacb5;
  --ink: #2a1f4d;
  --muted: #5b617d;
  --accent: #ff7a2f;
  --accent-hover: #d96828;
  --accent-ink: #241107;
  --accent-text: #a8400b;
  --accent-strong: #9b4a1d;
  --accent-soft: #d6dee2;
  --accent-border: #e5baa1;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #b9e1e8;
  --success-strong: #116d34;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #ccdbe1;
  --warning-strong: #994607;
  --danger: #b91c1c;
  --danger-ink: #ffffff;
  --danger-soft: #ccd5e4;
  --danger-strong: #aa1a1a;
  --chart-1: #d65f15;
  --chart-2: #8b8418;
  --chart-3: #0b8461;
  --chart-4: #148db3;
  --chart-5: #6858c8;
  --chart-6: #d15ba1;

  --font-display: "Lilita One", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
  --radius-card: 24px;
  --radius-btn: 18px;
  --x-edge: #2a1f4d;
  --x-panel: #fff6df;
  --x-panel-2: #ffe8b0;
  --x-gold: #ffc21a;
  --x-gold-dim: #d9c9a3;
  --x-green: #2f9e44;
  --x-red: #d93636;
  --x-blue: #2f6fe0;
  --x-purple: #8247d6;
  --x-spark: #ff6a2b;
  --x-boulder: #3f6fd1;
  --x-dash: #ffd23a;
  --x-bubble: #a56be0;
  --x-sky-top: #5cc2ff;
  --x-sky-bottom: #d9f4ff;
  --x-on-dark: #fff6df;
  --font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans: "Nunito", system-ui, sans-serif;
  --display-weight: 700;
  --display-tracking: -0.02em;
  --eyebrow-tracking: 0.08em;
}

html[data-theme="dark"] {
  --canvas: #100803;
  --surface: #28211c;
  --surface-2: #1c1410;
  --border: #312b26;
  --border-strong: #58524f;
  --ink: #cfeeff;
  --muted: #83929a;
  --accent: #ff7a2f;
  --accent-hover: #ff8e4e;
  --accent-ink: #241107;
  --accent-text: #ff7a2f;
  --accent-strong: #ff7a2f;
  --accent-soft: #45210d;
  --accent-border: #7c3b17;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #112210;
  --success-strong: #499c68;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #341904;
  --warning-strong: #c57a40;
  --danger: #b91c1c;
  --danger-ink: #ffffff;
  --danger-soft: #350c09;
  --danger-strong: #d16969;
  --chart-1: #ff7a2f;
  --chart-2: #cdc313;
  --chart-3: #12a67b;
  --chart-4: #48cdfc;
  --chart-5: #8474f2;
  --chart-6: #fe97d1;
}

/* Critter Clash — interface styling (the game art itself is drawn on canvas) */
html, body { overscroll-behavior: none; height: 100%; overflow: hidden; -webkit-tap-highlight-color: transparent; }

.cc-root {
  position: fixed; inset: 0; width: 100%; height: 100dvh; overflow: hidden;
  background: linear-gradient(180deg, var(--x-sky-top), var(--x-sky-bottom));
  font-family: var(--font-body); color: var(--ink);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none;
}
.cc-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

.cc-screen {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow-y: auto; z-index: 20;
}
.cc-screen[hidden], .cc-hud[hidden], .cc-tut[hidden], .hud-combo[hidden] { display: none; }
.cc-dim { background: color-mix(in srgb, var(--x-edge) 45%, transparent); }

.cc-panel {
  width: min(92vw, 440px); max-height: 94dvh; overflow-y: auto;
  background: var(--x-panel); border: 5px solid var(--x-edge); border-radius: 30px;
  box-shadow: 0 10px 0 var(--x-edge); padding: 22px 22px 24px; text-align: center;
  animation: cc-pop .35s cubic-bezier(.2,1.4,.4,1) both;
}
.cc-panel-wide { width: min(94vw, 760px); }
.cc-h2 { font-family: var(--font-display); font-size: clamp(30px, 6vw, 44px); letter-spacing: .02em; line-height: 1; margin-bottom: 14px; color: var(--x-edge); }
.cc-win-title { color: var(--accent-text); }
.cc-lose-title { color: var(--x-red); }
.cc-p { font-weight: 800; margin: 6px 0; color: var(--x-edge); }
.cc-score { font-family: var(--font-display); font-size: 30px; margin: 8px 0; color: var(--x-edge); }
.cc-best { color: var(--accent-text); min-height: 1.3em; }
.cc-row { display: flex; flex-direction: column; gap: 10px; justify-content: center; margin-top: 16px; }
@media (min-width: 640px) { .cc-row { flex-direction: row; } }
.cc-stack { display: flex; flex-direction: column; gap: 12px; }

.cc-btn {
  --c: var(--accent-text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 10px 22px; border: 4px solid var(--x-edge); border-radius: 18px;
  background: var(--c); color: var(--x-on-dark); font-family: var(--font-display); font-size: 20px; letter-spacing: .04em;
  text-shadow: 0 2px 0 color-mix(in srgb, var(--x-edge) 55%, transparent);
  box-shadow: 0 6px 0 var(--x-edge); cursor: pointer; touch-action: manipulation;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.cc-btn:hover { transform: translateY(-3px); box-shadow: 0 9px 0 var(--x-edge); filter: brightness(1.1); }
.cc-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--x-edge); }
.cc-btn:focus-visible, .cc-toggle:focus-visible, .level-card:focus-visible, .hud-ability:focus-visible { outline: 4px solid var(--x-gold); outline-offset: 3px; }
.cc-btn-lg { min-height: 62px; font-size: 26px; width: 100%; }
.cc-btn-sm { min-height: 40px; padding: 4px 14px; font-size: 16px; border-width: 3px; box-shadow: 0 4px 0 var(--x-edge); }
.cc-btn-round { width: 56px; height: 56px; min-height: 56px; padding: 0; border-radius: 50%; }
.cc-btn .icon { width: 1.1em; height: 1.1em; }

.cc-toggle {
  --c: var(--x-green); min-width: 84px; min-height: 48px; padding: 6px 16px; border: 4px solid var(--x-edge); border-radius: 16px;
  background: var(--c); color: var(--x-on-dark); font-family: var(--font-display); font-size: 18px; box-shadow: 0 5px 0 var(--x-edge);
  cursor: pointer; transition: transform .12s, box-shadow .12s; touch-action: manipulation;
}
.cc-toggle[aria-pressed="false"] { background: var(--x-gold-dim); color: var(--x-edge); }
.cc-toggle:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--x-edge); }
.cc-set { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; font-weight: 900; font-size: 18px; color: var(--x-edge); border-bottom: 3px dashed color-mix(in srgb, var(--x-edge) 25%, transparent); }
.cc-set span { display: inline-flex; align-items: center; gap: 8px; }
.cc-set .icon { width: 22px; height: 22px; }

.cc-menu { align-items: center; justify-content: center; }
.cc-menu-inner { width: min(92vw, 380px); margin: auto; text-align: center; }
.cc-title { display: flex; flex-direction: column; font-family: var(--font-display); font-weight: 400; line-height: .88; font-size: clamp(60px, 15vw, 118px); color: var(--x-gold);
  -webkit-text-stroke: 7px var(--x-edge); paint-order: stroke fill; text-shadow: 0 8px 0 var(--x-edge); transform: rotate(-3deg); animation: cc-bob 3s ease-in-out infinite; }
.cc-title span:last-child { color: var(--accent); margin-left: .4em; }
.cc-tag { font-weight: 900; font-size: 18px; margin: 18px 0 20px; color: var(--x-edge); }
.cc-menu-btns { display: flex; flex-direction: column; gap: 12px; }
@media (max-height: 560px) {
  .cc-menu-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; width: min(94vw, 760px); align-items: center; }
  .cc-title { font-size: clamp(48px, 14vh, 84px); }
  .cc-tag { display: none; }
  .cc-menu-btns { gap: 8px; }
  .cc-btn-lg { min-height: 50px; font-size: 21px; }
  .cc-panel { padding: 14px; }
  .cc-h2 { margin-bottom: 8px; }
  .cc-grid { max-height: 44dvh; }
}

.cc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; max-height: 56dvh; overflow-y: auto; padding: 6px 6px 12px; }
.level-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px 8px; min-height: 96px;
  background: var(--x-panel-2); border: 4px solid var(--x-edge); border-radius: 20px; box-shadow: 0 5px 0 var(--x-edge);
  font-family: var(--font-display); cursor: pointer; transition: transform .12s, box-shadow .12s; touch-action: manipulation; color: var(--x-edge);
}
.level-card:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 8px 0 var(--x-edge); }
.level-card:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--x-edge); }
.level-card:disabled { background: var(--x-gold-dim); cursor: not-allowed; opacity: .75; }
.level-card .ln { font-size: 30px; line-height: 1; }
.level-card .ls { font-size: 12px; font-family: var(--font-body); font-weight: 900; letter-spacing: .06em; }
.level-card .lb { font-size: 12px; font-family: var(--font-body); font-weight: 800; }
.level-card .icon { width: 28px; height: 28px; }
.mini-stars { font-size: 20px; letter-spacing: 2px; color: var(--x-gold-dim); -webkit-text-stroke: 1px var(--x-edge); }
.mini-stars .on { color: var(--x-gold); }

.cc-how { text-align: left; margin: 4px 0 14px; padding-left: 22px; font-weight: 800; display: grid; gap: 8px; list-style: decimal; color: var(--x-edge); }
.cc-crit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 640px) { .cc-crit-grid { grid-template-columns: repeat(4, 1fr); } }
.cc-crit { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px; background: var(--x-panel-2); border: 3px solid var(--x-edge); border-radius: 16px; font-size: 14px; font-weight: 800; color: var(--x-edge); }
.cc-crit b { font-family: var(--font-display); font-size: 20px; font-weight: 400; }

.pip { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--x-edge); background: var(--x-gold-dim); }
.cr-spark { background: var(--x-spark); }
.cr-boulder { background: var(--x-boulder); border-radius: 8px; }
.cr-dash { background: var(--x-dash); border-radius: 50% 50% 50% 8px; }
.cr-bubble { background: var(--x-bubble); }
.pip.used { opacity: .3; filter: grayscale(.6); }
.pip.now { transform: scale(1.25); box-shadow: 0 0 0 3px var(--x-gold); }

.cc-hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.cc-hud > * { position: absolute; pointer-events: auto; }
.cc-chip { background: var(--x-panel); border: 4px solid var(--x-edge); border-radius: 18px; box-shadow: 0 5px 0 var(--x-edge); padding: 6px 14px; font-family: var(--font-display); color: var(--x-edge); }
.hud-score { top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); display: flex; flex-direction: column; line-height: 1; min-width: 130px; pointer-events: none; }
.hud-score b { font-size: 30px; font-weight: 400; }
.hud-score b.pop { animation: cc-score-pop .28s ease-out; }
.cc-chip-label { font-family: var(--font-body); font-weight: 900; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
.hud-level { top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); font-size: 24px; pointer-events: none; }
.hud-pause { top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); --c: var(--x-purple); }
.hud-combo { top: 92px; left: max(12px, env(safe-area-inset-left)); font-family: var(--font-display); font-size: 26px; color: var(--x-gold); -webkit-text-stroke: 5px var(--x-edge); paint-order: stroke fill; animation: cc-pop .3s both; pointer-events: none; }
.hud-creature { bottom: max(12px, env(safe-area-inset-bottom)); left: max(12px, env(safe-area-inset-left)); pointer-events: none; min-width: 170px; }
.hud-cname { font-size: 22px; line-height: 1; }
.hud-cabil { font-family: var(--font-body); font-weight: 900; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); margin: 2px 0 6px; }
.hud-queue { display: flex; gap: 6px; }

.hud-ability {
  --c: var(--x-gold); bottom: max(14px, env(safe-area-inset-bottom)); right: max(14px, env(safe-area-inset-right));
  width: 96px; height: 96px; border-radius: 50%; border: 5px solid var(--x-edge); background: var(--x-gold-dim); box-shadow: 0 7px 0 var(--x-edge);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-family: var(--font-display); color: var(--x-edge); cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .2s; touch-action: manipulation;
}
.hud-ability:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--x-edge); }
.ab-name { font-size: 15px; line-height: 1; text-align: center; padding: 0 4px; }
.ab-key { font-family: var(--font-body); font-weight: 900; font-size: 9px; letter-spacing: .04em; opacity: .75; }
.hud-ability.is-ready { background: var(--c); animation: cc-pulse 1s ease-in-out infinite; }
.hud-ability.is-used { opacity: .55; }
.hud-ability.k-spark { --c: var(--x-spark); }
.hud-ability.k-boulder { --c: var(--x-boulder); }
.hud-ability.k-dash { --c: var(--x-dash); }
.hud-ability.k-bubble { --c: var(--x-bubble); }
@media (max-width: 640px) { .hud-ability { width: 84px; height: 84px; } .hud-creature { min-width: 0; padding: 4px 10px; } .hud-level { font-size: 18px; } .hud-score { min-width: 100px; } .hud-score b { font-size: 24px; } }

.cc-tut { position: absolute; z-index: 12; top: 84px; left: 50%; transform: translateX(-50%); width: min(92vw, 520px); display: flex; align-items: center; gap: 12px;
  background: var(--x-panel); border: 4px solid var(--x-edge); border-radius: 22px; box-shadow: 0 6px 0 var(--x-edge); padding: 10px 14px; }
.cc-tut-step { font-family: var(--font-display); background: var(--accent-text); color: var(--x-on-dark); border: 3px solid var(--x-edge); border-radius: 12px; padding: 2px 10px; white-space: nowrap; }
.cc-tut-text { flex: 1; font-family: var(--font-display); font-size: 20px; line-height: 1.05; color: var(--x-edge); text-align: left; }
@media (max-width: 640px) { .cc-tut { top: 70px; } .cc-tut-text { font-size: 16px; } }

.cc-portrait { display: none; position: absolute; z-index: 15; left: 50%; bottom: 130px; transform: translateX(-50%); padding: 8px 14px; border-radius: 14px; background: var(--x-edge); color: var(--x-on-dark); font-weight: 900; font-size: 13px; text-align: center; width: max-content; max-width: 86vw; pointer-events: none; }
@media (orientation: portrait) and (max-width: 700px) { .cc-portrait { display: block; } }

.cc-stars { display: flex; justify-content: center; gap: 6px; font-size: 76px; line-height: 1; margin: 4px 0; }
.win-star { color: var(--x-gold-dim); -webkit-text-stroke: 4px var(--x-edge); paint-order: stroke fill; transform: scale(.7); }
.win-star.on { color: var(--x-gold); animation: cc-star .6s cubic-bezier(.2,1.6,.4,1) both; transform: none; }
.win-star:nth-child(2) { margin-top: -14px; }

@keyframes cc-pop { from { transform: scale(.82) translateY(14px); } to { transform: none; } }
@keyframes cc-bob { 0%, 100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(-1deg) translateY(-8px); } }
@keyframes cc-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes cc-star { from { transform: scale(2.6) rotate(-40deg); } to { transform: scale(1) rotate(0); } }
@keyframes cc-score-pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

html.reduced-motion .cc-title, html.reduced-motion .hud-ability.is-ready, html.reduced-motion .cc-panel, html.reduced-motion .win-star.on, html.reduced-motion .hud-score b.pop { animation: none; }
