* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #b9cfcf; touch-action: none;
  font-family: 'Gochi Hand', 'Comic Sans MS', 'Chalkboard SE', cursive; color: #1d1714;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; }
:root { --ink: #1d1714; --cream: #fbf3dc; --gold: #f3b443; --orange: #e0662a; }

/* ---------- HUD ---------- */
.pill { background: var(--cream); border: 3px solid var(--ink); border-radius: 999px; padding: 3px 13px;
  font-size: 20px; line-height: 1.2; box-shadow: 0 3px 0 var(--ink); white-space: nowrap; }
.pill.small { font-size: 16px; padding: 2px 10px; display: flex; align-items: center; gap: 6px; }
.pill .sw { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); display: inline-block; }
.round { width: 40px; height: 40px; border-radius: 50%; background: var(--cream); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  font-size: 19px; padding: 0; display: flex; align-items: center; justify-content: center; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
#hud { position: fixed; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(env(safe-area-inset-top) + 8px) 10px 0; pointer-events: none; gap: 8px; }
#hud .btn { pointer-events: auto; }
.hudleft { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hudright { display: flex; gap: 6px; align-items: center; }
#pts.bump { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.25); background: var(--gold); } }
#mini { position: fixed; right: 10px; top: calc(env(safe-area-inset-top) + 58px); border: 3px solid var(--ink); border-radius: 10px;
  box-shadow: 0 3px 0 var(--ink); image-rendering: pixelated; opacity: .92; cursor: pointer; }
#mini.closed { width: 40px !important; height: 26px !important; opacity: .6; }
#progress { position: fixed; left: 10px; top: calc(env(safe-area-inset-top) + 92px); font-size: 17px; pointer-events: none; }
#toast { position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%); background: var(--cream); border: 3px solid var(--ink);
  border-radius: 20px; padding: 8px 18px; font-size: 22px; display: flex; align-items: center; gap: 10px; pointer-events: none;
  box-shadow: 0 4px 0 var(--ink); animation: pop .3s cubic-bezier(.3,1.6,.6,1); max-width: 92vw; text-align: center; }
#toast img { height: 46px; flex: none; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.4); } to { transform: translate(-50%, -50%) scale(1); } }
#keyhelp { position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%); font-size: 16px; background: rgba(251,243,220,.8);
  border: 2px solid var(--ink); border-radius: 999px; padding: 2px 14px; pointer-events: none; white-space: nowrap; }

/* era banner */
#eraBanner { position: fixed; left: 0; right: 0; top: 22%; display: flex; justify-content: center; pointer-events: none; }
.eb-inner { background: var(--era, #f4d36f); color: var(--eratext, #1d1714); border: 4px solid var(--ink); border-radius: 18px; padding: 10px 26px 12px;
  text-align: center; box-shadow: 0 5px 0 var(--ink); animation: drop .6s cubic-bezier(.3,1.5,.6,1); max-width: 88vw; position: relative; overflow: hidden; }
.eb-inner::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 10px;
  background: repeating-linear-gradient(100deg, transparent 0 7px, var(--orange) 7px 9px); }
.eb-small { font-size: 18px; opacity: .85; margin-top: 4px; }
.eb-name { font-size: 50px; line-height: 1; letter-spacing: 3px; }
.eb-years { font-size: 19px; }
.eb-blurb { font-size: 18px; margin-top: 4px; max-width: 420px; }
#eraBanner.out .eb-inner { animation: rise .6s ease-in forwards; }
@keyframes drop { from { transform: translateY(-140%) rotate(-4deg); } to { transform: none; } }
@keyframes rise { to { transform: translateY(-160%); opacity: 0; } }

/* touch controls */
#controls { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 12px calc(env(safe-area-inset-bottom) + 12px); pointer-events: none; }
.pad { display: flex; gap: 12px; pointer-events: auto; align-items: flex-end; }
.pad.right { position: relative; }
.cbtn { width: 72px; height: 72px; border-radius: 50%; background: rgba(251,243,220,.88); border: 4px solid var(--ink);
  font-size: 30px; box-shadow: 0 4px 0 var(--ink); touch-action: none; padding: 0; }
.cbtn.on { background: var(--gold); transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.cbtn.sniff { position: absolute; right: 42px; bottom: 86px; width: 58px; height: 58px; font-size: 28px;
  background: conic-gradient(rgba(29,23,20,.45) var(--cd, 0deg), rgba(251,243,220,.92) 0); }
.cbtn.sniff.cooling { opacity: .8; }
.actbtn { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 104px); translate: -50% 0; white-space: nowrap; pointer-events: auto; font-size: 24px; background: var(--gold); border: 4px solid var(--ink); border-radius: 999px; padding: 6px 18px;
  box-shadow: 0 4px 0 var(--ink); animation: wiggle 1.2s ease-in-out infinite; }
@keyframes wiggle { 50% { transform: scale(1.06) rotate(-2deg); } }
@media (max-width: 400px) { .cbtn { width: 62px; height: 62px; font-size: 26px; } .pad { gap: 8px; } .cbtn.sniff { width: 52px; height: 52px; bottom: 76px; right: 36px; } .actbtn { font-size: 20px; padding: 4px 12px; } }
@media (max-height: 460px) { .cbtn { width: 60px; height: 60px; } .cbtn.sniff { bottom: 0; right: auto; left: -66px; position: absolute; } }

