/* Pixel UI in the Kenney Tiny Town palette. */
:root {
  --outline: #3f2631;
  --panel: #262b44;
  --card: #2e3555;
  --well: #1b2036;
  --button: #3a4466;
  --button-hi: #46527c;
  --text: #fff7e8;
  --muted: #a9b4d0;
  --gold: #fdbe53;
  --orange: #e38628;
  --green: #84c669;
  --red: #e84537;
  --font: "Pixelify Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font);
  font-size: 15px;
  background: var(--panel);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
#game { flex: 1; min-width: 0; position: relative; }
#game canvas { touch-action: none; }

/* --- Side panel --- */
#hud {
  width: 286px;
  padding: 12px;
  overflow-y: auto;
  background: var(--panel);
  border-left: 4px solid var(--outline);
  scrollbar-width: thin;
  scrollbar-color: var(--button) transparent;
}
.card {
  animation: cardIn .45s cubic-bezier(.2, .9, .3, 1.2) backwards;
  margin-bottom: 10px;
  padding: 10px 12px 12px;
  background: var(--card);
  border: 3px solid var(--outline);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .06), inset 0 -4px 0 rgba(0, 0, 0, .22);
}
.head { background: linear-gradient(180deg, #3a4466, var(--card)); }
h1 { margin: 0; font-size: 24px; font-weight: 700; color: var(--gold); text-shadow: 2px 2px 0 var(--outline); letter-spacing: .5px; }
h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.row h2 { margin-bottom: 6px; }
#status, small, .help { font-size: 13px; color: var(--muted); }
.help { margin: 8px 0 0; line-height: 1.55; }
.credit { margin: 10px 0 0; font-size: 11px; color: #6f7a99; }
kbd {
  padding: 0 5px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--button);
  border: 2px solid var(--outline);
  border-bottom-width: 3px;
}
#level { color: var(--gold); font-size: 16px; }

.bar {
  height: 16px;
  background: var(--well);
  border: 3px solid var(--outline);
  overflow: hidden;
}
#xpbar {
  height: 100%;
  width: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .45) 0 3px, transparent 3px),
    repeating-linear-gradient(90deg, var(--gold) 0 8px, #f2ad3d 8px 10px);
  transition: width .35s cubic-bezier(.2, .9, .3, 1.2);
}

@keyframes cardIn { from { opacity: 0; transform: translateX(18px); } }
#hud .card:nth-child(2) { animation-delay: .05s; }
#hud .card:nth-child(3) { animation-delay: .1s; }
#hud .card:nth-child(4) { animation-delay: .15s; }
#hud .card:nth-child(5) { animation-delay: .2s; }
#hud .card:nth-child(n + 6) { animation-delay: .25s; }
#hint { transition: opacity .3s; }
.actions button:not(:disabled):hover .title { color: var(--gold); }

/* --- Inventory slots --- */
#inventory { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.slot {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: var(--well);
  border: 3px solid var(--outline);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, .3);
}
.slot .icon { width: 32px; height: 32px; }
.slot b {
  position: absolute;
  right: 3px;
  bottom: 0;
  font-size: 14px;
  text-shadow: 2px 0 0 var(--outline), -2px 0 0 var(--outline), 0 2px 0 var(--outline), 0 -2px 0 var(--outline);
}
.slot span { display: none; }
.slot.empty .icon { opacity: .35; filter: grayscale(1); }
.slot.empty b { color: var(--muted); }
.slot.bump { animation: bump .35s ease-out; }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); border-color: var(--gold); }
  100% { transform: scale(1); }
}
.icon { image-rendering: pixelated; vertical-align: middle; }

