:root {
  --ink: #152033;
  --muted: #687287;
  --paper: #f5f0e6;
  --paper-strong: #fffdf7;
  --navy: #101b2d;
  --navy-soft: #1a2941;
  --gold: #cf9d48;
  --gold-light: #f0cd83;
  --line: rgba(24, 35, 52, .13);
  --danger: #bd4f48;
  --shadow: 0 18px 48px rgba(19, 28, 42, .16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(210, 174, 103, .14), transparent 25rem),
    repeating-linear-gradient(0deg, rgba(31, 43, 59, .018) 0 1px, transparent 1px 4px),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

button { font: inherit; }
button, [role="button"] { touch-action: manipulation; }
button:focus-visible { outline: 3px solid rgba(62, 112, 167, .42); outline-offset: 2px; }

[hidden] { display: none !important; }

.app-shell {
  width: min(100%, 720px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(10px + var(--safe-top)) 14px calc(94px + var(--safe-bottom));
  position: relative;
}

.topbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.brand {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  cursor: pointer;
}

.brand > span:last-child { display: flex; flex-direction: column; line-height: 1; }
.brand b { font-family: Georgia, serif; font-size: 17px; letter-spacing: .13em; }
.brand small { margin-top: 5px; color: #7c6851; font-size: 7px; letter-spacing: .22em; font-weight: 800; }

.brand-mark {
  position: relative;
  width: 31px;
  height: 33px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  border-bottom: 3px solid var(--gold);
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 4px 4px auto;
  height: 7px;
  background: var(--gold);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.brand-mark i { width: 6px; background: var(--navy); border-radius: 1px 1px 0 0; }
.brand-mark i:nth-child(1) { height: 16px; }
.brand-mark i:nth-child(2) { height: 20px; }
.brand-mark i:nth-child(3) { height: 16px; }

.resources {
  display: flex;
  align-items: center;
  gap: 7px;
}

.resource {
  min-height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(29, 40, 54, .1);
  border-radius: 999px;
  background: rgba(255, 253, 247, .75);
  box-shadow: 0 3px 12px rgba(26, 34, 45, .06);
  font-size: 13px;
}

.resource i, .win-rewards i, .daily-reward i {
  width: 15px;
  height: 15px;
  display: inline-block;
  border-radius: 50%;
  border: 2px solid #a66c21;
  background: radial-gradient(circle at 35% 30%, #ffe29b 0 18%, #e0a845 20% 66%, #a96822 69%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.28);
}

.resource-prestige { color: #485975; }
.resource-prestige i { color: var(--gold); font-style: normal; }

.screen { animation: screen-in .28s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(5px); } }

.city-ribbon {
  width: 100%;
  height: 76px;
  border: 0;
  border-radius: 16px;
  padding: 0;
  overflow: hidden;
  position: relative;
  color: #fff;
  background: linear-gradient(135deg, #243a55, #112136);
  box-shadow: 0 8px 26px rgba(17, 31, 49, .18);
  cursor: pointer;
  text-align: left;
}

.city-ribbon::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(12, 24, 40, .85), rgba(12, 24, 40, .2) 62%, rgba(12, 24, 40, .38));
  pointer-events: none;
}

.city-ribbon-copy {
  position: absolute;
  z-index: 4;
  left: 17px;
  top: 17px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.city-ribbon-copy small { color: var(--gold-light); font-size: 8px; font-weight: 900; letter-spacing: .18em; }
.city-ribbon-copy b { font-family: Georgia, serif; font-size: 17px; font-weight: 600; }
.ribbon-arrow { position: absolute; right: 16px; top: 22px; z-index: 4; font-size: 27px; color: rgba(255,255,255,.82); }

.puzzle-card {
  margin-top: 11px;
  padding: 17px 14px 12px;
  border: 1px solid rgba(36, 45, 56, .11);
  border-radius: 20px;
  background:
    linear-gradient(rgba(255,255,255,.78), rgba(255,255,255,.78)),
    repeating-linear-gradient(90deg, transparent 0 24px, rgba(34,48,67,.045) 24px 25px),
    repeating-linear-gradient(0deg, transparent 0 24px, rgba(34,48,67,.045) 24px 25px);
  box-shadow: var(--shadow);
}

.puzzle-heading, .section-heading, .sheet-heading, .building-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.level-selector {
  border: 0;
  padding: 0;
  background: transparent;
  color: #8a6a35;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .13em;
  cursor: pointer;
}
.level-selector i { font-size: 12px; font-style: normal; margin-left: 3px; }

.puzzle-heading h1, .section-heading h1 {
  margin: 4px 0 0;
  font-family: Georgia, serif;
  font-size: clamp(23px, 6vw, 31px);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -.02em;
}

.difficulty {
  flex: 0 0 auto;
  margin-top: 3px;
  border: 1px solid rgba(77, 92, 111, .15);
  border-radius: 999px;
  padding: 6px 9px;
  color: #58667a;
  background: rgba(237, 232, 219, .65);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.coach {
  width: 100%;
  min-height: 46px;
  margin: 14px 0 10px;
  padding: 8px 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(185, 132, 54, .25);
  border-radius: 12px;
  color: #5d492f;
  background: #fff7df;
  text-align: left;
  font-size: 12px;
  line-height: 1.35;
  cursor: pointer;
}

.coach-seal {
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #aa7937;
  font-family: Georgia, serif;
  font-weight: 700;
}
.coach-close { margin-left: auto; color: #a69272; font-size: 17px; }

.rule-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 11px 0 14px;
}

.rule {
  min-width: 0;
  padding: 7px 3px 6px;
  border: 1px solid rgba(37, 48, 61, .09);
  border-radius: 9px;
  background: rgba(241, 237, 226, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #5f6875;
  font-size: 9px;
  white-space: nowrap;
}
.rule b { color: var(--ink); font-size: 14px; font-family: Georgia, serif; }
.rule-distance b { font-family: inherit; font-size: 13px; }
.rule-clue b { width: 18px; height: 18px; display: grid; place-items: center; border: 1px solid #7b8798; border-radius: 50%; font-size: 10px; }

.board-stage {
  width: 100%;
  display: grid;
  place-items: center;
  position: relative;
  padding: 3px 0;
}

.board-halo {
  position: absolute;
  width: min(91vw, 445px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(199, 157, 80, .1), transparent 68%);
  pointer-events: none;
}

.board {
  --n: 4;
  width: min(82vw, 410px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  position: relative;
  z-index: 1;
  border: 3px solid var(--navy);
  border-radius: 8px;
  overflow: hidden;
  background: #ddd5c7;
  box-shadow: 0 10px 28px rgba(27, 35, 46, .18), 0 0 0 5px rgba(255,255,255,.64);
  user-select: none;
}

.cell {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  border-right: 1px solid rgba(26, 36, 50, .13);
  border-bottom: 1px solid rgba(26, 36, 50, .13);
  background: var(--cell-color);
  color: var(--ink);
  cursor: pointer;
  transition: filter .12s ease, transform .12s ease, box-shadow .12s ease;
}

.cell::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .17;
  background: repeating-linear-gradient(135deg, transparent 0 7px, rgba(255,255,255,.45) 7px 8px);
  pointer-events: none;
}

.cell:hover { filter: brightness(1.035); }
.cell:active { transform: scale(.95); z-index: 4; }
.cell.border-top { border-top: 3px solid var(--navy); }
.cell.border-right { border-right: 3px solid var(--navy); }
.cell.border-bottom { border-bottom: 3px solid var(--navy); }
.cell.border-left { border-left: 3px solid var(--navy); }
.cell.tutorial-target { animation: target-glow 1.35s ease-in-out infinite; z-index: 3; }
@keyframes target-glow { 50% { box-shadow: inset 0 0 0 5px rgba(255,255,255,.58), 0 0 0 4px rgba(213,167,83,.44); } }

.tower-piece {
  position: relative;
  z-index: 2;
  color: #17263b;
  font-family: Georgia, serif;
  font-size: clamp(27px, calc(85vw / var(--n) * .48), 47px);
  line-height: 1;
  filter: drop-shadow(0 3px 0 rgba(255,255,255,.32));
  animation: piece-in .2s cubic-bezier(.2,.9,.35,1.3) both;
}
@keyframes piece-in { from { opacity: 0; transform: translateY(-8px) scale(.65); } }

.cell-mark {
  position: relative;
  z-index: 2;
  color: rgba(30, 42, 57, .4);
  font-family: Georgia, serif;
  font-size: clamp(22px, calc(82vw / var(--n) * .35), 34px);
}

.cell.is-blocked { cursor: not-allowed; }
.cell.is-blocked::after {
  content: "";
  width: 44%;
  height: 44%;
  background:
    linear-gradient(45deg, transparent 42%, rgba(41,51,64,.34) 43% 57%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, rgba(41,51,64,.34) 43% 57%, transparent 58%);
  opacity: .62;
}

.clue-number {
  position: relative;
  z-index: 2;
  width: 48%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid rgba(28,43,61,.52);
  border-radius: 50%;
  background: rgba(255,255,255,.55);
  font-family: Georgia, serif;
  font-size: clamp(12px, calc(82vw / var(--n) * .24), 20px);
  font-weight: 700;
}

.cell.is-conflict {
  animation: conflict .32s ease;
  box-shadow: inset 0 0 0 4px var(--danger);
  z-index: 5;
}
.cell.is-conflict .tower-piece, .cell.is-conflict .clue-number { color: var(--danger); }
@keyframes conflict { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.game-message {
  min-height: 33px;
  margin: 11px auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #616b78;
  font-size: 11px;
  text-align: center;
}
.game-message.is-error { color: var(--danger); }
.game-message.is-good { color: #3d796b; }
.message-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(207,157,72,.13); }
.is-error .message-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(189,79,72,.12); }
.is-good .message-dot { background: #4f9c8d; box-shadow: 0 0 0 4px rgba(79,156,141,.12); }

.tool-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 43px auto;
  align-items: center;
  gap: 7px;
}

.mode-switch {
  min-width: 0;
  padding: 3px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  border-radius: 11px;
  background: #e9e4d9;
}

.mode-button {
  min-width: 0;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  color: #737b87;
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}
.mode-button span { margin-right: 3px; font-size: 15px; }
.mode-button.is-active { color: #fff; background: var(--navy-soft); box-shadow: 0 3px 10px rgba(17,29,47,.22); }

.icon-button, .hint-button, .help-button, .sheet-close {
  border: 1px solid rgba(36,47,61,.12);
  background: #fffdf8;
  color: var(--ink);
  cursor: pointer;
}
.icon-button { width: 43px; height: 43px; border-radius: 11px; font-size: 21px; }
.icon-button:disabled { opacity: .35; cursor: default; }

.hint-button {
  min-height: 43px;
  border-radius: 11px;
  padding: 0 10px;
  color: #725427;
  background: #fff7df;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}
.hint-button span:first-child { font-size: 15px; margin-right: 3px; }

.puzzle-foot {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid rgba(35,47,61,.09);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #7b8290;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.puzzle-foot span { display: inline-flex; align-items: center; gap: 4px; }
.puzzle-foot b { color: #4e5968; }
.tiny-icon { color: #8a6a35; font-style: normal; font-size: 13px; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 720px);
  min-height: calc(69px + var(--safe-bottom));
  padding: 7px 24px var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(255, 253, 248, .94);
  border-top: 1px solid rgba(28,40,55,.1);
  backdrop-filter: blur(16px);
  box-shadow: 0 -10px 30px rgba(20,28,38,.07);
}

.nav-button {
  position: relative;
  border: 0;
  border-radius: 12px;
  color: #8a909a;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}
.nav-button span { font-size: 19px; line-height: 1; }
.nav-button b { font-size: 9px; letter-spacing: .04em; }
.nav-button.is-active { color: var(--navy); background: rgba(224,211,184,.26); }
.nav-button i { position: absolute; top: 7px; right: calc(50% - 18px); width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 2px solid #fff; }

.section-heading { margin: 14px 2px 14px; align-items: center; }
.eyebrow { color: #9a7436; font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.help-button { width: 35px; height: 35px; border-radius: 50%; font-family: Georgia, serif; font-weight: 700; }

.city-scene-card {
  overflow: hidden;
  border-radius: 20px;
  background: var(--navy);
  box-shadow: var(--shadow);
}

.skyline { position: relative; overflow: hidden; }
.skyline::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 78% 25%, rgba(247,201,110,.85) 0 5%, rgba(235,164,79,.16) 5.5% 16%, transparent 17%),
    linear-gradient(#385875 0%, #d48d63 58%, #d9b070 100%);
}
.skyline::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 15%; background: #132238; }
.skyline-compact { position: absolute; inset: 0; }
.skyline-large { height: 250px; }

.sky-building {
  position: absolute;
  z-index: 2;
  bottom: 8%;
  left: var(--x);
  width: var(--w);
  height: var(--h);
  background: var(--tone);
  border-radius: 2px 2px 0 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
  transform-origin: bottom;
  animation: build-rise .55s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: var(--delay);
}
@keyframes build-rise { from { transform: scaleY(0); } }
.sky-building::before { content: ""; position: absolute; left: 50%; top: calc(var(--roof) * -1); transform: translateX(-50%); border-left: var(--roof) solid transparent; border-right: var(--roof) solid transparent; border-bottom: var(--roof) solid var(--tone); }
.sky-building::after { content: ""; position: absolute; inset: 18% 17% 8%; background: repeating-linear-gradient(90deg, rgba(240,198,110,.8) 0 3px, transparent 3px 8px), repeating-linear-gradient(0deg, transparent 0 9px, rgba(240,198,110,.58) 9px 12px); opacity: var(--lights); }
.sky-building.is-tower { border-radius: 50% 50% 0 0 / 12% 12% 0 0; }
.sky-building.is-tower::before { width: 3px; height: 27px; top: -25px; border: 0; background: var(--gold-light); }
.sky-building.is-domed::before { width: 70%; height: 24%; top: -18%; border: 0; border-radius: 50% 50% 0 0; background: var(--tone); }
.sky-road { position: absolute; z-index: 4; left: -5%; right: -5%; bottom: 0; height: 9%; background: linear-gradient(#28354a 0 24%, #a07142 25% 39%, #4c3a2c 40%); transform: skewX(-15deg); }
.sky-tree { position: absolute; z-index: 3; left: var(--x); bottom: 8%; width: var(--s); height: var(--s); border-radius: 50%; background: #31584c; box-shadow: calc(var(--s) * .25) calc(var(--s) * .15) 0 #24463e; }

.city-rank-line {
  min-height: 62px;
  padding: 12px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: #101b2d;
}
.city-rank-line span { display: flex; flex-direction: column; gap: 4px; }
.city-rank-line span:last-child { text-align: right; }
.city-rank-line small { color: #b6a47f; font-size: 8px; font-weight: 900; letter-spacing: .14em; }
.city-rank-line b { font-family: Georgia, serif; font-size: 16px; }

.city-progress-card, .streak-card {
  margin-top: 11px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,253,247,.8);
}
.city-progress-card > div:first-child { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.city-progress-card span { color: var(--muted); }
.progress-track { height: 7px; margin-top: 10px; border-radius: 99px; background: #e2ddd2; overflow: hidden; }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #b47d31, #e2b85d); transition: width .4s ease; }

.building-heading { align-items: end; margin: 22px 2px 10px; }
.building-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 20px; }
.building-heading span { color: var(--muted); font-size: 9px; }
.building-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.building-card {
  min-height: 174px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,253,247,.86);
  box-shadow: 0 6px 20px rgba(26,35,47,.06);
}
.building-icon { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 12px; background: var(--building-bg); color: var(--building-color); font-family: Georgia, serif; font-size: 25px; }
.building-card h3 { margin: 10px 0 3px; font-family: Georgia, serif; font-size: 16px; }
.building-card p { min-height: 31px; margin: 0 0 8px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.building-level { display: flex; gap: 3px; margin-bottom: 8px; }
.building-level i { width: 14px; height: 4px; border-radius: 99px; background: #ded8cc; }
.building-level i.is-filled { background: var(--gold); }
.building-upgrade {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: var(--navy-soft);
  font-size: 9px;
  font-weight: 850;
  cursor: pointer;
}
.building-upgrade:disabled { color: #8b8c8b; background: #e5e0d6; cursor: default; }
.building-upgrade.is-max { color: #6f5730; background: #f3e2b9; }

.streak-pill { min-width: 54px; height: 36px; padding: 0 10px; display: flex; align-items: center; justify-content: center; gap: 5px; border-radius: 99px; color: #8c5b26; background: #f4e0b6; }
.daily-card { overflow: hidden; border-radius: 21px; position: relative; min-height: 445px; color: #fff; background: linear-gradient(145deg, #233a58, #101b2d 70%); box-shadow: var(--shadow); }
.daily-card::before { content: ""; position: absolute; inset: 0; background: linear-gradient(120deg, transparent 35%, rgba(255,255,255,.04) 35.2% 35.7%, transparent 36%); }
.daily-sun { position: absolute; right: -42px; top: -25px; width: 210px; height: 210px; border-radius: 50%; background: radial-gradient(circle, rgba(242,190,90,.95) 0 25%, rgba(218,139,62,.18) 26% 57%, transparent 58%); }
.daily-sun span { position: absolute; inset: 50% auto auto 50%; width: 110px; height: 110px; transform: translate(-50%,-50%); border: 1px solid rgba(255,225,158,.22); border-radius: 50%; }
.daily-copy { position: relative; z-index: 2; min-height: 445px; padding: 32px 22px 22px; display: flex; flex-direction: column; align-items: flex-start; }
.daily-date { color: var(--gold-light); font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.daily-copy h2 { max-width: 350px; margin: 72px 0 13px; font-family: Georgia, serif; font-size: 31px; line-height: 1.08; font-weight: 500; }
.daily-copy p { max-width: 390px; margin: 0; color: #bdc6d2; font-size: 12px; line-height: 1.55; }
.daily-reward { margin-top: auto; display: flex; align-items: center; gap: 14px; font-size: 12px; }
.daily-reward > span { color: #99a4b2; font-size: 8px; font-weight: 900; letter-spacing: .14em; }
.daily-reward b { display: flex; align-items: center; gap: 5px; }
.daily-reward i { width: 14px; height: 14px; }
.primary-button, .secondary-button {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .03em;
  cursor: pointer;
}
.primary-button { border: 0; color: #152033; background: linear-gradient(135deg, #f0cc7d, #dba64d); box-shadow: 0 8px 18px rgba(207,157,72,.24); }
.primary-button:disabled { color: #707a88; background: #cbd0d6; box-shadow: none; cursor: default; }
.secondary-button { border: 1px solid rgba(28,40,56,.16); color: var(--ink); background: transparent; }
.daily-copy .primary-button { margin-top: 17px; }

.streak-card { display: flex; flex-direction: column; gap: 14px; }
.streak-card h2 { margin: 4px 0; font-family: Georgia, serif; font-size: 19px; }
.streak-card p { margin: 0; color: var(--muted); font-size: 10px; }
.week-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.day-dot { min-width: 0; text-align: center; }
.day-dot span { width: 100%; aspect-ratio: 1; max-width: 36px; margin: 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: #9a9fa8; background: #f0ece3; font-size: 11px; }
.day-dot b { display: block; margin-top: 4px; color: #9297a0; font-size: 7px; }
.day-dot.is-done span { color: #fff; background: #4c8c7f; border-color: #4c8c7f; }
.day-dot.is-today span { box-shadow: 0 0 0 3px rgba(207,157,72,.28); border-color: var(--gold); }

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  background: rgba(11, 19, 31, .58);
  backdrop-filter: blur(5px);
  animation: fade-in .2s ease both;
}
@keyframes fade-in { from { opacity: 0; } }

.sheet {
  position: fixed;
  z-index: 51;
  left: 50%;
  bottom: 0;
  width: min(100%, 720px);
  max-height: min(86dvh, 800px);
  padding: 10px 17px calc(20px + var(--safe-bottom));
  overflow-y: auto;
  transform: translateX(-50%);
  border-radius: 22px 22px 0 0;
  background: var(--paper-strong);
  box-shadow: 0 -20px 60px rgba(10,18,29,.28);
  animation: sheet-up .28s cubic-bezier(.2,.85,.25,1) both;
}
@keyframes sheet-up { from { transform: translate(-50%, 100%); } }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 14px; border-radius: 99px; background: #d5d0c6; }
.sheet-heading { align-items: center; margin-bottom: 14px; }
.sheet-heading h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 23px; }
.sheet-close { width: 37px; height: 37px; border-radius: 50%; font-size: 21px; }
.chapter-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chapter-tab { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; padding: 8px 11px; color: var(--muted); background: #f2eee6; font-size: 9px; font-weight: 800; cursor: pointer; }
.chapter-tab.is-active { color: #fff; background: var(--navy-soft); }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; padding: 7px 0 10px; }
.level-button { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #f4efe6; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.level-button b { font-family: Georgia, serif; font-size: 15px; }
.level-button span { min-height: 9px; color: var(--gold); font-size: 7px; letter-spacing: -1px; }
.level-button.is-current { color: #fff; background: var(--navy-soft); box-shadow: 0 0 0 2px var(--gold); }
.level-button:disabled { color: #b1b0ac; background: #ebe8e2; cursor: default; }
.level-button:disabled::after { content: "•"; color: #b7b2aa; }

.rules-list { display: grid; gap: 8px; }
.rules-list > div { padding: 11px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 12px; background: #f7f2e9; }
.rules-list > div > b { flex: 0 0 auto; color: var(--gold); font-family: Georgia, serif; font-size: 19px; }
.rules-list span { display: flex; flex-direction: column; gap: 3px; }
.rules-list strong { font-family: Georgia, serif; font-size: 14px; }
.rules-list small { color: var(--muted); font-size: 10px; }
.advanced-rule { margin: 10px 0 14px; padding: 11px; border-radius: 12px; color: #dce3ec; background: var(--navy-soft); }
.advanced-rule span { color: var(--gold-light); font-size: 8px; font-weight: 900; letter-spacing: .15em; }
.advanced-rule p { margin: 5px 0 0; font-size: 10px; line-height: 1.5; }

.win-sheet { text-align: center; overflow: hidden; }
.win-rays { position: absolute; inset: -80px -20%; background: repeating-conic-gradient(from 0deg, rgba(207,157,72,.08) 0 8deg, transparent 8deg 18deg); pointer-events: none; }
.win-kicker { position: relative; color: #99702f; font-size: 9px; font-weight: 900; letter-spacing: .18em; }
.win-sheet h2 { position: relative; margin: 8px 0 7px; font-family: Georgia, serif; font-size: 28px; }
.win-stars { position: relative; color: var(--gold); font-size: 25px; letter-spacing: 6px; text-shadow: 0 2px 0 #fff; }
.win-stars .is-empty { color: #d9d4ca; }
.win-rewards { position: relative; margin: 17px 0 12px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 13px; background: #f5f0e7; }
.win-rewards div { min-height: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.win-rewards div + div { border-left: 1px solid var(--line); }
.win-rewards small { color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .12em; }
.win-rewards b { display: flex; align-items: center; gap: 5px; font-family: Georgia, serif; font-size: 17px; }
.win-sheet p { position: relative; margin: 0 0 15px; color: var(--muted); font-size: 11px; }
.win-sheet .primary-button, .win-sheet .secondary-button { position: relative; margin-top: 7px; }

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(82px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 11px 15px;
  border-radius: 999px;
  color: #fff;
  background: rgba(16,27,45,.94);
  box-shadow: 0 8px 26px rgba(10,17,27,.25);
  font-size: 10px;
  text-align: center;
  animation: toast-in .25s ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (min-width: 620px) {
  .app-shell { padding-left: 24px; padding-right: 24px; }
  .puzzle-card { padding: 21px 25px 15px; }
  .board { width: min(57vh, 430px); }
  .tower-piece { font-size: calc(min(57vh, 430px) / var(--n) * .47); }
  .cell-mark { font-size: calc(min(57vh, 430px) / var(--n) * .34); }
  .building-grid { grid-template-columns: repeat(4, 1fr); }
  .daily-card { min-height: 410px; }
  .daily-copy { min-height: 410px; }
  .daily-copy h2 { margin-top: 55px; font-size: 38px; }
  .level-grid { grid-template-columns: repeat(10, 1fr); }
}

@media (max-width: 360px) {
  .app-shell { padding-left: 9px; padding-right: 9px; }
  .brand b { font-size: 14px; }
  .brand-mark { width: 27px; }
  .resource { padding: 0 7px; }
  .puzzle-card { padding-left: 9px; padding-right: 9px; }
  .board { width: min(86vw, 340px); }
  .rule { font-size: 8px; gap: 2px; }
  .hint-button { padding: 0 7px; font-size: 8px; }
  .mode-button { font-size: 9px; }
}

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