/* ---------- overlays ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(29,23,20,.45);
  padding: 14px; overflow: auto; touch-action: pan-y; }
.page { background: var(--cream); border: 4px solid var(--ink); border-radius: 22px; padding: 16px 20px; max-width: 540px; width: 100%;
  box-shadow: 0 6px 0 var(--ink); text-align: center; position: relative; margin: auto; }
.page.wide { max-width: 780px; }
.page.title { padding-top: 0; overflow: hidden; }
.hero { display: block; width: calc(100% + 40px); margin: 0 -20px 4px; border-bottom: 4px solid var(--ink); max-height: 34vh; object-fit: cover; object-position: center 40%; }
h1 { font-size: 46px; margin: 2px 0 4px; letter-spacing: 3px; }
h2 { font-size: 32px; margin: 4px 0 4px; line-height: 1.1; }
h3 { font-size: 24px; margin: 12px 0 4px; }
p { font-size: 20px; margin: 6px 0; text-align: left; line-height: 1.25; }
.howto { font-size: 19px; text-align: left; margin: 8px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.howto .k { display: inline-block; min-width: 44px; font-weight: bold; }
@media (max-width: 480px) { .howto { grid-template-columns: 1fr; } h1 { font-size: 38px; } }
.startbtns { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.bigbtn { font-size: 28px; background: var(--gold); border: 4px solid var(--ink); border-radius: 999px; padding: 5px 26px; box-shadow: 0 4px 0 var(--ink); }
.bigbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.bigbtn:disabled { opacity: .5; }
.smallbtn { font-size: 18px; background: var(--cream); border: 3px solid var(--ink); border-radius: 999px; padding: 3px 14px; }
#loading { font-size: 18px; margin-top: 6px; }

.page.dark { background: #3b2a21; color: var(--cream); }
.page.dark::before { content: ""; position: absolute; inset: 0; border-radius: 18px; pointer-events: none;
  background-image: radial-gradient(#e8c25a 1.2px, transparent 1.6px); background-size: 22px 22px; opacity: .3; }
.page.dark > * { position: relative; }
#cardImg { max-width: 100%; max-height: 32vh; margin: 4px 0; animation: cardpop .6s cubic-bezier(.3,1.5,.6,1); }
@keyframes cardpop { from { transform: scale(.3) rotate(-8deg); opacity: 0; } }
.stars { color: var(--gold); font-size: 26px; letter-spacing: 6px; }
.era { font-size: 18px; color: #e8c25a; }
.stats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.stats span { background: rgba(251,243,220,.12); border: 2px solid rgba(251,243,220,.5); border-radius: 999px; padding: 1px 10px; font-size: 17px; }
.count { font-size: 19px; color: #e8c25a; margin: 4px 0 8px; }
.finaleimg { height: 150px; margin: 6px 0; }

/* camp */
.camp { padding-top: 12px; }
.xbtn { position: absolute; right: 10px; top: 10px; width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--ink); background: var(--cream); font-size: 20px; z-index: 2; }
.tabs { display: flex; gap: 6px; justify-content: center; margin: 0 44px 10px; flex-wrap: wrap; }
.tab { font-size: 20px; border: 3px solid var(--ink); background: #efe2bd; border-radius: 14px; padding: 3px 12px; }
.tab.on { background: var(--gold); box-shadow: 0 3px 0 var(--ink); }
.note { text-align: center; font-size: 19px; }
.shoprow { display: flex; align-items: center; gap: 10px; border: 3px solid var(--ink); border-radius: 14px; padding: 6px 10px; margin: 6px 0; background: #fff8e6; text-align: left; }
.sicon { font-size: 32px; width: 46px; text-align: center; }
.sinfo { flex: 1; font-size: 17px; line-height: 1.15; }
.sinfo b { font-size: 20px; }
.sinfo small { opacity: .7; font-size: 15px; }
.lv i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); margin-right: 2px; }
.lv i.on { background: var(--orange); }
.buy { font-size: 19px; background: var(--gold); border: 3px solid var(--ink); border-radius: 999px; padding: 3px 12px; min-width: 76px; box-shadow: 0 3px 0 var(--ink); }
.buy:disabled { background: #ddd2b4; opacity: .7; box-shadow: none; }
.mrow { display: flex; align-items: center; gap: 10px; text-align: left; font-size: 19px; padding: 4px 8px; border-bottom: 2px dashed rgba(29,23,20,.25); }
.mrow span:nth-child(2) { flex: 1; }
.mrow .chk { width: 26px; height: 26px; border: 3px solid var(--ink); border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #2f7d32; font-weight: bold; }
.mrow.done span:nth-child(2) { text-decoration: line-through; opacity: .6; }
.museumhall { background: url(img/museum.jpg) center 70% / cover; border: 3px solid var(--ink); border-radius: 14px; padding: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); }
.cell { background: rgba(59,42,33,.62); border: 3px solid var(--ink); border-radius: 12px; padding: 5px; color: var(--cream); font-size: 17px; line-height: 1.1; }
.cell small { color: #e8c25a; font-size: 14px; }
.cell img { width: 100%; height: 70px; object-fit: contain; }
.grid.small .cell { background: #f4d36f; color: var(--ink); font-size: 15px; }
.grid.small .cell img { height: 40px; }
.cell.locked img { filter: brightness(0) opacity(.5); }
.cell.locked { color: #b5a48f; }