/* --- Buttons --- */
.actions { display: grid; gap: 8px; }
.actions button {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 8px;
  width: 100%;
  padding: 8px 10px 10px;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--button);
  border: 3px solid var(--outline);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25), inset 0 2px 0 rgba(255, 255, 255, .08);
  cursor: pointer;
  transition: transform .08s, background .12s;
}
.actions button:hover:not(:disabled) { background: var(--button-hi); transform: translateY(-1px); }
.actions button:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25); }
.actions button:disabled { opacity: .55; cursor: default; }
.actions button.done { border-color: #2f6b3a; background: #34503f; opacity: .8; }
.actions .title { font-weight: 600; font-size: 15px; }
.actions small { grid-column: 1; }
.costs, .pips { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
.cost { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; font-weight: 600; }
.cost .icon { width: 20px; height: 20px; }
.cost.short { color: #ff9a8a; }
.pips i { width: 9px; height: 9px; background: var(--well); border: 2px solid var(--outline); }
.pips i.on { background: var(--gold); }
/* The skill tree: branches with a heading, a skill indented under the one it needs. */
#skills .branch { margin: 6px 0 -2px; font-size: 13px; color: var(--gold); letter-spacing: 1px; text-transform: uppercase; }
#skills .branch:first-child { margin-top: 0; }
#skills .skill.depth-1 { margin-left: 14px; }
#skills .skill.depth-2 { margin-left: 28px; }
#skills .skill.depth-1::before, #skills .skill.depth-2::before {
  content: ''; position: absolute; left: -11px; top: -10px; width: 8px; height: 24px; border-left: 2px solid var(--outline); border-bottom: 2px solid var(--outline);
}
#skills .skill { position: relative; }
#skills .skill.locked { opacity: .45; }
#skills .skill.locked small { color: #ffb08a; }
.points {
  padding: 1px 7px;
  font-size: 12px;
  color: var(--outline);
  background: var(--gold);
  border: 2px solid var(--outline);
  animation: pulse 1.2s ease-in-out infinite;
}
.points:empty { display: none; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* --- Quality select --- */
.quality { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.quality select {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--well); border: 2px solid var(--outline); padding: 2px 4px;
}

/* --- Inputs and chat --- */
.field {
  width: 100%;
  margin-top: 8px;
  padding: 7px 9px;
  font: inherit;
  color: var(--text);
  background: var(--well);
  border: 3px solid var(--outline);
}
.field::placeholder { color: #6f7a99; }
.field:focus { outline: none; border-color: var(--gold); }
#chatlog { max-height: 120px; overflow-y: auto; font-size: 14px; line-height: 1.45; }
#chatlog b { color: var(--gold); font-weight: 600; }
#chatlog:empty::before { content: 'Още няма съобщения.'; color: var(--muted); font-size: 13px; }

/* --- Hint, clock and quests --- */
.hint { border-color: #6b4a1f; background: linear-gradient(180deg, #3d3a4a, var(--card)); }
.hint h2 { color: var(--gold); }
#hint { margin: 0; line-height: 1.45; }
#clock { font-size: 13px; color: var(--gold); white-space: nowrap; }
#quests { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.quest { padding: 6px 8px 8px; background: var(--well); border: 2px solid var(--outline); }
.quest b { font-weight: 600; }
.quest small { display: block; }
.quest .row small { display: inline; color: var(--gold); }
.quest .mini { height: 6px; margin-top: 5px; background: #12162a; }
.quest .mini i { display: block; height: 100%; background: var(--green); transition: width .6s cubic-bezier(.2, .9, .3, 1); }
.quest .count { text-align: right; font-size: 12px; }
.quest.done { opacity: .55; }
.quest.done .mini i { background: var(--gold); }

/* --- Building menu --- */
.popup {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 3;
  width: min(330px, calc(100% - 32px));
  padding: 10px 12px 12px;
  background: var(--card);
  border: 3px solid var(--outline);
  box-shadow: 0 0 0 3px var(--gold), 0 8px 0 3px rgba(0, 0, 0, .3);
  transform: translateX(-50%);
  animation: popIn .18s cubic-bezier(.2, .9, .3, 1.4);
}
.popup[hidden] { display: none; }
.popup h3 { margin: 0; font-size: 18px; color: var(--gold); }
.popup .help { margin: 4px 0 10px; }
#buildMenuClose {
  width: 30px; height: 30px; font: inherit; color: var(--text);
  background: var(--button); border: 2px solid var(--outline); cursor: pointer;
}
#buildMenuClose, .popup .tools button {
  font: inherit; color: var(--text); background: var(--button); border: 2px solid var(--outline); cursor: pointer;
}
.popup .tools { display: flex; gap: 8px; margin-top: 10px; }
.popup .tools button { flex: 1; padding: 5px 6px; }
.popup .tools button:hover:not(:disabled) { background: var(--button-hi); }
.popup .tools button:disabled { opacity: .55; cursor: default; }
#buildDemolish.confirm { background: #8a2f2f; }
.popup .queue { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.popup .queue:empty { display: none; }
.popup .queue span { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 6px; background: var(--button); border: 2px solid var(--outline); }
.popup .queue .now { border-color: var(--gold); }
.popup .queue button { font: inherit; font-size: 12px; line-height: 1; padding: 2px 4px; color: var(--text); background: #8a2f2f; border: 2px solid var(--outline); cursor: pointer; }
@keyframes popIn { from { transform: translateX(-50%) scale(.7); opacity: 0; } }
.actions small .cost .icon { width: 16px; height: 16px; }

/* --- Overlays on the game --- */
#hudToggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 44px;
  height: 44px;
  font-size: 22px;
  color: var(--text);
  background: var(--button);
  border: 3px solid var(--outline);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25);
  cursor: pointer;
}
#hudToggle:hover, #muteToggle:hover { background: var(--button-hi); }
#muteToggle {
  position: absolute;
  top: 12px;
  right: 64px;
  z-index: 3;
  width: 44px;
  height: 44px;
  font-size: 18px;
  background: var(--button);
  border: 3px solid var(--outline);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25);
  cursor: pointer;
}
#minimap {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 1;
  width: 140px;
  height: 140px;
  border: 3px solid var(--outline);
  box-shadow: 0 0 0 3px var(--text), 0 6px 0 3px rgba(0, 0, 0, .25);
  image-rendering: pixelated;
  cursor: crosshair;
}
#emotes { position: absolute; left: 12px; bottom: 164px; z-index: 1; display: flex; gap: 4px; }
#emotes button {
  width: 34px; height: 34px; padding: 0; font-size: 18px; line-height: 1;
  background: var(--button); border: 3px solid var(--outline); cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25);
}
#emotes button:hover { background: var(--button-hi); transform: translateY(-1px); }
/* --- Hearts and the red flash when hurt --- */
.hearts { display: flex; gap: 3px; margin: 6px 0 2px; }
.hearts i {
  width: 14px; height: 12px; background: var(--outline);
  clip-path: polygon(50% 100%, 0 40%, 0 15%, 15% 0, 35% 0, 50% 18%, 65% 0, 85% 0, 100% 15%, 100% 40%);
}
.hearts i.full { background: var(--red); }
#hurt {
  position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(232, 69, 55, .65) 100%);
}
#hurt.on { animation: hurtFlash .5s ease-out; }
@keyframes hurtFlash { 0% { opacity: 1; } 100% { opacity: 0; } }

