* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fdcff; font-family: 'Fredoka', 'Trebuchet MS', sans-serif; color: #1d3557; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
canvas { display: block; touch-action: none; }
button { font-family: inherit; font-size: 17px; font-weight: 600; border: 0; border-radius: 12px; padding: 10px 16px; margin: 4px 4px 4px 0; cursor: pointer; background: #2ec4b6; color: white; touch-action: manipulation; }
button.alt { background: #e3eaf0; color: #1d3557; }
button.red { background: #e63946; }
button.gold { background: #f4a100; }
button:disabled { opacity: 0.45; cursor: default; }
button.small { font-size: 14px; padding: 6px 10px; }
kbd { display: inline-block; background: #e3eaf0; border-radius: 6px; padding: 0 6px; font-family: inherit; font-weight: 600; font-size: 0.9em; color: #1d3557; }
.muted { color: #6b7a90; }
.hidden { display: none !important; }

/* ---- eggs drawn in CSS (for the menus) ---- */
.egg { display: inline-block; width: 20px; height: 26px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; vertical-align: middle; box-shadow: inset -3px -3px 0 rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.25); position: relative; flex: none; }
.egg.speckled { background: radial-gradient(circle at 30% 35%, #9c7a54 2px, transparent 3px), radial-gradient(circle at 65% 60%, #9c7a54 2px, transparent 3px), radial-gradient(circle at 45% 80%, #9c7a54 1.5px, transparent 2.5px), #f3e6c8; }
.egg.silver { background: radial-gradient(circle at 35% 30%, #fff 3px, transparent 5px), linear-gradient(160deg, #eef2f6, #aab4c2); }
.egg.gold { background: radial-gradient(circle at 35% 30%, #fff6c0 3px, transparent 5px), linear-gradient(160deg, #ffe066, #e09a00); box-shadow: 0 0 8px #ffd23f, inset -3px -3px 0 rgba(0,0,0,0.12); }
.egg.tank { background: radial-gradient(circle at 30% 30%, #3d5a1e 3px, transparent 4.5px), radial-gradient(circle at 68% 55%, #3d5a1e 3.5px, transparent 5px), radial-gradient(circle at 40% 78%, #56752c 3px, transparent 4.5px), #7a9a45; }
.egg.rainbow { background: linear-gradient(180deg, #ff5d8f 0 16%, #ff9f43 16% 32%, #ffd166 32% 48%, #6ede8a 48% 64%, #4cc9f0 64% 80%, #9b5de5 80%); box-shadow: 0 0 10px #ff8fd8, inset -3px -3px 0 rgba(0,0,0,0.12); }
.egg.none { background: transparent; border: 2px dashed #b8c4d4; box-shadow: none; }
.egg.big { width: 34px; height: 44px; }

/* ---- HUD during a raid ---- */
.panel { position: fixed; background: rgba(255,255,255,0.92); border-radius: 14px; padding: 8px 14px; box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
#topbtns { position: fixed; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 3; }
#topbtns button { margin: 0; font-size: 20px; padding: 8px 12px; background: rgba(255,255,255,0.92); color: #1d3557; box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
#castles { top: 10px; left: 50%; transform: translateX(-50%); padding: 6px 12px 8px; width: min(560px, calc(100vw - 250px)); }
#castles .bars { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; font-weight: 700; font-size: 14px; }
#castles .hp { height: 14px; border-radius: 7px; background: #e3eaf0; overflow: hidden; position: relative; }
#castles .hp i { position: absolute; top: 0; bottom: 0; left: 0; background: #2ec4b6; border-radius: 7px; transition: width 0.15s; }
#castles .hp.them i { left: auto; right: 0; background: #e63946; }
#castles .who { display: flex; justify-content: space-between; font-size: 13px; }
#castles .vs { font-size: 13px; color: #6b7a90; }
#mini { width: 100%; height: auto; aspect-ratio: 520 / 190; max-height: 82px; margin-top: 6px; border-radius: 8px; display: block; cursor: pointer; }
#wave { top: 10px; left: 68px; font-size: 15px; line-height: 1.3; min-width: 150px; } /* (room for the 🏠 at the top left) */
#wave .big { font-size: 22px; font-weight: 700; }
#wave .track { height: 8px; border-radius: 4px; background: #e3eaf0; margin-top: 4px; overflow: hidden; }
#wave .track i { display: block; height: 100%; background: #ffd166; }
#sendall { position: fixed; right: 16px; bottom: 16px; width: 104px; height: 104px; border-radius: 50%; font-size: 17px; line-height: 1.1; background: #e63946; box-shadow: 0 6px 16px rgba(0,0,0,0.25); padding: 0; margin: 0; }
#sendall .big { font-size: 34px; display: block; }
/* the Rally Horn: fills up like a clock while it recharges, glows and bounces when it's ready */
#rally { position: fixed; right: 30px; bottom: 132px; width: 76px; height: 76px; border-radius: 50%; padding: 0; margin: 0; font-size: 13px; line-height: 1.05; color: #5a3b00;
  background: radial-gradient(circle, #ffe7a3 0 58%, transparent 59%), conic-gradient(#ffb703 calc(var(--k, 0) * 1turn), rgba(90,70,30,0.35) 0); box-shadow: 0 5px 14px rgba(0,0,0,0.25); }
#rally .big { font-size: 28px; display: block; }
#rally.ready { background: radial-gradient(circle, #ffd166 0 58%, #ffb703 59%); animation: rallyPulse 1.1s ease-in-out infinite; }
#rally.on { background: radial-gradient(circle, #ff9f1c 0 58%, #ff6b35 59%); color: #fff; animation: rallyPulse 0.35s ease-in-out infinite; }
@keyframes rallyPulse { 50% { scale: 1.08; box-shadow: 0 0 0 8px rgba(255,183,3,0.35), 0 5px 14px rgba(0,0,0,0.25); } }
/* Sir Squeaks' tips after a lost raid, and each land's line on the raid card */
.coach { background: #eef6ff; border: 2px solid #4cc9f0; border-radius: 14px; padding: 8px 12px; margin: 10px 0; text-align: left; font-size: 15px; line-height: 1.4; }
.coach b { color: #1d3557; } .coach ul { margin: 6px 0 0; padding-left: 20px; } .coach li { margin: 4px 0; }
.raidcard .land { display: block; margin-bottom: 4px; font-weight: 600; } .raidcard .land .muted { font-weight: 400; }
#squads { position: fixed; left: 70px; right: 132px; bottom: 10px; display: flex; gap: 6px; justify-content: safe center; flex-wrap: nowrap; overflow-x: auto; padding: 6px 2px 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
#squads:empty { display: none; }
#squads::-webkit-scrollbar { display: none; }
#squads button { flex: none; }
#squads button { margin: 0; background: rgba(255,255,255,0.95); color: #1d3557; box-shadow: 0 4px 12px rgba(0,0,0,0.18); padding: 6px 10px; font-size: 15px; display: flex; align-items: center; gap: 5px; border: 3px solid transparent; }
#squads button.on { border-color: #ffd166; background: #fff6d8; }
#squads button .num { background: #2ec4b6; color: #fff; border-radius: 8px; padding: 0 6px; font-size: 13px; }
#squads button .st { font-size: 13px; }
.badge { position: absolute; transform: translate(-50%, -100%); background: #2ec4b6; color: #fff; font-weight: 700; font-size: 13px; border-radius: 9px; padding: 0 7px; box-shadow: 0 2px 5px rgba(0,0,0,0.25); border: 2px solid #fff; }
.badge.on { background: #ffd166; color: #1d3557; }
#timer { font-size: 22px; font-weight: 700; }
#caster { position: fixed; top: 100px; left: 50%; transform: translate(-50%, -6px); background: rgba(29,53,87,0.88); color: #fff; padding: 7px 14px; border-radius: 12px;
  font-size: 15px; max-width: min(560px, calc(100vw - 250px)); text-align: center; pointer-events: none; opacity: 0; transition: opacity 0.3s, transform 0.3s; }
#caster.on { opacity: 1; transform: translate(-50%, 0); }
#caster b { color: #ffd166; }
#timer.low { color: #e63946; }
#hint { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); width: max-content; background: rgba(29,53,87,0.88); color: #fff; padding: 8px 16px; border-radius: 12px; font-size: 16px; text-align: center; max-width: min(70vw, 560px); pointer-events: none; }
#hint:empty { display: none; }
#zoom { position: fixed; left: 12px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
#zoom button { margin: 0; width: 46px; height: 46px; padding: 0; font-size: 22px; background: rgba(255,255,255,0.92); color: #1d3557; box-shadow: 0 4px 14px rgba(0,0,0,0.15); }

#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.say { position: absolute; transform: translate(-50%, -100%); background: #fff; border-radius: 16px; padding: 6px 12px; font-size: 16px; font-weight: 600; box-shadow: 0 3px 10px rgba(0,0,0,0.2); white-space: nowrap; }
.say::after { content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -8px; border: 8px solid transparent; border-bottom: 0; border-top-color: #fff; }
.say.hidden { display: none; }

#toasts { position: fixed; top: 96px; right: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: none; z-index: 4; }
.toast { background: rgba(29,53,87,0.92); color: white; padding: 8px 14px; border-radius: 10px; font-size: 16px; animation: fade 4s forwards; max-width: 340px; }
.toast.good { background: rgba(46,196,182,0.95); }
.toast.bad { background: rgba(230,57,70,0.95); }
@keyframes fade { 0% { opacity: 0; transform: translateX(20px); } 8% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }

body.camp #topbtns { right: auto; left: 68px; }
body.camp #toasts { right: auto; left: 12px; top: 64px; align-items: flex-start; }
/* ---- your kingdom (between raids): a panel on the right, your castle on the left ---- */
#camp { position: fixed; top: 10px; right: 10px; bottom: 10px; width: min(420px, 56vw); background: rgba(255,255,255,0.95); border-radius: 22px; box-shadow: 0 10px 30px rgba(0,0,0,0.25); display: flex; flex-direction: column; overflow: hidden; z-index: 2; }
#camp .head { padding: 12px 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#camp h1 { margin: 0; font-size: 24px; color: #e63946; line-height: 1.1; }
#camp .coins { font-size: 22px; font-weight: 700; white-space: nowrap; }
#camp .scroll { overflow-y: auto; padding: 0 16px 12px; flex: 1; -webkit-overflow-scrolling: touch; }
#camp .foot { padding: 10px 16px 12px; border-top: 1px solid #eef2f6; display: flex; gap: 8px; align-items: center; }
#camp .foot button { margin: 0; }
#go { flex: 1; font-size: 22px; padding: 12px; background: #e63946; }
.tabs { display: flex; gap: 6px; margin: 10px 16px 8px; }
.tabs button { margin: 0; flex: 1; background: #e3eaf0; color: #1d3557; padding: 8px; }
.tabs button.on { background: #2ec4b6; color: #fff; }
h3 { margin: 12px 0 6px; font-size: 17px; }
.nests { display: flex; gap: 8px; flex-wrap: wrap; }
.nest { background: #fff7e6; border: 2px solid #f0d9a8; border-radius: 14px; padding: 6px 8px; min-width: 70px; text-align: center; cursor: pointer; font-size: 12px; line-height: 1.2; color: #6b5a3a; }
@media (hover: hover) { .nest:hover { border-color: #e0b760; } }
.nest .nm { display: block; margin-top: 3px; font-weight: 600; }
.nest.locked { opacity: 0.45; cursor: default; background: #f3f5f8; border-color: #e3eaf0; }
.raids { display: grid; gap: 8px; }
.raid { border: 2px solid #e3eaf0; border-radius: 14px; padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; }
.raid.on { border-color: #e63946; background: #fff0f1; }
.raid.locked { opacity: 0.5; cursor: default; }
.raid .t { font-weight: 700; font-size: 17px; }
.raid .s { font-size: 13px; color: #6b7a90; }
.raid .rw { text-align: right; font-size: 14px; font-weight: 600; white-space: nowrap; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #eef2f6; }
.row:last-child { border-bottom: 0; }
.row .item { display: flex; align-items: center; gap: 10px; }
.row .emoji { font-size: 26px; width: 34px; text-align: center; }
.row .sub { font-size: 13px; color: #6b7a90; }
.pips { letter-spacing: 1px; color: #f4a100; font-size: 13px; }
.row button { margin: 0; white-space: nowrap; }
.basket { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.basket span { display: flex; align-items: center; gap: 4px; }

/* raid picker */
.picker { display: flex; align-items: center; gap: 6px; }
.picker button { margin: 0; padding: 8px 11px; }
.picker .rp { flex: 1; text-align: center; }
.picker .rp .t { font-weight: 700; font-size: 20px; }
.picker .rp .s { font-size: 12px; color: #6b7a90; }
.raidcard { border: 2px solid #e63946; background: #fff0f1; border-radius: 14px; padding: 8px 12px; margin-top: 8px; font-size: 14px; line-height: 1.5; }
.raidcard.boss { border-color: #9b5de5; background: #f5eeff; }
.raidcard .gerry-eggs { display: inline-flex; gap: 3px; vertical-align: middle; }
.progress { height: 10px; border-radius: 5px; background: #e3eaf0; overflow: hidden; margin: 4px 0 2px; position: relative; }
.progress i { display: block; height: 100%; background: #2ec4b6; }
.progress b { position: absolute; top: -2px; width: 3px; height: 14px; background: #9b5de5; }
/* ---- menus ---- */
.modal { position: fixed; inset: 0; background: rgba(20,30,60,0.35); display: none; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; z-index: 5; }
.modal.open { display: flex; }
.box { background: #fff; border-radius: 22px; padding: 22px 26px; width: 520px; max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.3); margin: auto; }
.box h1 { margin: 0 0 4px; color: #e63946; font-size: 32px; }
.box h2 { margin: 0 0 8px; font-size: 26px; }
.keys { font-size: 14px; color: #6b7a90; line-height: 1.8; margin-top: 10px; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 6px; }
.teams button { margin: 0; font-size: 22px; padding: 18px 10px; line-height: 1.3; }
.teams button .e { font-size: 54px; display: block; }
.teams button .s { font-size: 13px; font-weight: 400; display: block; opacity: 0.9; }
.prize { display: flex; align-items: center; gap: 14px; background: #fff7e6; border-radius: 14px; padding: 10px 14px; margin: 10px 0; font-size: 18px; font-weight: 600; }

@media (max-width: 760px), (max-height: 480px) {
  #castles { width: min(420px, calc(100vw - 220px)); padding: 4px 10px 6px; }
  #castles .who { font-size: 11px; } #mini { max-height: 46px; }
  #wave { font-size: 12px; min-width: 110px; padding: 6px 10px; } #wave .big { font-size: 17px; }
  #sendall { width: 84px; height: 84px; font-size: 14px; } #sendall .big { font-size: 26px; }
  #rally { width: 62px; height: 62px; right: 27px; bottom: 104px; font-size: 11px; } #rally .big { font-size: 22px; }
  #squads { left: 58px; right: 104px; bottom: 6px; } #squads button { font-size: 13px; padding: 4px 7px; }
  #hint { bottom: 56px; } #timer { font-size: 17px; }
  #caster { top: 82px; font-size: 13px; padding: 5px 10px; max-width: calc(100vw - 230px); }
  #zoom button { width: 40px; height: 40px; font-size: 18px; }
  #camp h1 { font-size: 19px; } #camp .coins { font-size: 18px; }
  #go { font-size: 18px; padding: 9px; }
  .raid .t { font-size: 15px; }
  #hint { font-size: 13px; }
  .box { padding: 16px 18px; }
}

/* phones held sideways (short screens): the raid's result card is wider and tighter, so "Back to your kingdom" shows
   without scrolling (with Sir Squeaks' tips it was below the bottom of the screen) */
@media (max-height: 500px) {
  #resultbox { width: 720px; padding: 12px 20px; }
  #resultbox h1 { font-size: 26px; }
  #resultbox .prize { padding: 6px 12px; margin: 6px 0; font-size: 16px; }
  #resultbox .coach { margin: 6px 0; font-size: 14px; padding: 6px 12px; } #resultbox .coach li { margin: 2px 0; }
  /* (in a raid: Sir Squeaks' line goes just under the map strip, not over it, and the tips under him, not on top of
     his words) */
  #caster { top: 100px; }
  #toasts { top: 136px; } .toast { font-size: 14px; padding: 6px 12px; max-width: 300px; }
}

/* words that pop up in the world */
.pop { position: absolute; white-space: nowrap; pointer-events: none; font-weight: 700; will-change: transform; }
.pop.cry { background: #fff; color: #1d3557; border-radius: 14px; padding: 4px 10px; font-size: 15px; box-shadow: 0 3px 8px rgba(0,0,0,0.2); }
.pop.hit { font-size: 22px; letter-spacing: 1px; -webkit-text-stroke: 1.5px #1d3557; text-shadow: 2px 2px 0 #1d3557; }
.pop.hit.c0 { color: #ffd166; } .pop.hit.c1 { color: #ff5d8f; } .pop.hit.c2 { color: #4cc9f0; } .pop.hit.c3 { color: #ff9f43; }
@media (max-width: 760px), (max-height: 480px) { .pop.hit { font-size: 17px; } .pop.cry { font-size: 12px; } }

#squads button .go { font-size: 12px; background: #e63946; color: #fff; border-radius: 8px; padding: 1px 6px; }

body.camp #toasts { left: 70px; } /* (clear of the 🔊 under the 🏠; on wide screens it's beside the 🏠, below) */
/* (an upright phone: the camp window takes most of the width, so its messages ("Welcome to your kingdom!...") sat right
   over its Raid / Upgrades / Friends tabs for 4 s. Down by the Go! button instead, where they cover only the list) */
@media (orientation: portrait) and (max-width: 600px) { body.camp #toasts { top: auto; bottom: 86px; right: 16px; left: auto; align-items: flex-end; }
  #camp .tabs { gap: 4px; margin: 8px 10px 6px; } #camp .tabs button { min-width: 0; padding: 6px 2px; font-size: 13px; } /* (and its three tabs fit: "Friends" ran off the edge) */
  /* (the raid: the clock box and the castles' bar overlapped at the top, and the hint ran into Send all: the bar across
     the top between 🏠 and ⏸, the clock under it, Sir Squeaks and the messages below, the hint above the buttons) */
  #castles { left: 62px; right: 62px; transform: none; width: auto; } #wave { top: 104px; left: 62px; min-width: 0; }
  #caster { top: 214px; max-width: calc(100vw - 24px); } body:not(.camp) #toasts { top: 300px; } #hint { left: 12px; transform: none; bottom: 136px; max-width: calc(100vw - 130px); } }
/* the round 🔊 / 🔇 button (made in index.html): under the 🏠 on phones and narrow screens, beside it on an iPad or a
   computer, where the top-left box moves over to make room */
.paws-sound { position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 52px); left: max(10px, env(safe-area-inset-left)); z-index: 60; width: 44px; height: 44px; margin: 0; padding: 0; border: 2px solid rgba(29, 53, 87, 0.15); border-radius: 50%; background: rgba(255, 255, 255, 0.94); color: #1d3557; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2); font-size: 20px; line-height: 1; display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.paws-sound:active { transform: scale(0.92); }
@media (min-width: 1000px) and (min-height: 501px) {
  .paws-sound { top: max(10px, env(safe-area-inset-top)); left: calc(max(10px, env(safe-area-inset-left)) + 52px); }
  #wave { left: 122px; } body.camp #topbtns { left: 122px; } body.camp #toasts { left: 12px; }
}

/* (a narrow screen, like a phone held upright: windows start clear of the 🏠 and the 🔊 under it, like Splash's menu) */
@media (max-width: 660px) { .modal { padding-left: 70px; } }
