/* Kitten Manor — design system
   ------------------------------------------------------------------------
   Casual-game chrome: chunky rounded plates, warm wood and cream, thick dark
   text outlines, and one accent green for anything you press. Colours are
   tokens so a level's theme can retint the panels without touching layout. */

:root {
  color-scheme: dark;

  --cream:        #fff4de;
  --cream-2:      #ffe8c2;
  --ink:          #4a2410;
  --ink-soft:     #7a4a28;

  --plate:        #d9482f;
  --plate-2:      #b93420;
  --plate-edge:   #8d2314;

  --hard:         #c4225c;
  --hard-2:       #980f45;
  --superhard:    #7b2ec4;
  --superhard-2:  #57179a;

  --green:        #57c93a;
  --green-2:      #3aa020;
  --green-edge:   #2b7a17;

  --gold:         #ffcf3d;
  --gold-2:       #f0a020;

  --violet:       #6a4fb6;
  --night:        #241a3d;

  --tile:         #b9c2e8;

  --radius-lg:    22px;
  --radius:       16px;
  --radius-sm:    11px;

  --shadow-plate: 0 10px 0 var(--plate-edge), 0 18px 32px rgba(20, 10, 40, 0.42);
  --shadow-soft:  0 8px 26px rgba(20, 10, 40, 0.38);

  --font: "Baloo 2", "Nunito", ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  font-family: var(--font);
  color: var(--cream);
  overscroll-behavior: none;
  touch-action: manipulation;
}

body { -webkit-user-select: none; user-select: none; }

#app { position: fixed; inset: 0; }

/* ── background ────────────────────────────────────────────────────────── */
#bg-layer { position: absolute; inset: 0; overflow: hidden; }
#bg-img {
  position: absolute; inset: -4%;
  background: #2b2350 center/cover no-repeat;
  filter: saturate(1.05) blur(2px);
  transform: scale(1.06);
  transition: opacity 0.5s ease, background-image 0.01s;
  opacity: 1;
}
#bg-img.swapping { opacity: 0; }
#bg-veil {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 62% 78% at 50% 46%, rgba(10, 6, 26, 0.10) 0%, rgba(10, 6, 26, 0.46) 72%, rgba(8, 4, 20, 0.72) 100%),
    linear-gradient(180deg, rgba(10, 6, 26, 0.34) 0%, rgba(10, 6, 26, 0) 26%);
}

/* ── screens ───────────────────────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: none;
  opacity: 0;
  transition: opacity 0.28s ease;
}
.screen.is-active { display: flex; opacity: 1; }

/* ── buttons ───────────────────────────────────────────────────────────── */
.btn {
  position: relative;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.01em;
  padding: 12px 26px 15px;
  border-radius: 999px;
  background: linear-gradient(180deg, #6fdc4d 0%, var(--green) 46%, var(--green-2) 100%);
  box-shadow: 0 5px 0 var(--green-edge), 0 10px 20px rgba(15, 8, 30, 0.4);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
  transition: transform 0.09s ease, box-shadow 0.09s ease, filter 0.15s ease;
}
.btn::after {
  content: '';
  position: absolute; inset: 3px 8px auto; height: 38%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--green-edge), 0 4px 10px rgba(15, 8, 30, 0.4); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn[disabled] { filter: grayscale(0.75) brightness(0.8); cursor: not-allowed; }
.btn-lg  { font-size: 22px; padding: 14px 34px 17px; }
.btn-xl  { font-size: 27px; padding: 15px 46px 19px; }
.btn-sm  { font-size: 15px; padding: 8px 18px 10px; box-shadow: 0 4px 0 var(--green-edge); }
.btn-red {
  background: linear-gradient(180deg, #ff7a5e 0%, var(--plate) 46%, var(--plate-2) 100%);
  box-shadow: 0 5px 0 var(--plate-edge), 0 10px 20px rgba(15, 8, 30, 0.4);
}
.btn-red:active { box-shadow: 0 1px 0 var(--plate-edge); }
.btn-gold {
  background: linear-gradient(180deg, #ffe9a0 0%, var(--gold) 46%, var(--gold-2) 100%);
  box-shadow: 0 5px 0 #b87608, 0 10px 20px rgba(15, 8, 30, 0.4);
  color: #5a3405; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn-ghost {
  background: rgba(255, 244, 222, 0.14);
  box-shadow: inset 0 0 0 2px rgba(255, 244, 222, 0.34);
  color: var(--cream);
}
.btn-ghost:active { transform: translateY(2px); box-shadow: inset 0 0 0 2px rgba(255, 244, 222, 0.34); }

.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 20px; line-height: 1;
  border: 0; cursor: pointer;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 244, 222, 0.22), rgba(255, 244, 222, 0.08));
  box-shadow: inset 0 0 0 2px rgba(255, 244, 222, 0.28), 0 4px 12px rgba(10, 6, 24, 0.35);
  color: var(--cream);
  transition: transform 0.09s ease;
}
.icon-btn:active { transform: scale(0.93); }
.icon-btn-round { border-radius: 50%; }