.chip { font: inherit; font-size: 12px; padding: 2px 8px; color: var(--text); background: var(--button); border: 2px solid var(--outline); cursor: pointer; }
.chip:hover { background: var(--button-hi); }
.chip.on { background: #2f6b3a; }

.buffs { display: flex; gap: 6px; margin-right: auto; margin-left: 8px; }
.buff { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--gold); }
.buff .icon { width: 18px; height: 18px; }
.buff.ending { animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.slot.food { cursor: pointer; }
.slot.food:hover { outline: 2px solid var(--gold); }

/* --- Lighthouse menu and the end screen --- */
.slotrow { display: grid; gap: 4px; padding: 6px 0; border-bottom: 2px solid var(--well); }
.slotrow .bar { height: 8px; }
.slotrow .bar div { height: 100%; background: var(--gold); }
.give { display: flex; flex-wrap: wrap; gap: 4px; }
.give .icon { width: 14px; height: 14px; }
.modal { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 16px; background: rgba(28, 34, 56, .7); }
.modal[hidden] { display: none; }
#victoryStats { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin: 0; text-align: left; }
#victoryStats dt { color: var(--muted); }
#victoryStats dd { margin: 0; font-weight: 600; color: var(--gold); text-align: right; }

/* --- Settings --- */
.settings { display: grid; gap: 6px; margin: 4px 0 8px; font-size: 13px; }
.settings label { display: grid; gap: 2px; color: var(--muted); }
.settings label.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.settings input[type=range] { width: 100%; accent-color: var(--gold); }
.settings input[type=checkbox] { accent-color: var(--gold); }
#keys {
  position: absolute; right: 12px; bottom: 12px; z-index: 1; display: grid; gap: 2px; padding: 8px 10px;
  font-size: 13px; background: rgba(38, 43, 68, .88); border: 3px solid var(--outline); pointer-events: none;
}
#keys[hidden] { display: none; }
#keys b { color: var(--gold); }
body.large-text #hud, body.large-text .popup, body.large-text #tutorial, body.large-text #toast,
body.large-text .modal .card, body.large-text #keys, body.large-text #reel { zoom: 1.2; }

