/* Tycoon Kids Games — shell styles */

@font-face {
  font-family: 'Fredoka';
  src: url('../../assets/fonts/fredoka-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Fredoka';
  src: url('../../assets/fonts/fredoka-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  --cream: #f6efe1;
  --cream-dark: #e6d6b8;
  --brown: #5a3d2b;
  --brown-dark: #3a2a22;
  --gold: #f0b428;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--brown-dark);
  color: var(--brown-dark);
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 500;
  /* Stop phones from zooming, selecting text or bouncing the page while playing */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* The world canvas fills the screen. Pixels stay sharp (no blurring). */
#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------- Top bar ---------- */
#hud {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  display: flex;
  gap: 6px;
  align-items: center;
  pointer-events: none;   /* taps go through to the world... */
  z-index: 10;
}
#hud > * { pointer-events: auto; }   /* ...except on the bar's own pills */

.hud-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 12px 0 4px;
  background: var(--cream);
  border: 3px solid var(--brown);
  border-radius: 18px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
  font-weight: 600;
  font-size: 18px;
  line-height: 1;
  white-space: nowrap;
}
.hud-pill img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}
.hud-pill.tokens { padding-right: 14px; font-size: 20px; }
.hud-spacer { flex: 1; }

/* Little "pop" when a number changes */
.hud-pill.bump { animation: bump 0.35s ease-out; }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* Very short screens (phones held sideways): make the bar a bit smaller */
@media (max-height: 420px) {
  .hud-pill { height: 30px; font-size: 15px; padding-right: 9px; border-width: 2px; }
  .hud-pill.tokens { font-size: 17px; }
  .hud-pill img { width: 24px; height: 24px; }
}

/* ---------- Fade between areas ---------- */
#fade {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 50;
}
#fade.on { opacity: 1; }

/* ---------- Loading screen ---------- */
#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: radial-gradient(circle at 50% 35%, #4f8a3c 0, #2d5a2a 55%, #1f3d1d 100%);
  color: var(--cream);
  z-index: 90;
  text-align: center;
  padding: 16px;
}
#loading h1 { margin: 0; font-size: 34px; font-weight: 600; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.loading-token { width: 72px; height: 72px; image-rendering: pixelated; animation: spin 1.6s ease-in-out infinite; }
@keyframes spin { 0% { transform: rotateY(0) translateY(0); } 50% { transform: rotateY(180deg) translateY(-10px); } 100% { transform: rotateY(360deg) translateY(0); } }
.loading-bar { width: min(320px, 70vw); height: 18px; border-radius: 9px; background: rgba(0,0,0,.35); border: 3px solid var(--cream); overflow: hidden; }
.loading-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s; }
#loading p { margin: 0; font-size: 18px; opacity: .9; }
@media (max-height: 420px) { #loading h1 { font-size: 26px; } .loading-token { width: 52px; height: 52px; } }
#loading.hidden { display: none; }

/* ---------- "Turn your device" message ---------- */
#rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--brown-dark);
  color: var(--cream);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  padding: 24px;
}
.rotate-phone {
  width: 60px;
  height: 100px;
  border: 6px solid var(--cream);
  border-radius: 12px;
  animation: turn 2s ease-in-out infinite;
}
@keyframes turn {
  0%, 30% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}
/* Only on touch devices (phones/tablets) held upright */
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: flex; }
}

/* ---------- Developer panel (only shown when the address ends in ?dev) ----------
   Folded into a small "DEV" tab at the bottom middle, where no game buttons are. */
#dev-tab {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(4px, env(safe-area-inset-bottom));
  z-index: 95;
  font: 600 11px system-ui, sans-serif;
  letter-spacing: .05em;
  padding: 3px 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 20, 30, 0.55);
  color: #fff;
  cursor: pointer;
  opacity: 0.7;
}
#dev {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(max(4px, env(safe-area-inset-bottom)) + 26px);
  z-index: 95;
  background: rgba(20, 20, 30, 0.92);
  color: #fff;
  font: 13px/1.3 system-ui, sans-serif;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: min(360px, calc(100vw - 140px));
  max-height: calc(100vh - 80px);
  overflow: auto;
  align-items: center;
}
#dev[hidden] { display: none; }
#dev b { width: 100%; }
#dev button, #dev select {
  font: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
}
#dev button.danger { background: #e05555; color: #fff; }