/* ── loading ───────────────────────────────────────────────────────────── */
#screen-loading { align-items: center; justify-content: center; }
.boot { text-align: center; padding: 24px; }
.boot-logo {
  font-size: clamp(44px, 9vw, 92px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.02em;
  filter: drop-shadow(0 8px 0 rgba(90, 30, 10, 0.55)) drop-shadow(0 18px 30px rgba(0, 0, 0, 0.5));
}
.boot-logo-a { color: var(--gold); }
.boot-logo-b { color: #fff; margin-left: 0.16em; }
.boot-tag { margin: 14px 0 30px; font-size: clamp(14px, 2.2vw, 19px); font-weight: 600; color: #efdcc0; opacity: 0.9; }
.boot-bar {
  width: min(340px, 74vw); height: 16px; margin: 0 auto;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 244, 222, 0.18);
  overflow: hidden;
}
.boot-bar i {
  display: block; height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), #9df06f);
  transition: width 0.2s ease;
}
#boot-play { margin-top: 26px; }

/* ── top bar ───────────────────────────────────────────────────────────── */
.topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  z-index: 5;
}
.topbar-mid { display: flex; gap: 8px; margin-left: auto; }
.topbar-right { display: flex; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 15px 8px 11px;
  border: 0; font: inherit; font-weight: 800; font-size: 17px;
  color: var(--ink);
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
  border-radius: 999px;
  box-shadow: 0 4px 0 rgba(150, 96, 40, 0.55), 0 8px 18px rgba(10, 6, 24, 0.3);
  cursor: default;
}
.chip-lives { cursor: pointer; }
.chip-ico { font-size: 18px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25)); }
.chip small { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-left: 2px; }

/* ── map ───────────────────────────────────────────────────────────────── */
#screen-map { flex-direction: column; }
.map-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 16px;
  padding: 76px 16px 12px;
  min-height: 0;
}

.manor-card, .level-card {
  background: linear-gradient(180deg, rgba(46, 32, 74, 0.86), rgba(30, 20, 52, 0.92));
  border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 3px rgba(255, 244, 222, 0.16), var(--shadow-soft);
  padding: 16px;
  min-height: 0;
  display: flex; flex-direction: column;
}