.recipe { display: flex; gap: 6px; }
.recipe > button:first-child { flex: 1; }
.actions .recipe .many { width: auto; display: flex; align-items: center; padding: 0 10px; font-weight: 600; color: var(--gold); }

/* --- Coins and the Merchant --- */
.purse { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; font-weight: 700; color: var(--gold); }
.purse .icon, .coins .icon, .price .icon, .sellrow .icon { width: 18px; height: 18px; }
.shop { max-height: calc(100% - 60px); overflow-y: auto; width: min(380px, calc(100% - 32px)); }
.shop .row { align-items: center; }
/* Talking to the people on the islands. */
.talk { width: min(380px, calc(100% - 32px)); }
.talk .row { align-items: center; gap: 8px; }
.talk #talkFace { width: 42px; height: 60px; image-rendering: pixelated; background: var(--well); border: 2px solid var(--outline); }
.talk #talkClose { margin-left: auto; }
.talk #talkText { margin: 8px 0 4px; line-height: 1.35; }
.talk #talkStep { margin: 0 0 8px; color: var(--gold); }
.talk #talkButtons { flex-wrap: wrap; gap: 6px; }
.talk #dealFace { width: 42px; height: 54px; image-rendering: pixelated; background: var(--well); border: 2px solid var(--outline); object-fit: contain; }
.talk #dealClose { margin-left: auto; }
.talk #dealText { margin: 8px 0; line-height: 1.35; }
.deal { display: grid; gap: 6px; }
.dealRow { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--well); border: 2px solid var(--outline); }
.dealRow .what { display: grid; flex: 1; min-width: 0; }
.dealRow .what b { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-weight: normal; }
.dealRow .what small { color: var(--muted); }
.dealRow .costs { white-space: nowrap; }
.dealRow button:disabled { opacity: .45; cursor: default; }
#deal { max-height: calc(100% - 48px); overflow-y: auto; }
.today { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.today li { display: grid; }
.today small { color: var(--muted); }
#missions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#missions li { display: grid; gap: 2px; padding: 6px 8px; background: var(--well); border: 2px solid var(--outline); }
#missions li b { color: var(--gold); font-size: 14px; }
#missions li small { color: var(--muted); }
#missions li.ready b::after { content: ' ?'; color: #fff2b0; }
#missions li.done { opacity: .6; }
#missions .relic { font-size: 12px; color: #c7f0b8; }
.shop .coins { margin-left: auto; margin-right: 10px; display: inline-flex; align-items: center; gap: 3px; color: var(--gold); font-weight: 700; }
#shopClose { width: 30px; height: 30px; font: inherit; color: var(--text); background: var(--button); border: 2px solid var(--outline); cursor: pointer; }
.shop .tabs { display: flex; gap: 6px; margin: 8px 0; }
.shop .tabs .chip { flex: 1; padding: 6px; font-size: 14px; }
.shop .tabs .chip.on { background: var(--gold); color: var(--outline); }
.shop h4 { margin: 6px 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.sellrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; padding: 6px 0; border-bottom: 2px solid var(--well); }
.sellrow .what { display: flex; align-items: center; gap: 5px; }
.sellrow .what small { color: var(--muted); }
.sellrow .price { display: inline-flex; align-items: center; gap: 3px; color: var(--gold); font-weight: 600; font-size: 13px; }
.sellrow .give { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; }
.sellrow .give .all { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; }
.owned { display: flex; flex-wrap: wrap; gap: 4px; }
.owned span { font-size: 12px; padding: 2px 8px; background: #34503f; border: 2px solid var(--outline); }

/* --- Stats and the danger zone --- */
#statsCard summary { display: flex; justify-content: space-between; align-items: baseline; cursor: pointer; list-style: none; }
#statsCard summary::-webkit-details-marker { display: none; }
#statsCard summary h2 { margin: 0; }
#statsCard summary h2::before { content: '▸ '; }
#statsCard[open] summary h2::before { content: '▾ '; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.stats li { display: flex; align-items: center; gap: 4px; }
.stats li b { margin-left: auto; color: var(--gold); }
.stats .icon { width: 18px; height: 18px; }
.danger { margin-top: 10px; padding-top: 8px; border-top: 2px dashed var(--well); }
#wipeYes { background: #8a2f2f; }

/* --- Fishing: the reel bar --- */
#reel {
  position: absolute; left: 50%; bottom: 90px; z-index: 3; width: min(320px, 80%); height: 26px;
  transform: translateX(-50%); background: var(--well); border: 3px solid var(--outline);
  box-shadow: 0 0 0 3px var(--text), 0 6px 0 3px rgba(0, 0, 0, .3); cursor: pointer;
  animation: popIn .15s ease-out;
}
#reel[hidden] { display: none; }
#reelZone { position: absolute; top: 0; bottom: 0; background: var(--green); }
#reel.hot #reelZone { background: #b8f08e; }
#reelNeedle { position: absolute; top: -6px; bottom: -6px; width: 4px; margin-left: -2px; background: var(--gold); box-shadow: 0 0 0 2px var(--outline); }
#reel small { position: absolute; top: 32px; left: 0; right: 0; text-align: center; color: var(--text); font-weight: 600; text-shadow: 0 2px 0 var(--outline); }

/* --- On-screen HUD: level bar, hearts and coins, pickup list --- */
#topbar { position: absolute; top: 12px; left: 50%; z-index: 1; transform: translateX(-50%); width: min(460px, calc(100% - 420px)); min-width: 220px; pointer-events: none; }
#lvlBar {
  position: relative; height: 26px; background: var(--well); border: 3px solid var(--outline);
  box-shadow: 0 0 0 2px rgba(255, 247, 232, .2), 0 4px 0 rgba(0, 0, 0, .3); overflow: hidden;
}
#lvlFill {
  position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(#ffe08a, var(--gold) 45%, var(--orange));
  transition: width .5s cubic-bezier(.2, .9, .3, 1);
}
#lvlFill::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(115deg, transparent 0 10px, rgba(255, 255, 255, .18) 10px 14px); }
#lvlText, #lvlXp { position: absolute; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--text); text-shadow: 0 2px 0 var(--outline), 0 0 3px var(--outline); }
#lvlText { left: 10px; font-size: 14px; letter-spacing: 1px; }
/* Normal weight and one hard shadow: in bold with a glow the pixel font's 2 reads as an 8. */
#lvlXp { right: 10px; font-size: 14px; font-weight: 400; text-shadow: 0 2px 0 var(--outline); }
#lvlBar.gain { animation: barGain .35s ease-out; }
@keyframes barGain { 30% { box-shadow: 0 0 0 2px #fff2b0, 0 0 12px 2px rgba(253, 190, 83, .8); } }
#lvlBar.levelup { animation: barLevel 1.2s ease-out; }
@keyframes barLevel { 0%, 40% { box-shadow: 0 0 0 3px #fff, 0 0 26px 8px rgba(253, 190, 83, .95); transform: scale(1.06); } }
#hudLeft { position: absolute; top: 12px; left: 12px; z-index: 1; display: grid; gap: 6px; pointer-events: none; }
/* П16: the album's button under the coins (the HUD lets clicks through; this one takes them). */
#albumButton { pointer-events: auto; justify-self: start; cursor: pointer; font: inherit; color: var(--text); border: 0; padding: 2px 8px 2px 2px; background: transparent; }
#albumButton b { font-size: 16px; }
#albumButton.shine { animation: albumShine .9s ease-out; }
@keyframes albumShine { 0% { transform: scale(1); filter: brightness(1); } 30% { transform: scale(1.25); filter: brightness(1.6); } 100% { transform: scale(1); filter: brightness(1); } }
.card.album { width: min(600px, 100%); }
.card.album .row { align-items: center; gap: 10px; }
.card.album #albumClose { margin-left: auto; }
.albumTabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0; }
.albumTabs button { display: grid; padding: 4px 8px; font: inherit; font-size: 13px; color: var(--text); background: var(--well); border: 2px solid var(--outline); cursor: pointer; }
.albumTabs button small { color: var(--muted); font-size: 11px; }
.albumTabs button.on { background: var(--button-hi); border-color: var(--gold); }
.albumTabs button.full { color: var(--gold); }
.albumGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.albumGrid figure { margin: 0; padding: 6px 4px; display: grid; justify-items: center; gap: 4px; background: var(--well); border: 2px solid var(--outline); }
.albumGrid img { width: 56px; height: 56px; image-rendering: pixelated; }
.albumGrid img.unknown { filter: brightness(0); opacity: .35; }
.albumGrid figcaption { font-size: 12px; text-align: center; line-height: 1.2; }
.albumGrid figure:not(.found) figcaption { color: var(--muted); }
.hearts.on-map { margin: 0; gap: 4px; }
.hearts.on-map i { width: 22px; height: 19px; filter: drop-shadow(0 2px 0 var(--outline)) drop-shadow(0 -1px 0 var(--outline)); }
.purse.on-map { margin: 0; font-size: 18px; text-shadow: 0 2px 0 var(--outline), 0 0 3px var(--outline); }
.purse.on-map .icon { width: 24px; height: 24px; filter: drop-shadow(0 2px 0 var(--outline)); }
.purse.bump { animation: pop .3s ease-out; }
#feed { position: absolute; right: 12px; top: 70px; z-index: 1; display: grid; gap: 4px; justify-items: end; pointer-events: none; }
.pick {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 5px; font-size: 13px;
  background: rgba(38, 43, 68, .82); border: 2px solid var(--outline); animation: pickIn .25s cubic-bezier(.2, .9, .3, 1.4);
  transition: opacity .4s, transform .4s;
}
.pick .icon { width: 20px; height: 20px; }
.pick b { color: var(--gold); }
.pick small { color: var(--muted); }
.pick.bump { animation: pop .25s ease-out; }
.pick.out { opacity: 0; transform: translateX(20px); }
@keyframes pickIn { from { opacity: 0; transform: translateX(30px) scale(.8); } }
@keyframes pop { 40% { transform: scale(1.18); } }
/* messages go under the level bar, the guide card under the hearts and coins */
#game #toast { top: 48px; }
#game #tutorial { top: 112px; } /* under the hearts, the coins and the album button */
body.touch #feed { top: 168px; }
@media (max-width: 700px) {
  #topbar { left: 12px; transform: none; width: calc(100% - 184px); min-width: 0; }
  #hudLeft { top: 50px; }
  #game #tutorial { top: 148px; }
}

/* --- First-time guide --- */
#tutorial {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  width: min(290px, calc(100% - 90px));
  padding: 8px 10px 10px;
  background: var(--card);
  border: 3px solid var(--outline);
  box-shadow: 0 0 0 3px var(--gold), 0 6px 0 3px rgba(0, 0, 0, .3);
}
#tutorial[hidden] { display: none; }
#tutorial.pop { animation: tutorialIn .3s cubic-bezier(.2, .9, .3, 1.4); }
#tutorial .row { display: flex; justify-content: space-between; align-items: center; }
#tutorial small { color: var(--gold); font-weight: 600; }
#tutorial p { margin: 4px 0 0; font-size: 15px; line-height: 1.35; }
#tutorial b { color: var(--gold); }
#tutorialSkip { font: inherit; font-size: 12px; color: var(--muted); background: none; border: 0; cursor: pointer; text-decoration: underline; }
@keyframes tutorialIn { from { transform: translateY(-10px) scale(.92); opacity: 0; } }
.tutorial-glow { animation: tutorialGlow 1.1s ease-in-out infinite; }
@keyframes tutorialGlow { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 18px 4px rgba(253, 190, 83, .55); } }
#toast {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 2;
  padding: 8px 16px;
  font-size: 17px;
  color: var(--text);
  background: var(--outline);
  border: 3px solid var(--gold);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .3);
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity .2s, transform .25s cubic-bezier(.2, .9, .3, 1.4);
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  font-size: 18px;
  background: var(--panel);
  transition: opacity .5s;
}
#loading.done { opacity: 0; pointer-events: none; }

