:root {
  --ink: #1d2433;
  --paper: rgba(255, 255, 255, 0.92);
  --accent: #2f80ed;
  --accent-2: #ffb02e;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #8fd3ff;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }
.dim { opacity: 0.6; }
.small { font-size: 15px; }
.center { text-align: center; margin-top: 12px; }
.col { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }

#pet-card {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 8px 14px;
  min-width: 150px;
  box-shadow: var(--shadow);
}
#pet-card .label { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.6; }
#pet-name { font-weight: 700; font-size: 19px; margin-top: 1px; }
#pet-speed { font-size: 15px; color: var(--accent); font-weight: 700; }

#top-centre {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
#compass {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  box-shadow: var(--shadow);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
#compass-arrow {
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 16px solid var(--accent-2);
  transform-origin: 50% 70%;
}
#event {
  background: #ff4d6d;
  color: #fff;
  border-radius: 999px;
  padding: 6px 16px;
  font-weight: 800;
  font-size: 15px;
  box-shadow: var(--shadow);
  animation: pulse 1s ease-in-out infinite alternate;
  white-space: nowrap;
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.06); } }

#top-right {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
#coins {
  position: relative;
  background: var(--paper);
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.coin-icon { font-size: 18px; }
.coin-float {
  position: absolute;
  right: 10px;
  top: 100%;
  color: #2e9e5b;
  font-weight: 800;
  font-size: 16px;
  text-shadow: 0 1px 4px rgba(255, 255, 255, 0.9);
  animation: coinfloat 1.2s ease-out forwards;
  pointer-events: none;
}
.coin-float.minus { color: #d9534f; }
@keyframes coinfloat {
  0% { opacity: 0; transform: translateY(0); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translateY(26px); }
}
#bag {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 8px 10px 6px;
  box-shadow: var(--shadow);
  text-align: center;
}
#bag-slots { display: flex; gap: 6px; justify-content: center; }
#bag-label { font-size: 14px; opacity: 0.65; margin-top: 4px; }
.egg {
  width: 26px; height: 32px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: #cfd6de;
  border: 2px solid rgba(0, 0, 0, 0.15);
  box-shadow: inset -4px -6px 0 rgba(0, 0, 0, 0.12);
  flex: none;
}
.egg.empty { background: transparent; border: 2px dashed rgba(0, 0, 0, 0.25); box-shadow: none; }
.egg.lg { width: 56px; height: 70px; }

