* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0e1114;
  color: #e8efe0;
  font-family: 'Rubik', system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

canvas#game {
  display: block;
  touch-action: none;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(10, 20, 8, 0.65), rgba(0, 0, 0, 0.88));
  z-index: 10;
}

.hidden { display: none; }

.title {
  font-family: 'Creepster', 'Rubik', cursive;
  font-weight: normal;
  font-size: clamp(48px, 11vw, 110px);
  letter-spacing: 3px;
  color: #9ccc65;
  text-shadow: 0 0 24px rgba(156, 204, 101, 0.45), 0 4px 0 #1b2a12;
}
.title.red {
  color: #e53935;
  text-shadow: 0 0 24px rgba(229, 57, 53, 0.5), 0 4px 0 #2a0d0c;
}

.heading {
  font-family: 'Creepster', 'Rubik', cursive;
  font-weight: normal;
  font-size: clamp(40px, 8vw, 72px);
  color: #ffd54f;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(255, 213, 79, 0.4);
}

.subtitle { color: #b7c4ab; font-size: 17px; max-width: 520px; }
.hint { color: #7d8a72; }

.btn {
  font-family: 'Rubik', sans-serif;
  font-weight: 800;
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 14px 44px;
  color: #10170c;
  background: #9ccc65;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 5px 0 #557a2f, 0 0 30px rgba(156, 204, 101, 0.3);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #557a2f; }

.diffs, .row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.btn.diff {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 170px; padding: 12px 22px;
  background: var(--dc); box-shadow: 0 5px 0 color-mix(in srgb, var(--dc) 55%, #000), 0 0 26px color-mix(in srgb, var(--dc) 35%, transparent);
}
.btn.diff small { font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0; opacity: 0.8; }
.maps { gap: 10px; }
.btn.map {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 230px; padding: 8px 16px; font-size: 17px;
  color: var(--dc); background: rgba(0, 0, 0, 0.35); border: 2px solid color-mix(in srgb, var(--dc) 40%, transparent);
  box-shadow: none;
}
.btn.map small { font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0; opacity: 0.85; color: #d5e3c8; }
.btn.map.on { border-color: var(--dc); background: color-mix(in srgb, var(--dc) 18%, rgba(0, 0, 0, 0.4)); box-shadow: 0 0 22px color-mix(in srgb, var(--dc) 35%, transparent); }
.btn.map:disabled { opacity: 0.5; filter: grayscale(0.7); cursor: not-allowed; transform: none; }
body[data-map="desert"] #menu { background: radial-gradient(ellipse at center, rgba(70, 40, 10, 0.55), rgba(10, 6, 2, 0.88)); }
body[data-map="city"] #menu { background: radial-gradient(ellipse at center, rgba(60, 10, 20, 0.55), rgba(5, 4, 10, 0.9)); }
.btn.secondary { background: #3e4a38; color: #e8efe0; box-shadow: 0 5px 0 #222a1e; }

.controls { color: #8b9a7f; font-size: 14px; line-height: 1.9; }
kbd {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid #4a5a3f;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #1a2416;
  color: #d5e3c8;
  font-family: inherit;
  font-size: 12px;
}
.best { color: #ffd54f; font-size: 15px; min-height: 18px; }

.cards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 1300px;
}
.card {
  width: 220px;
  padding: 20px 16px;
  background: linear-gradient(180deg, #1f2b19, #141c10);
  border: 2px solid #3e5530;
  border-radius: 14px;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.1s, border-color 0.1s, box-shadow 0.1s;
}
.card:hover, .card:focus-visible {
  transform: translateY(-4px);
  border-color: #9ccc65;
  box-shadow: 0 0 24px rgba(156, 204, 101, 0.35);
  outline: none;
}
.card .rarity { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; }
.card[data-rarity="common"]   { --rc: #b0bec5; }
.card[data-rarity="uncommon"] { --rc: #66bb6a; }
.card[data-rarity="epic"]     { --rc: #ba68c8; }
.card[data-rarity="legendary"] { --rc: #ff9100; }
.card[data-rarity="mythic"]   { --rc: #ff5252; }
.card[data-rarity="pet"]      { --rc: #f48fb1; }
.card[data-rarity="ultra"]    { --rc: #ffd740; }
.card[data-rarity="power"]    { --rc: #80deea; }
.card[data-rarity="reroll"]   { --rc: #fff59d; }
.card[data-rarity] { border-color: var(--rc); box-shadow: inset 0 0 18px color-mix(in srgb, var(--rc) 25%, transparent); }
.card[data-rarity] .rarity { color: var(--rc); }
.card[data-rarity]:hover, .card[data-rarity]:focus-visible { border-color: var(--rc); box-shadow: 0 0 28px color-mix(in srgb, var(--rc) 60%, transparent); }
.card[data-rarity="mythic"] { background: linear-gradient(180deg, #3a1515, #1a0b0b); }
.card[data-rarity="epic"]   { background: linear-gradient(180deg, #2c1a33, #150d19); }
.card[data-rarity="legendary"] {
  background: linear-gradient(180deg, #3d2405, #1a0f02);
  animation: legendary-fire 0.6s ease-in-out infinite alternate;
}
.card[data-rarity="legendary"] .rarity {
  background: linear-gradient(90deg, #ff6d00, #ffd740, #fff3e0, #ffd740, #ff6d00);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 15px;
  animation: legendary-shine 1.5s linear infinite;
}
@keyframes legendary-fire {
  from { box-shadow: 0 0 14px rgba(255, 109, 0, 0.5), inset 0 -10px 24px rgba(255, 87, 34, 0.25); }
  to   { box-shadow: 0 0 34px rgba(255, 145, 0, 0.9), inset 0 -18px 30px rgba(255, 145, 0, 0.4); }
}
@keyframes legendary-shine {
  from { background-position: 200% 0; }
  to   { background-position: 0 0; }
}
.card[data-rarity="pet"]    { background: linear-gradient(180deg, #33192a, #170b13); }
.card[data-rarity="ultra"] {
  background: linear-gradient(180deg, #3d3208, #1a1505);
  animation: ultra-glow 1s ease-in-out infinite alternate;
}
.card[data-rarity="ultra"] .rarity {
  background: linear-gradient(90deg, #ff5252, #ffd740, #69f0ae, #40c4ff, #e040fb);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 16px;
}
@keyframes ultra-glow {
  from { box-shadow: 0 0 16px rgba(255, 215, 64, 0.5); transform: scale(1); }
  to   { box-shadow: 0 0 44px rgba(255, 215, 64, 0.95); transform: scale(1.04); }
}
.luck { font-size: 13px; color: #8b9a7f; max-width: 700px; line-height: 1.6; }

.card .icon { font-size: 40px; line-height: 1.1; }
.card .name { font-weight: 800; font-size: 19px; color: #e8efe0; }
.card .lvl { font-size: 12px; color: #ffd54f; text-transform: uppercase; letter-spacing: 1px; }
.card .desc { font-size: 14px; color: #aab9a0; }
.card .key { font-size: 11px; color: #6e7c64; margin-top: 4px; }

.stats {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 28px;
  font-size: 18px;
  text-align: left;
}
.stats .label { color: #8b9a7f; }
.stats .value { font-weight: 800; }
.stats .new-best { grid-column: 1 / -1; text-align: center; color: #ffd54f; font-weight: 800; }

@media (max-width: 560px) {
  .card { width: 100%; max-width: 340px; padding: 14px; flex-direction: row; text-align: left; }
  .card .icon { font-size: 32px; }
  .card .key { display: none; }
}

.docs-link {
  color: #ffd54f;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dashed rgba(255, 213, 79, 0.5);
}
.docs-link:hover { color: #fff176; }

/* ---- progress (menu + game over) ---- */
.progress { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: #b7c4ab; min-width: min(420px, 90vw); }
.pchips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.pchip { padding: 2px 9px; border-radius: 999px; font-weight: 800; font-size: 12px; color: var(--rc); border: 1px solid var(--rc); background: color-mix(in srgb, var(--rc) 14%, transparent); }
.pchip.locked { opacity: 0.45; filter: grayscale(0.6); }
.pbar { width: min(420px, 90vw); height: 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.pbar div { height: 100%; border-radius: 6px; transition: width 0.3s; }
.ptext b { font-weight: 800; }
.ptitle { font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; }
.stats .progress { grid-column: 1 / -1; margin-top: 8px; }
.small-row { gap: 22px; align-items: center; }
.btn-admin {
  font-family: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  color: #cfd8dc; background: rgba(255, 255, 255, 0.06); border: 1px solid #455a64; border-radius: 8px; padding: 5px 12px;
}
.btn-admin:hover { background: rgba(255, 255, 255, 0.12); }

/* ---- unlock show ---- */
.showcase { gap: 10px; background: radial-gradient(ellipse at center, color-mix(in srgb, var(--rc) 22%, rgba(0,0,0,0.75)), rgba(0, 0, 0, 0.94)); cursor: pointer; }
.sc-title {
  font-family: 'Creepster', 'Rubik', cursive; font-weight: normal; letter-spacing: 3px;
  font-size: clamp(38px, 7vw, 72px); color: var(--rc); text-shadow: 0 0 26px var(--rc), 0 4px 0 #000;
  animation: sc-pop 0.6s ease-out;
}
@keyframes sc-pop { from { transform: scale(2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#sc-canvas { border: 3px solid var(--rc); border-radius: 14px; box-shadow: 0 0 34px color-mix(in srgb, var(--rc) 55%, transparent); background: #15191d; }
.sc-name { font-size: 26px; font-weight: 800; color: #fff; }
.sc-name .ic { font-size: 30px; }
.sc-tags { font-size: 13px; font-weight: 600; color: #b0bec5; text-transform: uppercase; letter-spacing: 1px; }
.sc-desc { font-size: 16px; color: #e0e6ea; max-width: 560px; }
.sc-desc small { color: #90a4ae; font-size: 13px; }
.sc-dots { display: flex; gap: 6px; font-size: 20px; }
.sc-dots span { opacity: 0.3; transition: opacity 0.2s, transform 0.2s; }
.sc-dots span.done { opacity: 0.6; }
.sc-dots span.on { opacity: 1; transform: scale(1.3); }
.sc-next { font-size: 13px; color: #90a4ae; }
.sc-skip { position: fixed; right: 18px; bottom: 14px; font-size: 15px; font-weight: 800; color: #fff; opacity: 0.85; }

/* ---- admin setup ---- */
.admin { justify-content: flex-start; overflow-y: auto; padding-top: 30px; }
.adm-row { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.adm-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #b7c4ab; text-align: left; }
.admin select, .admin input, .adm-panel select, .adm-panel input {
  font-family: inherit; font-size: 14px; color: #e8efe0; background: #1a2416; border: 1px solid #4a5a3f; border-radius: 6px; padding: 5px 8px;
}
.admin input { width: 110px; }
.adm-weapons { display: flex; flex-direction: column; gap: 8px; max-width: 1100px; }
.adm-group { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; justify-content: center; }
.adm-group b { width: 90px; text-align: right; margin-right: 6px; font-size: 13px; }
.adm-chip {
  font-family: inherit; font-size: 13px; cursor: pointer; color: #cfd8dc; padding: 4px 9px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid color-mix(in srgb, var(--rc) 40%, transparent);
}
.adm-chip.on { color: #fff; background: color-mix(in srgb, var(--rc) 30%, transparent); border-color: var(--rc); }
.adm-chip i { font-style: normal; font-weight: 800; color: #ffd54f; margin-left: 3px; }

/* ---- admin panel in game ---- */
.adm-panel {
  position: fixed; right: 10px; top: 92px; z-index: 5; width: 300px;
  background: rgba(10, 14, 12, 0.88); border: 1px solid #455a64; border-radius: 10px; padding: 6px; font-size: 13px;
}
.adm-panel.hidden { display: none; }
.adm-panel.collapsed .adm-body { display: none; }
.adm-head { width: 100%; font-family: inherit; font-weight: 800; letter-spacing: 1px; color: #ffd54f; background: none; border: none; cursor: pointer; padding: 2px; }
.adm-body { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.adm-line { display: flex; gap: 4px; }
.adm-line.hidden { display: none; }
.adm-line select { flex: 1; min-width: 0; }
.adm-line input { width: 52px; }
.adm-line button {
  flex: 1; font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
  color: #e8efe0; background: #2a3826; border: 1px solid #4a5a3f; border-radius: 6px; padding: 5px 4px;
}
.adm-line button:hover { background: #3a4d33; }
@media (max-width: 560px) { .adm-panel { width: 230px; top: auto; bottom: 10px; } }
.locked-r { color: #607d8b; }

.adm-chip:disabled { opacity: 0.35; cursor: not-allowed; filter: grayscale(0.7); }
.adm-row small { color: #7d8a72; font-size: 11px; }

/* ---- secret code box (bottom of the menu) ---- */
.codebox { display: flex; gap: 6px; margin-top: 4px; }
.codebox input {
  width: 190px; padding: 7px 12px; border-radius: 8px; border: 1px solid #3e4a38;
  background: rgba(0, 0, 0, 0.45); color: #e8efe0; font: 600 14px Rubik, system-ui, sans-serif; text-align: center;
}
.codebox input:focus { outline: none; border-color: #ffd54f; box-shadow: 0 0 12px rgba(255, 213, 79, 0.3); }
.codebox button {
  padding: 7px 12px; border-radius: 8px; border: 1px solid #3e4a38; cursor: pointer;
  background: #2a3326; color: #e8efe0; font: 800 13px Rubik, system-ui, sans-serif;
}
.code-msg { min-height: 18px; font-size: 14px; font-weight: 800; color: #ffd54f; }
.code-msg.bad { color: #ef9a9a; }
.admin.full .heading { color: #80deea; }

/* ---- tutorial box ---- */
.tut {
  position: fixed; left: 50%; top: 74px; transform: translateX(-50%); z-index: 60;
  width: min(520px, 92vw); padding: 12px 16px 14px; border-radius: 14px;
  background: rgba(10, 16, 24, 0.92); border: 2px solid #4fc3f7; box-shadow: 0 0 24px rgba(79, 195, 247, 0.35);
  color: #e3f2fd; text-align: center; pointer-events: auto;
}
.tut.hidden { display: none; }
.tut { pointer-events: none; } /* touches go through to the game (drag to move)... */
.tut button { pointer-events: auto; } /* ...except on its buttons */
.tut.low { top: auto; bottom: 16px; }
.tut-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #81d4fa; font-weight: 700; letter-spacing: 0.5px; }
.tut-head button { font: inherit; font-size: 12px; color: #cfd8dc; background: rgba(255,255,255,0.08); border: 1px solid #546e7a; border-radius: 6px; padding: 3px 9px; cursor: pointer; }
.tut-head button:hover { background: rgba(255,255,255,0.16); }
.tut-title { font-family: Creepster, Rubik, cursive; font-size: 30px; color: #4fc3f7; margin: 4px 0 2px; letter-spacing: 1px; }
.tut-text { font-size: 15px; line-height: 1.4; }
.tut-text kbd { background: #263238; border: 1px solid #546e7a; border-radius: 4px; padding: 0 5px; font-size: 13px; }
.tut-go { margin-top: 10px; }

/* =========================================================================
   Phones in landscape (and other short screens): everything smaller and tighter.
   Screens that are still too tall scroll instead of being cut off.
   ========================================================================= */
@media (max-height: 520px) {
  .overlay { gap: 7px; padding: 8px 10px; justify-content: flex-start; overflow-y: auto; }
  /* centered when it fits, scrolls from the top when it doesn't */
  .overlay > :first-child { margin-top: auto; }
  .overlay > :last-child { margin-bottom: auto; }

  .title { font-size: clamp(30px, 10vh, 52px); letter-spacing: 2px; }
  .heading { font-size: clamp(26px, 9vh, 40px); }
  .subtitle { font-size: 12px; max-width: 640px; }
  .hint { font-size: 11px; }

  .btn { font-size: 15px; padding: 8px 24px; letter-spacing: 1px; box-shadow: 0 3px 0 #557a2f; }
  .btn.secondary { box-shadow: 0 3px 0 #222a1e; }
  .diffs, .row { gap: 8px; }
  .btn.diff { min-width: 120px; padding: 6px 14px; gap: 1px; }
  .btn.diff small { font-size: 9px; }
  .btn.map { width: 200px; padding: 4px 10px; font-size: 13px; gap: 1px; }
  .btn.map small { font-size: 9px; line-height: 1.25; }

  .controls { display: none; } /* keyboard hints: you use touch on a phone */
  .best { font-size: 12px; min-height: 14px; }

  .progress { font-size: 11px; gap: 3px; }
  .pchip { font-size: 10px; padding: 1px 6px; }
  .pbar { height: 7px; }
  .ptitle { font-size: 10px; }
  .small-row { gap: 12px; }
  .docs-link { font-size: 12px; }
  .btn-admin { font-size: 12px; padding: 3px 9px; }
  .codebox { margin-top: 0; }
  .codebox input { width: 150px; padding: 4px 10px; font-size: 12px; }
  .codebox button { padding: 4px 10px; font-size: 12px; }
  .code-msg { min-height: 14px; font-size: 12px; }

  /* level up / chest cards */
  .cards { gap: 8px; flex-wrap: nowrap; max-width: 100%; }
  .card { width: auto; flex: 1 1 0; min-width: 0; max-width: 175px; padding: 8px 8px; gap: 3px; border-radius: 10px; }
  .card .icon { font-size: 26px; }
  .card .name { font-size: 14px; }
  .card .rarity, .card .lvl { font-size: 10px; letter-spacing: 1px; }
  .card[data-rarity="legendary"] .rarity, .card[data-rarity="ultra"] .rarity { font-size: 12px; }
  .card .desc { font-size: 11px; line-height: 1.25; }
  .card .key { display: none; }
  .luck { font-size: 10px; line-height: 1.4; }

  /* game over */
  .stats { font-size: 13px; gap: 2px 16px; }

  /* unlock show */
  .sc-title { font-size: clamp(24px, 8vh, 40px); }
  .sc-name { font-size: 16px; }
  .sc-name .ic { font-size: 18px; }
  .sc-tags { font-size: 10px; }
  .sc-desc { font-size: 12px; }
  .sc-desc small { font-size: 10px; }
  .sc-dots { font-size: 13px; gap: 3px; }
  .sc-next { font-size: 11px; }
  .sc-skip { font-size: 12px; bottom: 6px; right: 10px; }

  /* admin setup */
  .admin { padding-top: 8px; }
  .adm-row { gap: 10px; }
  .adm-row label { font-size: 11px; }
  .admin select, .admin input { font-size: 12px; padding: 3px 6px; }
  .admin input { width: 80px; }
  .adm-weapons { gap: 4px; }
  .adm-group { gap: 3px; }
  .adm-group b { width: 70px; font-size: 11px; }
  .adm-chip { font-size: 11px; padding: 2px 6px; }
  /* Start / Clear / Back always visible at the bottom */
  .admin .row { position: sticky; bottom: -8px; padding: 6px 0 8px; width: 100%; background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,0.9) 30%); }

  /* admin panel during a run: smaller, scrolls if it is too tall */
  .adm-panel { top: 82px; width: 240px; font-size: 11px; padding: 4px; max-height: calc(100vh - 88px); overflow-y: auto; }
  .adm-body { gap: 3px; }
  .adm-panel select, .adm-panel input { font-size: 11px; padding: 2px 4px; }
  .adm-line button { font-size: 10px; padding: 3px 2px; }

  /* tutorial box */
  .tut { top: auto; bottom: 8px; width: min(440px, 60vw); padding: 5px 10px 7px; border-radius: 10px; }
  .tut.low { bottom: 6px; }
  .tut-head { font-size: 10px; }
  .tut-head button { font-size: 10px; padding: 2px 6px; }
  .tut-title { font-size: 20px; margin: 1px 0; }
  .tut-text { font-size: 12px; line-height: 1.3; }
  .tut-text kbd { font-size: 11px; }
  .tut-go { margin-top: 5px; }
}

/* pause button (only on touch screens: there is no Esc key on a phone) */
.btn-pause {
  position: fixed; left: 10px; bottom: 10px; z-index: 6;
  width: 44px; height: 44px; border-radius: 50%; font-size: 20px; cursor: pointer;
  color: #e8efe0; background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(255, 255, 255, 0.25);
}
.btn-pause.hidden { display: none; }
@media (hover: hover) and (pointer: fine) { .btn-pause { display: none; } }
.sc-skip { cursor: pointer; }