/* --- Start screen: pick a world --- */
.worlds { display: grid; gap: 6px; max-height: 46vh; overflow-y: auto; text-align: left; }
.world {
  position: relative; display: grid; gap: 2px; padding: 8px 10px; font: inherit; color: var(--text); text-align: left; cursor: pointer;
  background: var(--button); border: 3px solid var(--outline); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25);
}
.world:hover { background: var(--button-hi); }
.world b { color: var(--gold); font-size: 16px; }
.world small { color: var(--muted); font-size: 12px; }
.world.last { border-color: var(--gold); }
.world .tag { position: absolute; top: 6px; right: 8px; font-size: 11px; font-weight: 700; color: var(--outline); background: var(--gold); padding: 1px 6px; }
/* Deleting a world: a small bin on the card, then a question under it. */
.worldRow, .worldCard { display: grid; }
.worldCard { position: relative; }
.worldCard .del {
  position: absolute; right: 6px; bottom: 6px; width: 30px; height: 30px; padding: 0; font-size: 15px; line-height: 1; cursor: pointer;
  background: var(--button); border: 2px solid var(--outline); opacity: .75;
}
.worldCard .del:hover { opacity: 1; background: #8a3b3b; }
.worldRow .ask { display: none; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 8px; font-size: 13px; background: #4a2630; border: 3px solid var(--outline); border-top: 0; }
.worldRow.asking .ask { display: flex; }
.worldRow.asking .world { border-color: #d0605e; }
.chip.danger { background: #b04848; color: #fff; }
.trash { text-align: left; font-size: 13px; color: var(--muted); }
.trash summary { cursor: pointer; }
.trashed { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid rgba(255, 255, 255, .08); }
.trashed span { display: grid; }
.trashed b { color: var(--text); }
.online { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; margin: 8px 0 12px; font-size: 13px; color: var(--muted); }
.online a { color: var(--text); word-break: break-all; }
.online[hidden] { display: none; }
.start .field.name { letter-spacing: normal; text-transform: none; text-align: left; font-size: 15px; }
#startScreen { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 16px; background: rgba(28, 34, 56, .82); }
#startScreen[hidden] { display: none; }
.start { width: min(360px, 100%); display: grid; gap: 10px; text-align: center; animation: popInPlain .25s cubic-bezier(.2, .9, .3, 1.4); }
.start h1 { margin: 0; color: var(--gold); }
.start .row { display: flex; gap: 8px; }
.start .field { flex: 1; text-transform: uppercase; letter-spacing: .3em; text-align: center; font-size: 18px; }
.big {
  font: inherit; font-size: 17px; font-weight: 600; padding: 10px 14px; color: var(--text); cursor: pointer;
  background: var(--button); border: 3px solid var(--outline); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25);
}
.big:hover { background: var(--button-hi); }
#startMain { background: #2f6b3a; }
.error { margin: 0; min-height: 1.2em; color: var(--pink, #f28462); }
@keyframes popInPlain { from { transform: scale(.85); opacity: 0; } }
.room { margin-top: 6px; align-items: center; }
.room b { color: var(--gold); font-size: 14px; }
.spinner {
  width: 28px;
  height: 28px;
  background: var(--gold);
  border: 3px solid var(--outline);
  animation: hop .7s cubic-bezier(.3, 0, .7, 1) infinite alternate;
}
@keyframes hop {
  from { transform: translateY(0) rotate(0); }
  to { transform: translateY(-18px) rotate(90deg); }
}

body.hud-hidden #hud { display: none; }
/* Phones and narrow windows: the game fills the screen and the panel slides over it. */
/* Narrow screens, and phones held sideways (short screens): the panel slides over the game. */
@media (max-width: 700px), (max-height: 500px) {
  #hud {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    width: min(300px, 88vw);
    padding-top: 64px;
    transform: translateX(100%);
    transition: transform .22s ease-out;
  }
  body.hud-open #hud { transform: none; box-shadow: -8px 0 0 rgba(0, 0, 0, .25); }
  body.hud-hidden #hud { display: block; }
  #minimap { width: 100px; height: 100px; }
  #emotes { bottom: 124px; }
  #emotes button { width: 28px; height: 28px; font-size: 15px; }
  #toast { font-size: 15px; white-space: normal; width: max-content; max-width: 80vw; text-align: center; }
}
.start .field::placeholder { letter-spacing: normal; text-transform: none; }
.room b { white-space: nowrap; }
.room span { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.actions .give button { display: inline-flex; width: auto; gap: 4px; padding: 3px 8px; font-size: 13px; box-shadow: none; }

/* --- Touch controls: joystick on the left, round buttons on the right --- */
#touch { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#touch[hidden] { display: none; }
#stickZone { position: absolute; left: 0; bottom: 0; width: 46%; height: 60%; pointer-events: auto; touch-action: none; }
#stick {
  position: absolute; left: calc(96px + env(safe-area-inset-left)); top: calc(100% - 104px - env(safe-area-inset-bottom)); width: 132px; height: 132px; margin: -66px 0 0 -66px;
  border-radius: 50%; opacity: .5; transition: opacity .15s;
  background: radial-gradient(circle, rgba(38, 43, 68, .25) 0 52%, rgba(38, 43, 68, .62) 53% 100%);
  box-shadow: 0 0 0 3px rgba(63, 38, 49, .9), inset 0 0 0 3px rgba(255, 247, 232, .14), 0 6px 0 rgba(0, 0, 0, .25);
}
#stick::before {
  content: ''; position: absolute; inset: 14px; border-radius: 50%; border: 2px dashed rgba(253, 190, 83, .35);
}
#stick.active { opacity: 1; }
#stickKnob {
  position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6070a0, #3a4466 58%, #262b44);
  box-shadow: 0 0 0 3px var(--outline), 0 0 0 6px rgba(253, 190, 83, .8), 0 6px 0 rgba(0, 0, 0, .35);
  transition: transform .12s ease-out;
}
#stick.active #stickKnob { transition: none; }
#pad { position: absolute; right: calc(20px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); width: 0; height: 0; }
.tbtn {
  position: absolute; width: 56px; height: 56px; padding: 0; display: grid; place-items: center;
  pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  font: inherit; font-size: 24px; color: var(--text); border-radius: 50%; border: 3px solid var(--outline); cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #556294, #2e3555 72%);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .3), inset 0 2px 0 rgba(255, 255, 255, .14), 0 5px 0 rgba(0, 0, 0, .35);
  transition: transform .06s, box-shadow .06s, opacity .15s;
}
.tbtn[hidden] { display: none; }
.tbtn img { width: 32px; height: 32px; image-rendering: pixelated; pointer-events: none; }
.tbtn:active, .tbtn.down { transform: translateY(3px) scale(.93); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .3), 0 2px 0 rgba(0, 0, 0, .35); }
/* The big button: what to do now, with a gold ring and a label under it. */
.tbtn.big {
  right: 0; bottom: 0; width: 88px; height: 88px;
  background: radial-gradient(circle at 35% 30%, #6a78ad, #3a4466 70%);
  box-shadow: 0 0 0 4px rgba(253, 190, 83, .85), inset 0 -5px 0 rgba(0, 0, 0, .3), inset 0 3px 0 rgba(255, 255, 255, .16), 0 6px 0 rgba(0, 0, 0, .35);
}
.tbtn.big img { width: 48px; height: 48px; }
.tbtn.big span {
  position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); white-space: nowrap; pointer-events: none;
  font-size: 13px; font-weight: 700; color: var(--gold); text-shadow: 0 2px 0 var(--outline), 0 0 4px var(--outline);
}
.tbtn.big.idle { opacity: .55; }
.tbtn.big.down { box-shadow: 0 0 0 4px #fff2b0, inset 0 -1px 0 rgba(0, 0, 0, .3), 0 2px 0 rgba(0, 0, 0, .35); }
/* The small buttons sit on an arc around the big one. */
#tBuild { right: 122px; bottom: 16px; }
#tFish { right: 108px; bottom: 70px; }
#tEmote { right: 70px; bottom: 108px; }
#tChat { right: 16px; bottom: 122px; }
#tEmotes { position: absolute; right: 0; bottom: 192px; display: flex; gap: 6px; }
#tEmotes[hidden] { display: none; }
.tbtn.small { position: static; width: 48px; height: 48px; font-size: 22px; }

/* Full screen (and landscape lock where the phone allows it), next to the sound button. */
#fullscreen {
  position: absolute; top: 12px; right: 116px; z-index: 3; width: 44px; height: 44px; font-size: 20px; color: var(--text);
  background: var(--button); border: 3px solid var(--outline); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25); cursor: pointer;
}
#fullscreen[hidden] { display: none; }
/* Short screens: menus and overlays scroll instead of running off the screen. */
.modal, #startScreen { overflow-y: auto; }
body.touch .popup { max-height: calc(100% - 80px); overflow-y: auto; }

/* Room for the controls: minimap to the top right, menus and the reel bar up top. */
body.touch #minimap { left: auto; right: 12px; top: 66px; bottom: auto; width: 92px; height: 92px; }
body.touch #emotes, body.touch #keys { display: none; }
body.touch .popup { bottom: auto; top: 66px; }
body.touch #reel { bottom: auto; top: 38%; }
/* Phones held sideways: everything a little smaller. */
@media (max-height: 480px) {
  #pad { transform: scale(.82); transform-origin: bottom right; right: 14px; bottom: 18px; }
  #stick { transform: scale(.85); }
  body.touch #minimap { width: 72px; height: 72px; top: 62px; }
}