/* ---------- Player button (top right) ---------- */
#me { cursor: pointer; font: inherit; font-weight: 600; color: var(--brown-dark); padding: 0 12px 0 3px; }
#me canvas { border-radius: 50%; background: #9fd17a; }
#me:empty { display: none; }

/* ---------- Zoom buttons (bottom left) ---------- */
#zoom {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; z-index: 10;
}
#zoom button {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--cream); border: 3px solid var(--brown); color: var(--brown-dark);
  font: 600 28px/1 'Fredoka', system-ui, sans-serif; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.3); padding: 0;
}
#zoom button:active { transform: translateY(2px); box-shadow: none; }
@media (max-height: 420px) { #zoom button { width: 40px; height: 40px; font-size: 24px; } }

/* ---------- Buttons ---------- */
.tkg-btn {
  font: 600 18px 'Fredoka', system-ui, sans-serif;
  background: var(--cream-dark); color: var(--brown-dark);
  border: 3px solid var(--brown); border-radius: 14px;
  padding: 8px 18px; cursor: pointer; box-shadow: 0 3px 0 var(--brown);
  min-height: 44px;
}
.tkg-btn.primary { background: #6cbf4a; color: #fff; border-color: #3d7a2a; box-shadow: 0 3px 0 #3d7a2a; }
.tkg-btn:active { transform: translateY(2px); box-shadow: none; }
.tkg-btn:focus-visible, .choice:focus-visible, .who-card:focus-visible { outline: 3px solid #1f6f9a; outline-offset: 2px; }

/* ---------- Pop-up dialog ---------- */
.tkg-modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(30, 20, 15, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.tkg-card {
  background: var(--cream); border: 4px solid var(--brown); border-radius: 20px;
  box-shadow: 0 6px 0 var(--brown-dark), 0 16px 40px rgba(0,0,0,.35);
  padding: 18px 22px; max-width: 440px; width: 100%; max-height: 100%; overflow: auto;
  text-align: center;
}
.tkg-card h2 { margin: 0 0 6px; font-size: 24px; font-weight: 600; }
.tkg-card p { margin: 4px 0; font-size: 17px; line-height: 1.35; }
.tkg-card-icon { width: 56px; height: 56px; image-rendering: pixelated; object-fit: contain; }
.tkg-card-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
@media (max-height: 420px) { .tkg-card { padding: 12px 16px; } .tkg-card h2 { font-size: 20px; } .tkg-card p { font-size: 15px; } }

/* ---------- Toast ---------- */
.tkg-toast {
  position: fixed; left: 50%; top: 64px; z-index: 70;
  transform: translate(-50%, -20px); opacity: 0; transition: all .35s;
  background: var(--brown-dark); color: var(--cream);
  padding: 10px 20px; border-radius: 999px; font-weight: 600; font-size: 18px;
  pointer-events: none; white-space: nowrap;
}
.tkg-toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Setup screens ---------- */
#setup {
  position: fixed; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, #4f8a3c 0, #2d5a2a 60%, #1f3d1d 100%);
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  user-select: none;
}
.setup-inner {
  background: var(--cream); border: 4px solid var(--brown); border-radius: 22px;
  box-shadow: 0 6px 0 var(--brown-dark), 0 18px 50px rgba(0,0,0,.4);
  padding: 18px 22px; width: 100%; max-width: 620px; max-height: 100%; overflow: auto;
  text-align: center; display: flex; flex-direction: column; gap: 10px;
}
.setup-inner.wide { max-width: 1000px; height: 100%; padding: 12px; }
.setup-inner h1 { margin: 0; font-size: 28px; font-weight: 600; }
.setup-q { margin: 0; font-size: 20px; }
#setup-name {
  font: 600 24px 'Fredoka', system-ui, sans-serif; text-align: center;
  padding: 10px 14px; border: 3px solid var(--brown); border-radius: 14px;
  background: #fffaf0; color: var(--brown-dark); width: 100%; max-width: 360px; align-self: center;
  user-select: text; -webkit-user-select: text;
}
#setup-name.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.setup-nav { display: flex; justify-content: space-between; gap: 10px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.choice {
  font: 600 18px 'Fredoka', system-ui, sans-serif; color: var(--brown-dark);
  background: #fffaf0; border: 3px solid var(--cream-dark); border-radius: 14px;
  padding: 12px 8px; cursor: pointer; min-height: 52px;
}
.choice:hover { border-color: #6cbf4a; }
.choice:active { background: #d7ecd9; }
.who-list { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.who-card {
  width: 130px; padding: 12px 8px; border-radius: 16px; cursor: pointer;
  background: #fffaf0; border: 3px solid var(--cream-dark);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font: inherit; color: var(--brown-dark);
}
.who-full { margin: 14px 0 0; text-align: center; font-size: 15px; opacity: .75; }
.who-card canvas { border-radius: 50%; background: #9fd17a; }
.who-name { font-weight: 600; font-size: 18px; }
.who-grade { font-size: 14px; opacity: .75; }
.who-plus { width: 64px; height: 64px; border-radius: 50%; background: #6cbf4a; color: #fff; font-size: 44px; line-height: 64px; }
@media (max-height: 420px) {
  .setup-inner { padding: 10px 14px; gap: 6px; }
  .setup-inner h1 { font-size: 22px; } .setup-q { font-size: 17px; }
  .choice { min-height: 44px; padding: 8px; font-size: 16px; }
}

/* ---------- Character maker ---------- */
.maker { display: flex; gap: 12px; min-height: 0; flex: 1; text-align: left; }
.maker-stage { flex: 0 0 38%; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#maker-big { flex: 1; width: 100%; min-height: 0; border: 3px solid var(--brown); border-radius: 12px; image-rendering: pixelated; }
.maker-actions { display: flex; justify-content: center; }
.maker-side { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
.maker-tabs { display: flex; gap: 4px; overflow-x: auto; flex: 0 0 auto; padding-bottom: 2px; }
.maker-tab {
  font: 600 15px 'Fredoka', system-ui, sans-serif; white-space: nowrap; cursor: pointer;
  background: var(--cream-dark); border: 2px solid var(--brown); border-radius: 10px; padding: 6px 10px; color: var(--brown-dark);
}
.maker-tab[aria-selected="true"] { background: #6cbf4a; color: #fff; border-color: #3d7a2a; }
.maker-panel { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.maker-group h3 { margin: 0 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; opacity: .8; display: flex; justify-content: space-between; gap: 8px; }
.maker-group h3 span { text-transform: none; letter-spacing: 0; opacity: 1; }
.maker-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.maker-opt {
  background: #fffaf0; border: 2px solid var(--cream-dark); border-radius: 10px; padding: 3px;
  display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer;
  font: 600 11px 'Fredoka', system-ui, sans-serif; color: var(--brown-dark); min-width: 0;
}
.maker-opt canvas { width: 100%; max-width: 60px; aspect-ratio: 1; image-rendering: pixelated; }
.maker-opt span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.maker-opt[aria-pressed="true"] { border-color: #6cbf4a; background: #d7ecd9; box-shadow: inset 0 0 0 2px #6cbf4a; }
.maker-sws { display: flex; flex-wrap: wrap; gap: 6px; }
.maker-sw { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--cream); box-shadow: 0 0 0 2px var(--brown); cursor: pointer; padding: 0; }
.maker-sw[aria-pressed="true"] { box-shadow: 0 0 0 3px #3d7a2a, 0 0 0 5px var(--cream); }
.maker-sw.orig { background: conic-gradient(#c9a77a 0 25%, #7d5a3c 0 50%, #c9a77a 0 75%, #7d5a3c 0); }
.maker-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.maker-chip {
  font: 600 16px 'Fredoka', system-ui, sans-serif; cursor: pointer; color: var(--brown-dark);
  border: 2px solid var(--brown); background: var(--cream-dark); border-radius: 999px; padding: 6px 16px;
}
.maker-chip[aria-pressed="true"] { background: #6cbf4a; color: #fff; border-color: #3d7a2a; }
@media (max-height: 420px) { .maker-tab { font-size: 13px; padding: 4px 8px; } .tkg-btn { min-height: 38px; padding: 4px 14px; font-size: 16px; } }

/* ---------- Boat travel (shell/js/travel.js) ---------- */
#sail-btn {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 6px;
  height: 52px; padding: 0 16px 0 8px;
  background: #2f8fc6; color: #fff;
  border: 3px solid #1d5f86; border-radius: 26px;
  box-shadow: 0 3px 0 #1d5f86;
  font: 600 20px 'Fredoka', system-ui, sans-serif; cursor: pointer;
}
#sail-btn img { width: 46px; height: 24px; object-fit: contain; image-rendering: pixelated; }
#sail-btn:active { transform: translateY(2px); box-shadow: none; }
@media (max-height: 420px) { #sail-btn { height: 44px; font-size: 17px; } #sail-btn img { width: 38px; } }

.sail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sail-place {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 8px; min-height: 64px; cursor: pointer;
  background: #fffaf0; border: 3px solid #2f8fc6; border-radius: 14px;
  font: 500 14px 'Fredoka', system-ui, sans-serif; color: var(--brown-dark);
}
.sail-place b { font-weight: 600; font-size: 18px; }
.sail-place:active { background: #d6ecf7; }
.sail-place.here { border-color: var(--cream-dark); opacity: .6; cursor: default; }
.tkg-card-icon[src$="boat.png"] { width: 84px; height: 42px; }

.sail-scene { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 55; cursor: pointer; }
.sail-label {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 56;
  background: rgba(20, 50, 80, 0.7); color: #fff; padding: 10px 22px; border-radius: 999px;
  font: 600 22px 'Fredoka', system-ui, sans-serif; pointer-events: none; white-space: nowrap;
}

/* Game huts on the islands */
.hut-info { text-align: left; margin-top: 8px; font-size: 16px; }
.hut-info div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--cream-dark); }
.hut-info div span:first-child { opacity: .7; }
.hut-soon { display: inline-block; margin-top: 10px; padding: 4px 12px; border-radius: 999px; background: #f0b428; color: var(--brown-dark); font-weight: 600; }

/* ---------- Game launcher and results (shell/js/launcher.js) ---------- */
#game-layer { position: fixed; inset: 0; z-index: 58; background: #1d1a2a; }
#game-layer iframe { width: 100%; height: 100%; border: 0; display: block; }
#game-quit {
  position: fixed; z-index: 59;
  top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right));
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--brown);
  background: var(--cream); color: var(--brown-dark); font: 600 20px/1 'Fredoka', system-ui, sans-serif;
  cursor: pointer; opacity: .85; padding: 0;
}
.results p { margin: 4px 0; font-size: 18px; }
.prizes { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0 4px; }
.prize {
  display: flex; flex-direction: column; align-items: center; min-width: 76px; padding: 8px 10px;
  background: #fffaf0; border: 3px solid var(--gold); border-radius: 14px;
  animation: pop .45s ease-out both;
}
.prize:nth-child(2) { animation-delay: .12s; }
.prize img { width: 40px; height: 40px; image-rendering: pixelated; }
.prize b { font-size: 22px; font-weight: 600; }
.prize span { font-size: 13px; opacity: .75; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
.results .note { font-size: 15px; opacity: .8; }
.results .levelup { font-weight: 600; color: #2f7a22; background: #e3f4d8; border-radius: 12px; padding: 6px 10px; margin-top: 8px; }

/* ---------- Settings (shell/js/ui.js) ---------- */
#settings-btn { cursor: pointer; padding: 0 8px; color: var(--brown-dark); justify-content: center; }
.settings { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; text-align: left; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 19px; font-weight: 600;
  padding: 8px 4px; border-bottom: 1px solid var(--cream-dark); cursor: pointer; }
.switch { width: 60px; height: 34px; border-radius: 17px; border: 3px solid var(--brown); background: var(--cream-dark);
  position: relative; cursor: pointer; padding: 0; flex: 0 0 auto; }
.switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.4); transition: left .15s; }
.switch[aria-checked="true"] { background: #6cbf4a; border-color: #3d7a2a; }
.switch[aria-checked="true"] i { left: 29px; }
.settings-tip { font-size: 14px !important; opacity: .7; margin-top: 6px !important; }

/* ---------- Home building (shell/home/home.js) ---------- */
#build-btn {
  position: fixed;
  right: calc(max(10px, env(safe-area-inset-right)) + 128px);
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 16px 0 12px;
  background: #e8952c; color: #fff; border: 3px solid #a85f12; border-radius: 26px; box-shadow: 0 3px 0 #a85f12;
  font: 600 20px 'Fredoka', system-ui, sans-serif; cursor: pointer;
}
#build-btn:active { transform: translateY(2px); box-shadow: none; }
@media (max-height: 420px) { #build-btn { height: 44px; font-size: 17px; right: calc(max(10px, env(safe-area-inset-right)) + 112px); } }
/* ✋ Move: next to Build */
#move-btn {
  position: fixed;
  right: calc(max(10px, env(safe-area-inset-right)) + 254px);
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 16px 0 12px;
  background: #7a5ac8; color: #fff; border: 3px solid #4f3591; border-radius: 26px; box-shadow: 0 3px 0 #4f3591;
  font: 600 20px 'Fredoka', system-ui, sans-serif; cursor: pointer;
}
#move-btn:active { transform: translateY(2px); box-shadow: none; }
@media (max-height: 420px) { #move-btn { height: 44px; font-size: 17px; right: calc(max(10px, env(safe-area-inset-right)) + 222px); } }
.shop-item .small-btn { min-height: 32px; font-size: 14px; padding: 2px 10px; margin-top: 4px; background: #f3e6c8; }
.shop-hint { grid-column: 1 / -1; margin: 0; padding: 8px 12px; background: #e6f7df; border: 2px solid #3fae49; border-radius: 12px; font-weight: 600; color: #2f6b1f; }

#shop { position: fixed; inset: 0; z-index: 60; background: rgba(30, 20, 15, 0.5); display: flex; align-items: center; justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.shop-card { background: var(--cream); border: 4px solid var(--brown); border-radius: 20px; box-shadow: 0 6px 0 var(--brown-dark);
  width: 100%; max-width: 980px; height: 100%; max-height: 640px; display: flex; flex-direction: column; overflow: hidden; }
.shop-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px 6px; }
.shop-top h2 { margin: 0; font-size: 24px; flex: 1; }
.shop-top .tkg-btn { min-height: 38px; padding: 4px 14px; font-size: 16px; }
.shop-x { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--brown); background: var(--cream-dark); font: 600 20px 'Fredoka', sans-serif; cursor: pointer; color: var(--brown-dark); }
.shop-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 14px 8px; flex: 0 0 auto; scrollbar-width: thin; }
.shop-tab { flex: 0 0 auto; font: 600 16px 'Fredoka', sans-serif; padding: 6px 14px; border-radius: 999px; border: 2px solid var(--brown);
  background: var(--cream-dark); color: var(--brown-dark); cursor: pointer; white-space: nowrap; }
.shop-tab.special { border-color: #2f8fc6; }
.shop-tab.on { background: #6cbf4a; border-color: #3d7a2a; color: #fff; }
.shop-grid { flex: 1; overflow-y: auto; padding: 4px 14px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-content: start; }
.shop-item { background: #fffaf0; border: 3px solid var(--cream-dark); border-radius: 14px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.shop-item.selected { border-color: #6cbf4a; }
.shop-pic { height: 96px; width: 100%; display: flex; align-items: center; justify-content: center; }
.shop-pic img { max-width: 100%; max-height: 96px; image-rendering: pixelated; object-fit: contain; min-width: 40px; min-height: 40px; }
.shop-pic img.tile { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; border: 2px solid var(--brown); }
.shop-name { font-weight: 600; font-size: 16px; line-height: 1.15; }
.shop-note { font-size: 13px; opacity: .75; line-height: 1.2; }
.shop-item .tkg-btn { min-height: 36px; padding: 2px 16px; font-size: 16px; margin-top: auto; }
.shop-item .tkg-btn:disabled { opacity: .55; cursor: default; }
.shop-empty { grid-column: 1 / -1; text-align: center; font-size: 17px; opacity: .8; padding: 30px 10px; }
.price { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; font-size: 16px; font-weight: 600; }
.price span { display: flex; align-items: center; gap: 2px; }
.price img { width: 22px; height: 22px; image-rendering: pixelated; }
.price .short { color: #c0392b; }
@media (max-height: 420px) { .shop-pic { height: 70px; } .shop-pic img { max-height: 70px; } .shop-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); } .shop-top h2 { font-size: 20px; } }

#place-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(8px, env(safe-area-inset-bottom)); z-index: 30;
  background: rgba(58, 42, 34, 0.92); color: var(--cream); border-radius: 18px; padding: 6px 10px 8px; text-align: center; max-width: calc(100vw - 20px); }
#place-bar p { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
#place-bar div { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
#place-bar .tkg-btn { min-height: 40px; padding: 4px 12px; font-size: 16px; }
body:has(#place-bar) #sail-btn, body:has(#place-bar) #build-btn, body:has(#place-bar) #move-btn, body:has(#place-bar) #zoom { display: none !important; }

/* ---------- Homestead life (Step 3.9) ---------- */
.house-banner {
  display: flex; align-items: center; gap: 12px; margin: 0 14px 8px; padding: 8px 12px;
  background: linear-gradient(90deg, #fff1c4, #ffe08a); border: 3px solid #e0a020; border-radius: 16px;
  box-shadow: 0 3px 0 #b97f10; flex: 0 0 auto;
}
.house-banner.maxed { background: #eef7e6; border-color: #6cbf4a; box-shadow: 0 3px 0 #3d7a2a; }
.hb-pic { height: 72px; max-width: 110px; object-fit: contain; image-rendering: pixelated; flex: 0 0 auto; }
.hb-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hb-text b { font-size: 19px; line-height: 1.15; }
.hb-text span { font-size: 14px; opacity: .8; line-height: 1.2; }
.hb-buy { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 0 0 auto; }
.hb-buy .tkg-btn { min-height: 40px; padding: 4px 18px; font-size: 18px; }
.hb-buy .tkg-btn:disabled { opacity: .6; }
@media (max-height: 420px) { .house-banner { padding: 4px 10px; margin-bottom: 4px; } .hb-pic { height: 48px; } .hb-text b { font-size: 16px; } .hb-text span { font-size: 12px; } }
.shop-note { white-space: pre-line; }
.shop-note.does { color: #2f6b1f; opacity: 1; font-weight: 500; }
#place-bar .more-price .price { justify-content: center; margin-bottom: 6px; color: var(--cream); }
#place-bar .more-price .price .short { color: #ff8a7a; }
#boat-name { font: 600 22px 'Fredoka', sans-serif; padding: 8px 12px; border: 3px solid var(--brown); border-radius: 12px; width: 100%; max-width: 300px;
  text-align: center; background: #fffaf0; user-select: text; -webkit-user-select: text; margin-top: 8px; }

/* ---------- the market (sell your basket) ---------- */
.market { min-width: 240px; text-align: left; }
.market-left { font-weight: 600; color: #2f6b1f; margin: 0 0 8px; }
.market-empty, .market-tip { font-size: 14px; opacity: .8; margin: 8px 0 0; }
.market-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; background: #f6ecd8; margin: 4px 0; }
.market-row .mk-e { font-size: 24px; line-height: 1; }
.market-row .mk-n { flex: 1; font-weight: 600; }
.market-row .mk-p { font-size: 13px; opacity: .8; }
.tkg-btn:disabled { opacity: .45; cursor: default; }

/* ---------- the clock and day counter ---------- */
#hud2 {
  position: fixed; z-index: 20;
  top: calc(max(8px, env(safe-area-inset-top)) + 44px);
  right: max(8px, env(safe-area-inset-right));
  display: flex; gap: 6px;
}
#clock, #basket-btn {
  display: flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px;
  border: 3px solid #5a3d2b; border-radius: 15px;
  background: #fff7e6; color: #3a2a22;
  font: 600 14px Fredoka, system-ui, sans-serif;
  box-shadow: 0 2px 0 rgba(0,0,0,.25); cursor: pointer;
}
#clock .ck-sun { font-size: 15px; line-height: 1; }
#clock .ck-day { padding-left: 6px; border-left: 2px solid #e3cfae; color: #2f6b1f; }
.market-up { margin: 10px 0 0; padding: 8px 10px; border-radius: 10px; background: #fff1c8; border: 2px solid #f0b428; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 14px; }
.market-up > div:first-child { flex: 1 1 100%; display: flex; flex-direction: column; }
.market-up span { opacity: .8; }

/* ---------- wardrobe prices ---------- */
.maker-opt, .maker-chip { position: relative; }
.maker-price { position: absolute; top: 2px; right: 2px; display: flex; align-items: center; gap: 2px; padding: 1px 5px 1px 3px;
  border-radius: 9px; background: #fff3c4; border: 1.5px solid #e0a82a; font: 700 11px Fredoka, system-ui, sans-serif; color: #5a3d0a; line-height: 1.2; }
.maker-price img { width: 12px; height: 12px; image-rendering: pixelated; }
.maker-price.quest { background: #efe4ff; border-color: #8a5ac2; color: #4a2a7a; }
.maker-chip .maker-price { position: static; display: inline-flex; margin-left: 6px; vertical-align: middle; }
.maker-sw.paid { display: flex; align-items: center; justify-content: center; font-size: 11px; }
.maker-note { font-size: 13px; margin: 0 0 8px; padding: 6px 8px; border-radius: 8px; background: #fff1c8; color: #5a3d0a; }
.buy-list { min-width: 240px; }
.buy-list .market-row .price { margin-left: auto; }
.buy-total { display: flex; align-items: center; gap: 8px; justify-content: flex-end; font-weight: 700; margin-top: 8px; }
#basket-btn { position: relative; font-size: 16px; padding: 0 9px; }
#basket-btn .bk-n { font-size: 13px; }
.basket-total { display: flex; justify-content: space-between; font-weight: 700; margin: 8px 2px 0; }

/* ---------- levels, stars and game history (3 Nov) ---------- */
.stars { display: inline-flex; gap: 1px; font-size: 22px; line-height: 1; letter-spacing: 0; }
.stars i { font-style: normal; }
.stars .full { color: #f0b428; text-shadow: 0 1px 0 #a8740c; }
.stars .empty { color: #d8cdb6; }
.stars .half { background: linear-gradient(90deg, #f0b428 50%, #d8cdb6 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stars.none { color: #d8cdb6; font-size: 22px; }
.game-stars { margin: 4px 0 2px; }
.game-stars .stars { font-size: 34px; }
.level-box { text-align: left; background: #fff8e6; border: 3px solid #e8c77a; border-radius: 14px; padding: 8px 12px; margin: 8px 0 4px; }
.level-box .lb-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.level-box .lb-level { font-size: 20px; }
.level-box .lb-nums { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; font-weight: 600; opacity: .85; margin-top: 2px; flex-wrap: wrap; }
.level-box .lb-goal { margin: 6px 0 0; font-size: 14px; color: #6b4a1c; }
.hist { margin: 6px 0 2px; }
.hist-title { margin: 0 0 2px; font-size: 14px; font-weight: 600; opacity: .75; text-align: left; }
.hist-empty { margin: 4px 0; font-size: 14px; opacity: .7; }
.hist svg { width: 100%; max-width: 340px; height: auto; display: block; }
.hist .hb.g { fill: #3fae49; } .hist .hb.m { fill: #f0b428; } .hist .hb.l { fill: #e0705a; } .hist .hb.p { fill: #a9a2c8; }
.hist .hist-line { stroke: #3fae49; stroke-width: 1; stroke-dasharray: 3 3; }
.hist .hist-lv, .hist .hist-90 { font: 600 9px 'Fredoka', system-ui, sans-serif; fill: #7a6a52; }
.hist .hist-90 { text-anchor: end; fill: #2f7a22; }
.hut-note { font-size: 14px; margin: 6px 0 0; opacity: .85; }
.levelup-offer { text-align: center; }
.levelup-offer .lu-burst { font-size: 54px; line-height: 1; animation: lu-pop .7s ease; }
.levelup-offer .lu-stars .stars { font-size: 34px; }
.levelup-offer .lu-avg { font-size: 18px; font-weight: 600; margin: 6px 0; }
.levelup-offer .lu-list { text-align: left; margin: 8px auto; padding: 0; list-style: none; max-width: 420px; font-size: 16px; }
.levelup-offer .lu-list li { padding: 5px 8px; margin: 4px 0; background: #fff3d1; border-radius: 10px; }
.levelup-offer .lu-stay { font-size: 14px; opacity: .8; margin: 6px 0 0; }
@keyframes lu-pop { 0% { transform: scale(.2) rotate(-30deg); opacity: 0; } 70% { transform: scale(1.25) rotate(8deg); opacity: 1; } 100% { transform: scale(1); } }
.sail-place .stars { font-size: 16px; }