.manor-head { display: flex; gap: 14px; align-items: center; }
.manor-cat {
  width: clamp(64px, 9vw, 108px); height: auto;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
  animation: bob 4.2s ease-in-out infinite;
}
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1.2deg); } 50% { transform: translateY(-6px) rotate(1.2deg); } }
.manor-title { min-width: 0; }
.manor-title h1 { margin: 0; font-size: clamp(20px, 3vw, 30px); font-weight: 800; color: var(--gold); text-shadow: 0 3px 0 rgba(90, 40, 10, 0.5); }
.manor-title p { margin: 2px 0 8px; font-size: 14px; color: #e6d6bd; opacity: 0.86; }

.progress {
  position: relative; height: 20px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.progress i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.progress span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.tasks { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 9px; overflow-y: auto; }
.task {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(150, 96, 40, 0.45);
}
.task-ico { font-size: 24px; width: 32px; text-align: center; }
.task-name { flex: 1; font-weight: 700; font-size: 15px; }
.task.is-done { filter: saturate(0.5) brightness(0.94); }
.task.is-done .task-name { text-decoration: line-through; opacity: 0.6; }
.task-cost { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; }

.level-card-h { margin: 0 0 10px; font-size: 17px; color: #e9d8bd; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.8; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; overflow-y: auto; padding-right: 4px; }
.lvl {
  position: relative;
  aspect-ratio: 1;
  border: 0; cursor: pointer; font: inherit; font-weight: 800; font-size: 17px;
  border-radius: var(--radius-sm);
  color: #fff;
  background: linear-gradient(180deg, #ff7a5e, var(--plate) 50%, var(--plate-2));
  box-shadow: 0 4px 0 var(--plate-edge);
  display: grid; place-items: center;
  transition: transform 0.1s ease;
}
.lvl:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--plate-edge); }
.lvl.t-hard { background: linear-gradient(180deg, #f0517f, var(--hard) 50%, var(--hard-2)); box-shadow: 0 4px 0 #740a34; }
.lvl.t-superhard { background: linear-gradient(180deg, #b06ff0 0%, var(--superhard) 50%, var(--superhard-2)); box-shadow: 0 4px 0 #3d0f75; }
.lvl.is-locked { background: linear-gradient(180deg, #5b5470, #3d3752); box-shadow: 0 4px 0 #2a2439; color: #9d95b3; cursor: not-allowed; }
.lvl.is-next { animation: nextPulse 1.6s ease-in-out infinite; }
@keyframes nextPulse { 0%, 100% { box-shadow: 0 4px 0 var(--plate-edge), 0 0 0 0 rgba(255, 207, 61, 0.7); } 50% { box-shadow: 0 4px 0 var(--plate-edge), 0 0 0 8px rgba(255, 207, 61, 0); } }
.lvl-stars { position: absolute; bottom: -3px; left: 0; right: 0; font-size: 9px; letter-spacing: -1px; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6); }

.map-foot {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  padding: 6px 16px max(14px, env(safe-area-inset-bottom));
}
.next-info { text-align: right; line-height: 1.15; }
.next-label { display: block; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.6; }
.next-info strong { font-size: 18px; color: var(--cream); }

/* ── level HUD ─────────────────────────────────────────────────────────── */
#screen-level { align-items: stretch; min-height: 0; }

.hud {
  flex: 0 0 auto;
  min-height: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 8px;
  z-index: 3;
}
.hud-left { width: clamp(112px, 15vw, 168px); }
.hud-right { width: clamp(78px, 9vw, 104px); justify-content: center; gap: 12px; }

.portrait {
  width: clamp(60px, 7.5vw, 88px); aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #7f5fd0, #40266f);
  box-shadow: 0 0 0 5px var(--cream-2), 0 8px 18px rgba(0, 0, 0, 0.45);
  display: grid; place-items: center;
  overflow: hidden;
  margin-bottom: -14px; z-index: 2;
}
.portrait img { width: 116%; height: auto; transform: translateY(6%); }

.hud-body {
  width: 100%;
  flex: 0 1 auto;
  min-height: 0;
  padding: 22px 10px 12px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--plate) 0%, var(--plate-2) 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 244, 222, 0.2), var(--shadow-soft);
  display: flex; flex-direction: column; gap: 8px;
}
body.type-hard .hud-body { background: linear-gradient(180deg, var(--hard) 0%, var(--hard-2) 100%); }
body.type-superhard .hud-body { background: linear-gradient(180deg, var(--superhard) 0%, var(--superhard-2) 100%); }

.luck-badge {
  align-self: center;
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 800;
  padding: 3px 10px 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 0 0 2px rgba(255, 244, 222, 0.2);
  cursor: help;
  white-space: nowrap;
}

.goals { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; overflow-y: auto; }
.goal {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(150, 96, 40, 0.4);
  font-weight: 800; font-size: 17px;
}
.goal-ico { width: 30px; height: 30px; display: grid; place-items: center; font-size: 20px; }
.goal-ico img { width: 30px; height: 30px; }
.goal-n { margin-left: auto; padding-right: 4px; min-width: 1.6em; text-align: right; }
.goal.is-done .goal-n { color: var(--green-2); }
.goal.bump { animation: goalBump 0.32s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes goalBump { 0% { transform: scale(1); } 40% { transform: scale(1.11); } 100% { transform: scale(1); } }

.moves {
  margin-top: auto;
  display: flex; flex-direction: column; align-items: center;
  min-width: 92px;
  padding: 4px 18px 6px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(150, 96, 40, 0.5), var(--shadow-soft);
}
.moves-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.65; font-weight: 700; }
.moves strong { font-size: 34px; line-height: 1; font-weight: 800; }
.moves.low strong { color: var(--plate-2); }
.moves.bump { animation: goalBump 0.28s ease; }

/* The canvas is absolutely positioned so its size comes from the wrapper, not
   from its own width/height attributes. With an auto-sized grid track the
   attributes feed back into layout and the board grows a little every resize
   until it runs off the screen. */
.board-wrap { flex: 1 1 auto; position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#board-overlay { position: absolute; inset: 0; pointer-events: none; }

.booster-rail {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 9px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--plate) 0%, var(--plate-2) 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 244, 222, 0.2), var(--shadow-soft);
}
body.type-hard .booster-rail { background: linear-gradient(180deg, var(--hard) 0%, var(--hard-2) 100%); }
body.type-superhard .booster-rail { background: linear-gradient(180deg, var(--superhard) 0%, var(--superhard-2) 100%); }

.booster {
  position: relative;
  width: clamp(46px, 5.4vw, 62px); aspect-ratio: 1;
  border: 0; cursor: pointer;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, #8fd6ff, #2f7fd0 78%);
  box-shadow: 0 0 0 4px var(--cream-2), 0 5px 12px rgba(0, 0, 0, 0.4);
  display: grid; place-items: center;
  font-size: clamp(20px, 2.6vw, 27px);
  transition: transform 0.1s ease;
}
.booster:active { transform: scale(0.92); }
.booster.is-armed { box-shadow: 0 0 0 4px var(--gold), 0 0 22px 4px rgba(255, 207, 61, 0.6); animation: armed 1s ease-in-out infinite; }
@keyframes armed { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.booster.is-empty { filter: saturate(0.35) brightness(0.72); }
.booster-n {
  position: absolute; right: -5px; bottom: -5px;
  min-width: 22px; height: 22px; padding: 0 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff6a4d, #d3301a);
  box-shadow: 0 0 0 2px #fff4de;
  font-size: 12px; font-weight: 800; color: #fff;
  display: grid; place-items: center;
}
.booster.is-empty .booster-n { background: linear-gradient(180deg, #6fdc4d, var(--green-2)); }

/* ── dialogs ───────────────────────────────────────────────────────────── */
#overlays { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.veil {
  position: absolute; inset: 0;
  background: rgba(12, 6, 26, 0.72);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 16px;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.2s ease;
  overflow: auto;
}
.veil.in { opacity: 1; }

.dlg {
  position: relative;
  width: min(460px, 94vw);
  padding: 18px;
  border-radius: 28px;
  background: linear-gradient(180deg, var(--plate) 0%, var(--plate-2) 100%);
  box-shadow: inset 0 0 0 4px rgba(255, 244, 222, 0.9), 0 22px 50px rgba(0, 0, 0, 0.55);
  text-align: center;
  transform: scale(0.86) translateY(14px);
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.veil.in .dlg { transform: none; }
.dlg.wide { width: min(660px, 96vw); }
.dlg.d-hard { background: linear-gradient(180deg, var(--hard) 0%, var(--hard-2) 100%); }
.dlg.d-superhard { background: linear-gradient(180deg, var(--superhard) 0%, var(--superhard-2) 100%); }
.dlg.d-plain { background: linear-gradient(180deg, #46356f 0%, #2b1f47 100%); }

.dlg-banner {
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  padding: 6px 26px 8px;
  border-radius: 999px;
  font-size: 19px; font-weight: 800; white-space: nowrap;
  background: linear-gradient(180deg, #ffe9a0, var(--gold) 60%, var(--gold-2));
  color: #5a3405;
  box-shadow: 0 0 0 4px rgba(255, 244, 222, 0.9), 0 6px 14px rgba(0, 0, 0, 0.4);
}
.dlg-x {
  position: absolute; top: 10px; right: 12px;
  width: 34px; height: 34px;
  border: 0; cursor: pointer; border-radius: 50%;
  background: rgba(0, 0, 0, 0.24);
  color: #fff; font-size: 18px; font-weight: 800;
  display: grid; place-items: center;
}
.dlg h2 { margin: 12px 0 4px; font-size: 27px; font-weight: 800; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.28); }
.dlg h3 { margin: 14px 0 6px; font-size: 17px; color: var(--gold); }
.dlg p { margin: 6px 0; font-size: 15px; color: #f7e6cd; line-height: 1.45; }
.dlg .muted { opacity: 0.72; font-size: 13px; }
.dlg-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

.pick-row { display: flex; gap: 12px; justify-content: center; margin: 12px 0 4px; flex-wrap: wrap; }
.pick {
  position: relative;
  width: 86px; padding: 8px 4px 10px;
  border: 0; cursor: pointer;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 244, 222, 0.94), rgba(255, 232, 194, 0.9));
  box-shadow: 0 4px 0 rgba(120, 74, 30, 0.5);
  color: var(--ink);
  transition: transform 0.1s ease;
}
.pick img { width: 52px; height: 52px; display: block; margin: 0 auto; }
/* goalIcon() is sized for the HUD; inside a pick card it needs the big box or
   the 52px sprite overflows the 30px slot and lands on top of the label */
.pick .goal-ico { width: 52px; height: 52px; margin: 0 auto; }
.pick .goal-ico img { width: 52px; height: 52px; }
.pick .goal-ico > span { width: 40px !important; height: 40px !important; border-radius: 10px !important; }
.pick .goal-ico { font-size: 38px; }
.pick-ico { font-size: 34px; line-height: 52px; }
.pick-name { display: block; font-size: 11px; font-weight: 800; margin-top: 2px; }
.pick-n { display: block; font-size: 12px; font-weight: 800; color: var(--ink-soft); }
.pick.on { box-shadow: 0 0 0 4px var(--green), 0 4px 0 rgba(120, 74, 30, 0.5); transform: translateY(-3px); }
.pick.off { filter: grayscale(0.7) brightness(0.9); }
.pick:active { transform: translateY(2px); }

.stat-row { display: flex; gap: 18px; justify-content: center; margin: 14px 0 4px; }
.stat { text-align: center; }
.stat b { display: block; font-size: 26px; color: #fff; }
.stat span { font-size: 12px; opacity: 0.8; letter-spacing: 0.05em; text-transform: uppercase; }

.stars-row { display: flex; gap: 8px; justify-content: center; margin: 6px 0 2px; font-size: 44px; }
.stars-row i {
  font-style: normal;
  color: #4b4468;
  transform: scale(0.8);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.3s ease, text-shadow 0.3s ease;
}
.stars-row i.on {
  color: var(--gold);
  transform: scale(1.06);
  text-shadow: 0 0 18px rgba(255, 207, 61, 0.75), 0 3px 0 rgba(140, 80, 10, 0.5);
}

.help-grid { display: grid; gap: 10px; text-align: left; margin-top: 10px; }
.help-row {
  display: flex; gap: 12px; align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
}
.help-row img { width: 42px; height: 42px; flex: 0 0 auto; }
.help-ico { width: 42px; text-align: center; font-size: 28px; flex: 0 0 auto; }
.help-row b { color: var(--gold); display: block; font-size: 15px; }
.help-row small { font-size: 13px; color: #f0dfc6; opacity: 0.9; line-height: 1.35; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 10px; margin-top: 10px; }
.shop-item {
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.22);
  text-align: center;
}
.shop-item img { width: 48px; height: 48px; }
.shop-ico { font-size: 34px; }
.shop-item b { display: block; font-size: 14px; margin: 2px 0; }
.shop-item small { display: block; font-size: 11px; opacity: 0.75; min-height: 2.4em; line-height: 1.2; }

.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 4px; border-bottom: 1px solid rgba(255, 244, 222, 0.14); }
.set-row:last-of-type { border-bottom: 0; }
.set-row span { font-weight: 700; }
.toggle {
  position: relative; width: 58px; height: 30px;
  border: 0; cursor: pointer; border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
  transition: background 0.2s ease;
}
.toggle i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #e6d6bd; transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }
.toggle.on { background: linear-gradient(180deg, #6fdc4d, var(--green-2)); }
.toggle.on i { transform: translateX(28px); background: #fff; }

/* ── floating move-grant badge ─────────────────────────────────────────── */
.grant {
  position: absolute;
  padding: 6px 16px 8px;
  border-radius: 999px;
  font-size: 20px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #6fdc4d, var(--green-2));
  box-shadow: 0 0 0 3px #fff4de, 0 8px 18px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 30;
}

/* ── toast ─────────────────────────────────────────────────────────────── */
#toast {
  position: absolute; left: 50%; bottom: 8%;
  transform: translate(-50%, 20px);
  padding: 10px 20px 12px;
  border-radius: 999px;
  background: rgba(20, 10, 40, 0.9);
  box-shadow: inset 0 0 0 2px rgba(255, 244, 222, 0.3);
  font-weight: 700; font-size: 15px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 40;
  max-width: 80vw; text-align: center;
}
#toast.in { opacity: 1; transform: translate(-50%, 0); }

/* ── portrait / small screens ──────────────────────────────────────────── */
@media (orientation: portrait), (max-width: 760px) {
  #screen-level { flex-direction: column; }
  .hud-left, .hud-right { width: 100%; flex-direction: row; align-items: center; gap: 10px; padding: 8px 10px; }
  .hud-left { padding-top: max(8px, env(safe-area-inset-top)); }
  .portrait { margin: 0; flex: 0 0 auto; width: 52px; box-shadow: 0 0 0 4px var(--cream-2); }
  /* min-width:0 is what keeps the scrolling goal strip from shoving the move
     counter off the right edge of a phone screen. */
  .hud-body { flex-direction: row; align-items: center; padding: 8px 10px; flex: 1 1 auto; min-width: 0; gap: 8px; }
  .goals { grid-auto-flow: column; grid-auto-columns: max-content; gap: 6px; overflow-x: auto; overflow-y: hidden; min-width: 0; scrollbar-width: none; }
  .goals::-webkit-scrollbar { display: none; }
  .goal { font-size: 15px; padding: 4px 8px; }
  .goal-ico { width: 24px; height: 24px; }
  .goal-ico img { width: 24px; height: 24px; }
  /* On a phone the goal strip needs every pixel, so the luck grade shrinks to
     its icon; the full name stays in the tooltip. */
  .luck-badge { align-self: center; flex: 0 0 auto; padding: 4px 7px 5px; font-size: 15px; }
  #luck-name { display: none; }
  .moves { margin: 0; flex: 0 0 auto; flex-direction: row; gap: 8px; align-items: baseline; min-width: 0; padding: 6px 12px; }
  .moves-label { display: none; }
  .moves strong { font-size: 26px; }
  .moves::before { content: '↔'; font-size: 15px; opacity: 0.55; }
  .booster-rail { flex-direction: row; padding: 8px 10px; }
  .hud-right { justify-content: center; padding-bottom: max(8px, env(safe-area-inset-bottom)); }

  .map-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); padding-top: 68px; }
  .manor-card { flex: 0 0 auto; }
  .tasks { grid-auto-flow: row; }
  .map-foot { flex-direction: column; gap: 8px; }
  .next-info { text-align: center; }
}

@media (max-height: 520px) {
  .manor-cat { display: none; }
  .manor-title p { display: none; }
}

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