/* Windows 10's emoji font is old: some newer emoji (🪵 🪨 🦣 🛖 ...) show as empty boxes.
   On Windows we add a tiny font with just those emoji (fonts/emoji-extra.woff2, from Noto Color Emoji).
   Other devices already have them (utils.js adds the "win-emoji" class).
   Using a NEW emoji (Unicode 12 or newer)? Make the font again with it in:
     https://fonts.googleapis.com/css2?family=Noto+Color+Emoji&text=<all the emoji, URL-encoded>
   (open it in Chrome, download the .woff2 file it points to, save it as fonts/emoji-extra.woff2)
   and copy its unicode-range into the rule below. */
@font-face {
  font-family: "GameEmoji";
  src: url("../fonts/emoji-extra.woff2") format("woff2");
  unicode-range: U+1F6D6, U+1F7E0-1F7E2, U+1F7EB, U+1F976, U+1F9A3, U+1F9AC, U+1FA78, U+1FA83, U+1FA94, U+1FA98, U+1FAA8, U+1FAB5-1FAB6, U+1FABB, U+1FACE, U+1FAD0, U+1FADA;
  font-display: swap;
}
.win-emoji body, .win-emoji button, .win-emoji select, .win-emoji input { font-family: "Segoe UI", Arial, "GameEmoji", sans-serif; }

/* style.css - the look of the HUD and menus (not the 3D world) */

body {
  margin: 0;
  overflow: hidden;
  background: #000;
  font-family: "Segoe UI", Arial, sans-serif;
  color: #fff;
  user-select: none;
}

#game canvas { display: block; }