#hud-buttons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 260px; }
.hud-btn, button.primary, button.secondary, button.tiny {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  border: 0;
  border-radius: 999px;
  padding: 9px 15px;
  cursor: pointer;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.hud-btn { background: var(--paper); color: var(--ink); position: relative; }
.hud-btn.badged::after {
  content: '';
  position: absolute;
  top: -3px; right: -3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #ff4d6d;
  border: 2px solid #fff;
}
button.primary { background: var(--accent); color: #fff; }
button.secondary { background: #e8edf3; color: var(--ink); }
button.tiny { background: #f3f6fa; color: var(--ink); box-shadow: none; padding: 5px 10px; font-size: 14px; }
button:disabled { opacity: 0.5; cursor: default; }

#zone-banner {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  animation: banner 2.4s ease forwards;
  pointer-events: none;
  white-space: nowrap;
}
#zone-banner.rain { color: #ffe066; font-size: 40px; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#prompt {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 15px;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
kbd {
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  padding: 1px 7px;
  font-family: inherit;
  font-size: 14px;
}

#toasts {
  position: absolute;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: 100%;
}
.toast {
  background: rgba(29, 36, 51, 0.88);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  animation: toast 2.6s ease forwards;
  max-width: 92vw;
  text-align: center;
}
.toast.good { background: #2e9e5b; }
.toast.warn { background: #d9534f; }
.toast.uncommon { background: #3aa54a; }
.toast.rare { background: #4a90ff; }
.toast.epic { background: #b25cff; }
.toast.legendary { background: #ffa33a; color: var(--ink); }
.toast.mythic { background: #ff4d6d; }
@keyframes toast {
  0% { opacity: 0; transform: translateY(8px); }
  10% { opacity: 1; transform: translateY(0); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

#hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  white-space: nowrap;
}

#joystick {
  position: absolute;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#joystick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  transform: translate(-50%, -50%);
}
#btn-jump {
  position: absolute;
  right: 24px;
  bottom: 28px;
  width: 84px; height: 84px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.85);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  box-shadow: var(--shadow);
}
#btn-nest {
  position: absolute;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  background: var(--accent-2);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

#modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 10;
}
#modal-box {
  position: relative;
  background: #fff;
  border-radius: 20px;
  width: min(640px, 100%);
  max-height: min(92vh, 720px);
  overflow: auto;
  padding: 20px 20px 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  font-size: 16px;
}
#modal-close {
  position: absolute;
  top: 10px; right: 12px;
  border: 0;
  background: #eef2f6;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
#modal-content h2 { margin: 0 0 4px; font-size: 24px; padding-right: 36px; }
#modal-content h3 { margin: 14px 0 8px; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.6; }
#modal-content p.sub { margin: 0 0 8px; opacity: 0.75; }
#modal-content a { color: var(--accent); cursor: pointer; font-weight: 700; }
.coin-tag { font-weight: 800; white-space: nowrap; }

.nest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .nest-grid { grid-template-columns: 1fr; } }
.egg-list { display: flex; flex-wrap: wrap; gap: 10px; }
.egg-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: #f3f6fa; border: 0; border-radius: 14px; padding: 10px 12px;
  font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
}
.egg-btn:hover { background: #e4ebf4; }
.slot {
  display: flex; align-items: center; gap: 12px;
  background: #f3f6fa; border-radius: 14px; padding: 10px 12px; margin-bottom: 8px;
}
.slot .info { flex: 1; }
.slot .name { font-weight: 700; }
.slot .time { font-size: 15px; opacity: 0.7; }
.slot.ready { background: #e6f7ec; }
.slot.empty { opacity: 0.6; border: 2px dashed rgba(0, 0, 0, 0.15); background: transparent; }

.pet-row, .shop-card, .quest {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; border-radius: 12px; margin-bottom: 6px; background: #f3f6fa;
}
.pet-row .swatch, .index-card .swatch {
  width: 36px; height: 36px; border-radius: 10px; border: 3px solid transparent; flex: none;
}
.pet-row .info, .shop-card .info, .quest .info { flex: 1; min-width: 0; }
.pet-row .name, .shop-card .name, .quest .name { font-weight: 700; }
.pet-row .meta, .shop-card .meta, .quest .meta { font-size: 15px; opacity: 0.75; }
.pet-row.equipped { outline: 2px solid var(--accent); }
.riding { font-weight: 800; color: var(--accent); }

.levels { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 15px; }
.pip { width: 12px; height: 12px; border-radius: 50%; background: #d5dbe3; display: inline-block; }
.pip.on { background: var(--accent-2); }

.index-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.index-card { background: #f3f6fa; border-radius: 14px; padding: 10px; text-align: center; }
.index-card .swatch { margin: 0 auto 6px; }
.index-card .name { font-weight: 700; font-size: 15px; }
.index-card .meta { font-size: 14px; opacity: 0.75; }
.index-card.unknown { opacity: 0.55; }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day {
  background: #f3f6fa; border-radius: 12px; padding: 8px 4px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 14px;
  border: 2px solid transparent;
}
.day .d { font-weight: 700; opacity: 0.7; }
.day .v { font-weight: 700; line-height: 1.2; }
.day .coin-big { font-size: 26px; line-height: 32px; }
.day.done { opacity: 0.45; }
.day.now { border-color: var(--accent-2); background: #fff6e0; }
.day.claimed { border-color: #2e9e5b; background: #e6f7ec; }
@media (max-width: 560px) { .days { grid-template-columns: repeat(4, 1fr); } }

.quest .bar { height: 8px; border-radius: 4px; background: #dfe5ec; margin: 6px 0 4px; overflow: hidden; }
.quest .fill { height: 100%; background: var(--accent); border-radius: 4px; }
.quest.claimed { opacity: 0.55; }

.settings .row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.settings .row > span:first-child { width: 90px; font-weight: 700; }
.settings input[type=range] { flex: 1; min-width: 80px; }
.settings button { min-width: 64px; }

.reveal { text-align: center; padding: 10px 0; }
.reveal .preview-wrap {
  width: 220px; height: 220px; border-radius: 32px; margin: 0 auto 12px;
  border: 5px solid transparent;
  background: radial-gradient(circle at 50% 35%, #f6f9ff, #dde6f2);
  overflow: hidden;
  animation: pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.preview-canvas { width: 100%; height: 100%; display: block; }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.reveal h2 { font-size: 28px; padding-right: 0; }
.reveal .reveal-text { transition: opacity 0.3s; }
.reveal.cracking .reveal-text { opacity: 0; }
.reveal .actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 14px; font-weight: 700; color: #fff; vertical-align: middle;
}

#splash {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #8fd3ff, #c9efb6);
  padding: 16px;
}
#splash-box {
  text-align: center;
  background: var(--paper);
  padding: 28px 36px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  max-width: 100%;
}
#splash-egg {
  width: 54px; height: 68px; margin: 0 auto 8px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: var(--accent-2);
  border: 3px solid var(--ink);
  box-shadow: inset -8px -10px 0 rgba(0, 0, 0, 0.12);
  animation: wobble 1.6s ease-in-out infinite;
}
@keyframes wobble { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
#splash h1 { margin: 0 0 6px; font-size: 40px; }
#splash p { margin: 0 0 16px; opacity: 0.75; font-size: 16px; }
#splash-bar { height: 10px; border-radius: 5px; background: #dfe5ec; overflow: hidden; margin: 0 auto 16px; width: 240px; max-width: 100%; }
#splash-fill { height: 100%; width: 8%; background: var(--accent); border-radius: 5px; transition: width 0.3s; }
#splash:not(.loading) #splash-bar { display: none; }
#btn-start {
  font: inherit; font-size: 22px; font-weight: 800;
  border: 0; border-radius: 999px; padding: 14px 48px;
  background: var(--accent); color: #fff; cursor: pointer;
  box-shadow: var(--shadow);
}
#splash.loading #btn-start { opacity: 0.5; pointer-events: none; }
#splash-fail { color: #d9534f; font-weight: 700; margin-top: 12px; }

/* phones and short windows */
@media (max-width: 700px), (max-height: 480px) {
  #pet-card { padding: 6px 10px; min-width: 120px; }
  #pet-card .label { display: none; }
  #pet-name { font-size: 17px; }
  #hud-buttons { max-width: 200px; }
  .hud-btn { padding: 8px 11px; font-size: 15px; }
  #zone-banner { font-size: 24px; top: 64px; }
  #hint { display: none; }
  #toasts { bottom: 120px; }
  #modal-box { padding: 16px 14px 12px; border-radius: 16px; }
  #splash h1 { font-size: 32px; }
  #splash-box { padding: 20px 22px; }
}
@media (max-height: 480px) {
  .reveal .preview-wrap { width: 150px; height: 150px; margin-bottom: 6px; }
  .reveal h2 { font-size: 24px; margin-bottom: 2px; }
  .reveal .actions { margin-top: 8px; }
}
/* upright phones: the compass and the event sit under the pet card, the
   zone banner below the right-hand column, so nothing overlaps */
@media (max-width: 480px) {
  #top-centre { top: 70px; left: 12px; transform: none; align-items: flex-start; }
  #compass, #event { font-size: 15px; }
  #zone-banner { top: 230px; font-size: 26px; }
  #zone-banner.rain { font-size: 32px; }
  #hud-buttons { max-width: 180px; }
  .egg { width: 20px; height: 26px; }
  #bag { padding: 6px 8px 4px; }
}
