:root {
  --ink: #2b1d14;
  --paper: #fff6e6;
  --bark: #7a4a2a;
  --gold: #ffc533;
  --red: #e2552d;
  --green: #5c9a2e;
  --display: "Lilita One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #7ec8f0;
  font-family: var(--body);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
canvas { display: block; width: 100vw; height: 100dvh; touch-action: none; }

button { font: inherit; cursor: pointer; }

.corner-btn {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 30;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 246, 230, 0.8);
  font-size: 20px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  padding: 12px;
  background: rgba(30, 20, 10, 0.35);
  overflow-y: auto;
}
.overlay[hidden] { display: none; }

.card {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 8px 0 var(--ink), 0 20px 40px rgba(0, 0, 0, 0.3);
  padding: clamp(14px, 2.5vw, 24px);
  max-width: 100%;
  margin: auto; /* centres, but scrolls instead of clipping when taller than the screen */
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: normal;
  font-size: clamp(48px, 10vw, 88px);
  line-height: 1;
  color: var(--gold);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink);
  letter-spacing: 0.02em;
}

.title-card { width: 560px; text-align: center; }
.title-card .sub { font-size: 18px; font-weight: 800; margin: 14px 0 10px; }
.how { text-align: left; margin: 0 auto 18px; padding-left: 22px; line-height: 1.45; max-width: 460px; }
.how li { margin: 6px 0; }
.keys { font-size: 13px; opacity: 0.7; margin: 14px 0 0; }
.credit { font-size: 12px; opacity: 0.55; margin: 6px 0 0; }

.big {
  font-family: var(--display);
  font-size: 30px;
  padding: 10px 40px 12px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  background: var(--red);
  color: #fff;
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
  box-shadow: 0 6px 0 var(--ink);
  transition: transform 0.06s, box-shadow 0.06s;
}
.big:hover { filter: brightness(1.08); }
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }

.link { background: none; border: 0; text-decoration: underline; opacity: 0.6; font-size: 13px; }

/* ---------- hangar ---------- */

.hangar-card { width: 900px; }
.hangar-head {
  display: flex;
  gap: 12px;
  align-items: stretch;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
#results { flex: 1 1 360px; }
#results h2 { font-family: var(--display); font-weight: normal; font-size: 28px; margin: 0 0 6px; }
#results .reason { font-weight: 800; color: var(--bark); margin: 0 0 8px; }
.lines { display: grid; grid-template-columns: 1fr auto; gap: 0 18px; max-width: 360px; font-size: 14px; }
.lines .total { font-family: var(--display); font-size: 20px; border-top: 2px dashed var(--ink); padding-top: 4px; margin-top: 2px; }
.lines .bonus { color: #b07800; font-weight: 800; }

.wallet {
  flex: 0 0 auto;
  text-align: right;
  align-self: center;
}
.cash {
  font-family: var(--display);
  font-size: 44px;
  color: var(--green);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
}
.best { font-weight: 800; opacity: 0.75; }

.shop {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}
.upg {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 4px 10px;
  align-items: center;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 6px 10px 8px;
}
.upg .icon { font-size: 30px; grid-row: span 3; text-align: center; }
.upg .name { font-family: var(--display); font-size: 18px; }
.upg .desc { font-size: 12.5px; line-height: 1.25; grid-column: 2 / 4; opacity: 0.8; }
.upg .eff { font-size: 12.5px; font-weight: 800; color: var(--bark); grid-column: 2 / 4; }
.pips { display: flex; gap: 3px; justify-self: end; }
.pips { gap: 2px; }
.pips i { width: 9px; height: 7px; border-radius: 2px; background: #e6dcc6; }
.pips i.on { background: var(--gold); box-shadow: inset 0 -2px 0 #c98f00; }
.upg .buy {
  grid-column: 1 / 4;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: var(--gold);
  font-family: var(--display);
  font-size: 18px;
  padding: 3px 0 4px;
  box-shadow: 0 3px 0 var(--ink);
}
.upg .buy:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.upg .buy:disabled { background: #ddd; color: #888; cursor: default; box-shadow: none; }
.upg.maxed .buy { background: #bfe3a1; color: var(--ink); }
.upg.flash { animation: flash 0.4s; }
@keyframes flash { 30% { background: #fff1b8; transform: scale(1.03); } }

.hangar-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* ---------- touch controls ---------- */

#touch[hidden] { display: none; }
#touch button {
  position: fixed;
  z-index: 15;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: rgba(255, 246, 230, 0.75);
  font-size: 28px;
  touch-action: none;
}
#touch button.held { background: var(--gold); }
.pad-left button[data-key="up"] { left: max(18px, env(safe-area-inset-left)); bottom: calc(110px + env(safe-area-inset-bottom)); }
.pad-left button[data-key="down"] { left: max(18px, env(safe-area-inset-left)); bottom: calc(24px + env(safe-area-inset-bottom)); }
#touch .boost { right: max(18px, env(safe-area-inset-right)); bottom: calc(24px + env(safe-area-inset-bottom)); width: 92px; height: 92px; font-size: 38px; }