.panel {
  position: fixed;
  background: rgba(20, 28, 22, 0.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 10px 14px;
  z-index: 2;
}

#title-panel { top: 12px; left: 12px; line-height: 1.5; }
.era { color: #ffcf7a; font-size: 14px; }
.small { font-size: 12px; opacity: 0.7; }
.small.warn { color: #ff8a6a; opacity: 1; font-weight: bold; }

#bars { bottom: 16px; left: 16px; width: 220px; }
.bar-label { font-size: 12px; margin-top: 4px; }
.bar {
  height: 10px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 6px;
  overflow: hidden;
  margin: 3px 0 6px;
}
.fill { height: 100%; transition: width 0.15s; }
.fill.health { background: linear-gradient(90deg, #d13a3a, #ff6b5a); }
.fill.stamina { background: linear-gradient(90deg, #e0a020, #ffe066); }
.fill.hunger { background: linear-gradient(90deg, #a0582a, #e8a060); }
.bar.low { animation: pulse 0.8s infinite alternate; }
.bar.swim .fill.stamina { background: linear-gradient(90deg, #2a8ad0, #7ad0ff); }
@keyframes pulse { to { box-shadow: 0 0 10px #ff3030; } }

#message {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translate(-50%, -10px);
  font-size: 22px;
  font-weight: bold;
  text-shadow: 0 2px 8px #000;
  opacity: 0;
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
  text-align: center;
  z-index: 3;
}
#message.show { opacity: 1; transform: translate(-50%, 0); }

#hint {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  text-shadow: 0 1px 4px #000;
  pointer-events: none;
}

#damage-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, transparent 40%, rgba(200, 0, 0, 0.7));
  opacity: 0;
  z-index: 4;
}
#damage-flash.hit { animation: flash 0.7s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

#start-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10;
  cursor: pointer;
}
#start-screen.hidden { display: none; }
.card {
  background: rgba(25, 30, 24, 0.85);
  border: 1px solid rgba(255, 207, 122, 0.4);
  border-radius: 14px;
  padding: 24px 32px;
  max-width: 560px;
  width: calc(100% - 32px);
  box-sizing: border-box;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: 1px; }
.card { max-height: 94vh; overflow-y: auto; }
/* Controls in two columns so the start screen fits on small screens */
.card table { margin: 10px auto; border-collapse: collapse; font-size: 13px; }
.card table tbody { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
.card table tr { display: flex; }
.card td { padding: 2px 6px; text-align: left; }
.card td:first-child { min-width: 92px; }
@media (max-width: 520px) { .card table tbody { grid-template-columns: 1fr; } }
.card table tr.keys-head, .card table tr.keys-group { grid-column: 1 / -1; justify-content: center; }
.card tr.keys-head td { font-size: 15px; font-weight: bold; color: #fff; padding-top: 6px; text-align: center; }
.card tr.keys-group td { color: #c9b48a; font-weight: bold; font-size: 12px; text-align: center; padding-top: 6px; border-bottom: 1px solid rgba(255, 207, 122, 0.25); width: 100%; }
.card td:first-child { color: #ffcf7a; font-weight: bold; text-align: right; }
.card button {
  margin-top: 8px;
  padding: 10px 28px;
  font-size: 16px;
  border: none;
  border-radius: 8px;
  background: #e8a33a;
  color: #241405;
  font-weight: bold;
  cursor: pointer;
}
.card button:hover { background: #ffbe55; }
.card button.secondary { background: transparent; color: #ffcf7a; border: 1px solid #ffcf7a; margin-left: 8px; }
.card button.secondary:hover { background: rgba(255, 207, 122, 0.15); }
#save-info { margin: 0 0 6px; }
.volume-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0 10px; font-size: 14px; }
.volume-row input { width: 160px; accent-color: #e8a33a; }
.settings-panel .volume-row { margin: 0 0 6px; }
.slider-text { min-width: 64px; text-align: left; font-size: 12px; opacity: 0.85; }
.settings-row { display: flex; gap: 16px; justify-content: center; align-items: center; flex-wrap: wrap; font-size: 14px; margin-bottom: 10px; }
.settings-row input[type="checkbox"] { accent-color: #e8a33a; }
.settings-row select { margin-left: 4px; padding: 3px 6px; border-radius: 6px; border: 1px solid #ffcf7a; background: #2a2a20; color: #fff; font-size: 13px; }

.save-panel { margin: 6px 0 12px; padding: 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); }
.save-buttons { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.card button.small-btn { margin: 0; padding: 5px 10px; font-size: 12px; }
.slot-row { margin: 0 0 6px; }
.cloud-panel { margin: 0 0 8px; padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.06); }
.cloud-form input { flex: 1 1 140px; min-width: 0; max-width: 220px; padding: 6px 8px; border-radius: 6px; border: 1px solid #666; background: #1d1d1d; color: #eee; font-size: 14px; }
.card button.slot-btn.active { background: #e8a33a; color: #241405; cursor: default; }

#saved-icon { opacity: 0; transition: opacity 0.5s; }
#saved-icon.show { opacity: 0.8; }

#inventory { bottom: 16px; right: 16px; min-width: 200px; }
.inv-row { display: flex; gap: 14px; font-size: 16px; margin-bottom: 4px; }

#camp-compass {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 14px;
}
#camp-arrow { display: inline-block; font-size: 18px; color: #ffcf7a; transition: transform 0.1s linear; }

#minimap {
  position: fixed;
  left: 16px;
  bottom: 124px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  z-index: 2;
}

.bubble {
  position: fixed;
  transform: translate(-50%, -100%);
  background: rgba(255, 250, 238, 0.95);
  color: #2a1d14;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 13px;
  max-width: 220px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 3;
  display: none;
}
.bubble.show { opacity: 1; }
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: rgba(255, 250, 238, 0.95);
  border-bottom: 0;
}

#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 2;
}

#craft-menu {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 11;
}
#craft-menu.show { display: flex; }
.craft-card-wrap { max-width: 560px; width: calc(100% - 32px); max-height: 88vh; overflow-y: auto; text-align: left; }
.craft-card-wrap h2 { margin: 0 0 4px; text-align: center; }
.craft-card-wrap > p { text-align: center; }
#craft-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.craft-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.craft-card.locked { opacity: 0.7; }
.craft-icon { font-size: 28px; width: 36px; text-align: center; }
.craft-info { flex: 1; font-size: 14px; }
.craft-info .small { margin: 2px 0 4px; }
.costs { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.cost.ok { color: #9be38a; }
.cost.short { color: #ff8a7a; }
.craft-card button {
  margin: 0;
  padding: 8px 14px;
  font-size: 13px;
  white-space: nowrap;
}
.card .craft-card button:disabled { background: #555; color: #bbb; cursor: default; }
#craft-close { display: block; margin: 0 auto; }

#bag-menu {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.5); z-index: 11;
}
#bag-menu.show { display: flex; }
#bag-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.bag-buttons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
#bag-close { display: block; margin: 0 auto; }
.card .bag-buttons button { margin: 0; padding: 7px 10px; }

#trade-menu {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.5); z-index: 11;
}
#trade-menu.show { display: flex; }
.trade-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
#trade-close { display: block; margin: 0 auto; }
.warn { color: #ff8a6a; font-weight: bold; }

#map-menu {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55); z-index: 11;
}
#map-menu.show { display: flex; }
.map-card { max-width: none; width: auto; padding: 14px 18px; }
.map-card h2 { margin: 0 0 8px; }
#big-map { display: block; margin: 0 auto; border-radius: 10px; border: 1px solid rgba(255, 207, 122, 0.4); }
#map-info { margin: 8px 0 4px; }
.map-buttons { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
.card .map-buttons button { margin: 0; }

#tribe-menu {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.5); z-index: 11;
}
#tribe-menu.show { display: flex; }
.tribe-card { max-width: 720px; width: calc(100% - 32px); max-height: 90vh; overflow-y: auto; text-align: left; }
.tribe-card h2, .tribe-card > p { text-align: center; margin: 4px 0; }
#tribe-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.tribe-row { padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); }
.tribe-who { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.tribe-icon { font-size: 28px; }
.tribe-jobs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.card .tribe-jobs .job-btn {
  margin: 0; padding: 4px 8px; font-size: 12px; background: rgba(255, 255, 255, 0.08); color: #fff;
  display: inline-flex; align-items: center; gap: 4px;
}
.card .tribe-jobs .job-btn.active { background: #e8a33a; color: #241405; }
#tribe-close { display: block; margin: 0 auto; }
.card .feed-btn { margin: 0 0 0 auto; }
.card .feed-all { margin: 6px 0 0; }
.card button.small-btn:disabled { background: #555; color: #bbb; cursor: default; }

#quest-panel { top: 12px; right: 12px; width: 250px; font-size: 13px; }
#camp-panel { top: 160px; right: 12px; width: 250px; font-size: 12px; line-height: 1.45; }
#camp-panel[hidden] { display: none; }
.camp-line { margin: 2px 0; }
.camp-line.dim { opacity: 0.75; }
.camp-line.warn, .camp-line .warn { color: #ff9a7a; }
body.touch #camp-panel { right: calc(6px + env(safe-area-inset-right)); width: 170px; font-size: 10px; padding: 4px 8px; }
.quest-title { font-weight: bold; color: #ffcf7a; margin-bottom: 4px; }
.quest { margin: 6px 0; }
.quest.challenge { color: #ffe08a; }
.quest.boss { color: #ff9a7a; font-weight: bold; }
.quest.challenge.done { color: #9be39b; }
.quest.help-call { color: #ff9a7a; font-weight: bold; animation: pulse-text 1s infinite alternate; }
@keyframes pulse-text { to { color: #ffd27a; } }
.qbar { height: 5px; background: rgba(0, 0, 0, 0.4); border-radius: 3px; margin-top: 3px; overflow: hidden; }
.qbar div { height: 100%; background: linear-gradient(90deg, #7ac74f, #c8f07a); transition: width 0.3s; }

#quest-banner {
  position: fixed;
  top: 26%;
  left: 50%;
  transform: translate(-50%, -20px) scale(0.9);
  padding: 14px 26px;
  border-radius: 14px;
  background: rgba(30, 40, 20, 0.85);
  border: 2px solid #ffcf7a;
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
  z-index: 5;
}
#quest-banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#quest-banner-title { font-size: 22px; font-weight: bold; color: #ffe08a; }
#quest-banner-text { font-size: 16px; margin-top: 4px; }

#journal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 11;
}
#journal.show { display: flex; }
#era-end { position: fixed; inset: 0; display: none; align-items: flex-end; justify-content: center; padding-bottom: 3vh; background: linear-gradient(transparent 35%, rgba(0, 0, 0, 0.55)); z-index: 12; }
#era-end.show { display: flex; }
#era-end .journal-card { max-height: 62vh; background: rgba(20, 16, 12, 0.72); }
.story-line { opacity: 0; animation: storyIn 1.6s ease forwards; }
@keyframes storyIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#era-end-close { display: block; margin: 12px auto 0; }
.journal-card { max-width: 760px; width: calc(100% - 32px); max-height: 90vh; overflow-y: auto; text-align: left; }
.journal-card h2 { margin: 0 0 8px; text-align: center; }
.tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.card .tabs .tab { margin: 0; padding: 6px 14px; font-size: 13px; background: rgba(255, 255, 255, 0.08); color: #fff; }
.card .tabs .tab.active { background: #e8a33a; color: #241405; }
.center { text-align: center; }
.jrow { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; margin-bottom: 4px; background: rgba(255, 255, 255, 0.05); }
.jrow.done { opacity: 0.65; }
.jrow.later { opacity: 0.45; }
.jstatus { font-size: 18px; }
.jinfo { flex: 1; font-size: 14px; }
.jgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.jcard { padding: 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 207, 122, 0.25); font-size: 14px; }
.jcard.locked { opacity: 0.55; border-style: dashed; }
.jcard .small { margin-top: 4px; line-height: 1.35; }
.jicon { font-size: 34px; }
/* The animals' pictures: their real 3D models from the game (portraits.js) */
.jportrait { display: block; width: 100%; max-width: 240px; aspect-ratio: 4 / 3; margin: 0 auto 6px; border-radius: 8px;
  background: radial-gradient(ellipse at 50% 85%, rgba(120, 160, 90, 0.45), rgba(150, 190, 230, 0.18) 70%); object-fit: contain; }
.jportrait-wait { display: flex; align-items: center; justify-content: center; font-size: 40px; }
.danger { font-weight: bold; }
.dim { opacity: 0.7; }
#journal-close { display: block; margin: 12px auto 0; }

#faint-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 28px;
  background: rgba(0, 0, 0, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s;
  z-index: 9;
}
#faint-screen.show { opacity: 1; }

/* Asleep in a tent (sleep.js): the night outside goes by fast, darkly */
#sleep-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 30px;
  line-height: 1.5;
  color: #dfe6ff;
  text-shadow: 0 2px 8px #000;
  background: rgba(4, 6, 20, 0.78);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s;
  z-index: 8;
}
#sleep-screen small { font-size: 16px; opacity: 0.8; }
#sleep-screen.show { opacity: 1; }

/* ---------- Phones and tablets (touch.js adds the "touch" class) ---------- */
#rotate-hint { display: none; }
body.touch { touch-action: none; overscroll-behavior: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }

/* The area you drag on (joystick and looking). Only there while playing. */
.touch-layer { position: fixed; inset: 0; z-index: 1; display: none; touch-action: none; }
body.playing .touch-layer { display: block; }
.stick-base {
  position: fixed;
  left: calc(90px + env(safe-area-inset-left)); top: calc(100% - 100px);
  width: 120px; height: 120px; margin: -60px 0 0 -60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.25);
  opacity: 0.55;
  pointer-events: none;
}
.stick-base.active { opacity: 1; }
.stick-base.sprint { border-color: #ffcf7a; box-shadow: 0 0 16px rgba(255, 207, 122, 0.6); }
.stick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* The buttons */
.touch-buttons, .touch-menu { display: none; }
body.playing .touch-buttons, body.playing .touch-menu { display: block; }
.tbtn {
  position: fixed; z-index: 6;
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  background: rgba(20, 28, 22, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  touch-action: none;
}
.tbtn.down { background: rgba(232, 163, 58, 0.6); transform: scale(0.93); }
.tbtn.ready { border-color: #ffcf7a; box-shadow: 0 0 14px rgba(255, 207, 122, 0.8); }
.tbtn.off { opacity: 0.35; }
.tbtn.hidden { display: none; }
.tbtn.big { width: 76px; height: 76px; font-size: 34px; }
.tbtn.small { width: 46px; height: 46px; font-size: 21px; }
.tbtn.stab  { right: calc(18px + env(safe-area-inset-right)); bottom: 20px; }
.tbtn.jump  { right: calc(110px + env(safe-area-inset-right)); bottom: 14px; }
.tbtn.throw { right: calc(26px + env(safe-area-inset-right)); bottom: 110px; }
.tbtn.use   { right: calc(100px + env(safe-area-inset-right)); bottom: 88px; }
.tbtn.eat   { right: calc(184px + env(safe-area-inset-right)); bottom: 18px; }
.tbtn.wood  { right: calc(178px + env(safe-area-inset-right)); bottom: 74px; }
.tbtn.torch { right: calc(36px + env(safe-area-inset-right)); bottom: 180px; }
.tbtn.bow   { right: calc(110px + env(safe-area-inset-right)); bottom: 160px; }
.tbtn.run   { right: calc(186px + env(safe-area-inset-right)); bottom: 132px; }
.tbtn.crouch { right: calc(252px + env(safe-area-inset-right)); bottom: 110px; }
.touch-menu { position: fixed; top: 6px; right: calc(8px + env(safe-area-inset-right)); z-index: 6; }
.touch-menu .tbtn.mini { position: static; display: inline-flex; width: 38px; height: 38px; font-size: 18px; margin-left: 5px; }

/* A smaller HUD, moved out of the way of your thumbs */
body.touch .panel { padding: 5px 9px; border-radius: 8px; }
body.touch #title-panel { top: 6px; left: calc(6px + env(safe-area-inset-left)); line-height: 1.3; font-size: 12px; }
body.touch #title-panel b, body.touch #title-panel .era, body.touch #view-mode,
body.touch #sound-status, body.touch #key-help { display: none; }
body.touch #mem-btn { display: none; } /* (on a phone: in the menu) */
body.touch #minimap { left: calc(6px + env(safe-area-inset-left)); top: 62px; bottom: auto; width: 104px; height: 104px; }
body.touch #bars { top: 6px; bottom: auto; left: 50%; transform: translateX(-50%); width: 170px; padding: 3px 9px; }
body.touch .bar-label { display: none; }
body.touch .bar { height: 7px; margin: 3px 0; }
body.touch #camp-compass { top: 36px; font-size: 12px; padding: 3px 10px; }
body.touch #quest-panel { top: 50px; right: calc(6px + env(safe-area-inset-right)); width: 170px; font-size: 11px; }
body.touch .quest { margin: 3px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch #inventory { bottom: 4px; left: 50%; right: auto; transform: translateX(-50%); min-width: 0; padding: 3px 9px; }
body.touch .inv-row { gap: 8px; font-size: 13px; margin: 0; }
body.touch #hunt-stats { display: none; }
body.touch #spear-status { font-size: 10px; text-align: center; }
body.touch #hint { bottom: 52px; font-size: 13px; max-width: 46%; text-align: center; }
body.touch #message { top: 24%; font-size: 16px; width: 70%; }
body.touch #quest-banner-title { font-size: 17px; }
body.touch #quest-banner-text { font-size: 13px; }
body.touch .bubble { font-size: 11px; max-width: 160px; }
body.touch #crosshair { display: none !important; }
body.touch .card { padding: 14px 16px; max-height: 92vh; }
body.touch .card h1 { font-size: 20px; }
body.touch .card p { font-size: 13px; margin: 6px 0; }
body.touch .card button { padding: 10px 22px; }
body.touch .tabs { flex-wrap: wrap; }

/* Phone held upright: it still works (some phones can't turn), just tighter.
   The menu buttons go down the right side, the bag sits above your thumbs. */
@media (orientation: portrait) {
  body.touch #rotate-hint { display: block; color: #ffcf7a; font-size: 13px; margin: 2px 0 6px; }
  body.touch .touch-menu { top: 70px; width: 38px; }
  body.touch .touch-menu .tbtn.mini { display: flex; margin: 0 0 5px; }
  body.touch #bars { left: auto; right: calc(6px + env(safe-area-inset-right)); transform: none; width: 120px; }
  body.touch #quest-panel { top: 70px; right: calc(52px + env(safe-area-inset-right)); width: 150px; }
  body.touch #inventory { bottom: 250px; max-width: 92vw; }
  body.touch .inv-row { flex-wrap: wrap; justify-content: center; }
  body.touch #hint { bottom: 335px; max-width: 80%; }
  body.touch #message { width: 88%; }
  body.touch #update-btn { top: auto; bottom: 380px; }
}

/* A new version of the game is ready */
#update-btn {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60;
  padding: 9px 18px; border-radius: 20px; font-size: 15px; font-weight: bold;
  background: #e8a33a; color: #1a1408; border: 2px solid #ffcf7a;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5); cursor: pointer;
}
#update-btn[hidden] { display: none; }
/* Phone held sideways: between the map and the joystick */
@media (orientation: landscape) {
  body.touch #update-btn { top: 175px; left: calc(6px + env(safe-area-inset-left)); transform: none; }
}
/* Start screen on phones: the Play button right under the title, no scrolling needed */
body.touch #start-screen .card { display: flex; flex-direction: column; align-items: center; }
body.touch #start-screen .card > * { order: 1; }
body.touch #start-screen .card > h1, body.touch #start-screen .card > .era { order: -2; }
body.touch #start-screen #play-btn, body.touch #start-screen #new-btn { order: -1; margin: 4px; }
body.touch #start-screen #new-btn[hidden] { display: none; }

/* ☁️ Logging in (cloud.js): a box at the TOP of the screen - on a phone the keyboard fills the bottom */
.cloud-dialog { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.72); display: flex; justify-content: center; align-items: flex-start;
  padding: max(6px, env(safe-area-inset-top)) 12px 0; }
.cloud-box { width: min(94vw, 560px); background: #2b2620; border: 1px solid #8a6a44; border-radius: 12px; padding: 8px 10px; color: #f3eadc; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5); }
.cloud-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cloud-head b { white-space: nowrap; }
.cloud-head .small { flex: 1; }
.cloud-row { display: flex; gap: 6px; align-items: stretch; }
.cloud-row input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; font-size: 18px; border-radius: 8px; border: 1px solid #a8844e; background: #141210; color: #fff; }
.cloud-row button, .cloud-x { min-width: 44px; height: 44px; border-radius: 8px; border: 1px solid #a8844e; background: #3d342a; color: #f3eadc; font-size: 16px; padding: 0 10px; margin: 0; }
.cloud-row .cloud-go { background: #e8a33a; color: #1d1409; font-weight: bold; padding: 0 16px; }
.cloud-row .cloud-go:disabled { opacity: 0.6; }
.cloud-x { margin-left: auto; height: 34px; min-width: 34px; padding: 0; }
.cloud-msg { min-height: 1.2em; margin-top: 5px; }
.cloud-switch { color: #e8a33a; }

/* 💾 Save / 📂 Load (slots.js): a list of the slots, in the middle of the screen */
.main-save { margin: 2px 0 6px; }
.card .main-save button { padding: 9px 22px; font-size: 16px; margin: 0; }
.card .main-save button.small-btn { padding: 9px 14px; font-size: 14px; }
.slots-dialog { align-items: center; padding-bottom: 8px; }
.slots-dialog .cloud-box { max-height: calc(100vh - 20px); overflow-y: auto; }
.cave-picker { align-items: center; padding-bottom: 8px; }
.cave-picker .cloud-box { max-height: calc(100vh - 20px); overflow-y: auto; max-width: 760px; }
.slot-pick:disabled { opacity: 0.4; cursor: default; }
.era-tabs { margin: 0 0 8px; }
.era-tabs .era-tab { margin: 0; }
.era-tabs .era-tab.active { background: #e8a33a; color: #241405; border-color: #e8a33a; }
.slot-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 6px; }
.slot-pick { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; margin: 0; padding: 8px 12px; border-radius: 8px;
  border: 1px solid #8a6a44; background: #3a3128; color: #f3eadc; font-size: 14px; cursor: pointer; }
.slot-pick span { font-size: 12px; opacity: 0.85; }
.slot-pick.active { border-color: #e8a33a; background: #4a3b26; }
.slot-pick.online { border-style: dashed; background: #2c3138; }
.slot-pick.empty { opacity: 0.5; cursor: default; }
.link-btn { background: none; border: none; color: #e8a33a; text-decoration: underline; padding: 0 2px; margin: 0; font: inherit; cursor: pointer; }

/* Going through the Great Cave (crossing.js): the screen goes dark */
body.crossing::after { content: ""; position: fixed; inset: 0; z-index: 200; background: #000; animation: cave-dark 1.1s ease-in forwards; pointer-events: all; }
@keyframes cave-dark { from { opacity: 0; } to { opacity: 1; } }
/* ---------- The start screen: a living picture on top, the name glowing over it, a big Play ---------- */
#start-screen {
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.72) 100%);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
#start-screen .card {
  padding-top: 0;
  background: linear-gradient(180deg, rgba(22, 26, 22, 0.92), rgba(14, 16, 14, 0.94));
  border: 1px solid rgba(255, 207, 122, 0.45);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 18px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(255, 160, 60, 0.12);
  max-width: 600px;
}
.start-hero { position: relative; height: 230px; margin: 0 -32px 6px; border-radius: 14px 14px 0 0; overflow: hidden; flex-shrink: 0; align-self: stretch; }
.start-hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-text { position: absolute; left: 0; right: 0; top: 16px; text-align: center; pointer-events: none; }
#start-screen .start-hero h1 {
  margin: 0; font-size: 34px; font-weight: 900; letter-spacing: 3px; text-transform: uppercase; line-height: 1.05;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #fff6dc 0%, #ffd27a 45%, #e8913a 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.7)) drop-shadow(0 0 14px rgba(255, 170, 70, 0.55));
}
#start-screen .start-hero .era {
  display: inline-block; margin: 6px 0 0; padding: 3px 14px; border-radius: 20px; font-size: 13px; font-weight: bold; letter-spacing: 1px;
  color: #ffe2a8; background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(255, 207, 122, 0.45);
}
.play-row { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.play-row button { margin: 0 !important; }
#start-screen #play-btn {
  font-size: 20px; padding: 13px 46px; border-radius: 30px; letter-spacing: 1px;
  background: linear-gradient(180deg, #ffd27a, #e8913a); color: #241405; border: 1px solid #fff0c8;
  box-shadow: 0 4px 0 #8a4f14, 0 6px 18px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s, box-shadow 0.12s;
}
#start-screen #play-btn:not(:disabled) { animation: play-glow 2.2s ease-in-out infinite; }
#start-screen #play-btn:not(:disabled):hover { transform: translateY(-2px) scale(1.03); }
#start-screen #play-btn:not(:disabled):active { transform: translateY(2px); box-shadow: 0 2px 0 #8a4f14, 0 3px 10px rgba(0, 0, 0, 0.5); }
#start-screen #play-btn:disabled {
  cursor: default; color: #ffe8bc; border-color: rgba(255, 207, 122, 0.5); box-shadow: none;
  background: linear-gradient(90deg, rgba(120, 80, 30, 0.6) 0%, rgba(232, 163, 58, 0.75) 50%, rgba(120, 80, 30, 0.6) 100%); background-size: 200% 100%;
  animation: play-loading 1.6s linear infinite;
}
@keyframes play-glow { 0%, 100% { box-shadow: 0 4px 0 #8a4f14, 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 0 rgba(255, 190, 90, 0); } 50% { box-shadow: 0 4px 0 #8a4f14, 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 26px rgba(255, 190, 90, 0.75); } }
@keyframes play-loading { from { background-position: 200% 0; } to { background-position: 0 0; } }
#start-screen #intro { font-size: 14px; line-height: 1.5; color: #e4dccb; margin: 6px 4px 8px; }
/* the controls: folded up, open them when you want them */
#keys-box { margin: 6px 0; border: 1px solid rgba(255, 207, 122, 0.3); border-radius: 10px; background: rgba(255, 255, 255, 0.03); }
#keys-box > summary { cursor: pointer; padding: 8px 12px; font-weight: bold; color: #ffcf7a; list-style: none; user-select: none; }
#keys-box > summary::-webkit-details-marker { display: none; }
#keys-box > summary::after { content: " ▾"; }
#keys-box[open] > summary::after { content: " ▴"; }
#keys-box > summary:hover { background: rgba(255, 207, 122, 0.08); border-radius: 10px; }
#keys-box table { margin-top: 0; }
#keys-box tr.keys-head { display: none; }
/* the Jurassic Era: warmer colours */
body.era-jurassic #start-screen .card { border-color: rgba(255, 150, 90, 0.5); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 18px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(255, 90, 40, 0.18); }
body.era-jurassic #start-screen .start-hero h1 { background: linear-gradient(180deg, #fff3d6 0%, #ffb35a 50%, #d9502a 100%); -webkit-background-clip: text; background-clip: text; }
/* small screens (a phone on its side): a lower picture, so Play is still on the screen */
@media (max-height: 520px) {
  .start-hero { height: 150px; }
  #start-screen .start-hero h1 { font-size: 24px; letter-spacing: 2px; }
  #start-screen .start-hero .era { font-size: 11px; margin-top: 3px; }
  .hero-text { top: 8px; }
  #start-screen #play-btn { font-size: 18px; padding: 10px 38px; }
}
@media (max-width: 520px) { .start-hero { margin: 0 -16px 6px; } #start-screen .start-hero h1 { font-size: 24px; } }
body.touch #start-screen .card > .start-hero { order: -3; margin: 0 -16px 6px; }
body.touch #start-screen .card > .play-row { order: -2; }
/* 📜 Stories: a list to pick from (era.js) */
.story-picker .cloud-box { display: flex; flex-direction: column; gap: 6px; }
.story-pick { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid #8a6a44; background: #3a3128; color: #f3eadc; font-size: 15px; cursor: pointer; }
.story-pick:hover { background: #4a3e30; border-color: #e8a33a; }
