/* NIBBLES styles. Portrait-first, safe-area aware, one-thumb reachable. */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #241a12;
  font-family: 'Trebuchet MS', 'Comic Sans MS', system-ui, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; }
button { font-family: inherit; }

#stage { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; display: block; }

.hidden { display: none !important; }

/* screens */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px calc(env(safe-area-inset-bottom, 0px) + 14px); }
.screen.overlay { background: rgba(20, 12, 6, 0.55); backdrop-filter: blur(2px); }
.screen-title { font-size: 28px; font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.35); }

.logo { font-size: 52px; font-weight: 900; color: #ffd94b; letter-spacing: 4px;
  text-shadow: 0 4px 0 #b5895a, 0 8px 18px rgba(0,0,0,.5); animation: bob 2.2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-8px) } }

.rope-bar { width: 220px; height: 14px; border-radius: 8px; background: rgba(0,0,0,.35);
  overflow: hidden; border: 2px solid rgba(255,255,255,.25); }
#rope-fill { height: 100%; width: 0%; border-radius: 6px;
  background: repeating-linear-gradient(45deg, #d9a05b 0 8px, #b5793a 8px 16px); transition: width .15s; }

.big-btn { min-width: 220px; min-height: 56px; padding: 12px 28px; font-size: 22px; font-weight: 900;
  color: #5a3a12; background: linear-gradient(#ffd94b, #f0a832); border: none; border-radius: 30px;
  box-shadow: 0 5px 0 #b5793a, 0 8px 16px rgba(0,0,0,.35); letter-spacing: 1px; }
.big-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #b5793a; }
.small-btn { min-height: 44px; padding: 8px 20px; font-size: 15px; font-weight: 700; border-radius: 22px;
  border: none; background: #fff; color: #444; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.small-btn.danger { background: #e05252; color: #fff; }

.icon-btn { width: 52px; height: 52px; border-radius: 50%; border: none; font-size: 22px;
  background: rgba(255,255,255,.92); color: #6a4a20; box-shadow: 0 3px 0 rgba(0,0,0,.3); position: relative; }
.icon-btn:active { transform: scale(.92); }
#btn-hint #hint-count { position: absolute; bottom: -4px; right: -4px; background: #e05252; color: #fff;
  font-size: 13px; font-weight: 900; border-radius: 50%; width: 22px; height: 22px; line-height: 22px; }

.corner-tl { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); left: 14px; }
.corner-tr { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); right: 14px; }
.corner-bl { position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); left: 14px; }
.star-total { font-size: 24px; font-weight: 900; color: #ffd94b; text-shadow: 0 2px 0 rgba(0,0,0,.4); }

/* HUD */
#hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start;
  justify-content: space-between; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 0; pointer-events: none; }
#hud button { pointer-events: auto; }
.hud-left { display: flex; gap: 10px; }
.hud-stars { flex: 1; text-align: center; padding-top: 6px; }
.hstar { font-size: 34px; color: rgba(255,255,255,.35); text-shadow: 0 2px 0 rgba(0,0,0,.3);
  transition: color .2s, transform .2s; display: inline-block; }
.hstar.lit { color: #ffd94b; transform: scale(1.2); }
#level-tag { position: absolute; top: 38vh; left: 0; right: 0; text-align: center; font-size: 40px;
  font-weight: 900; color: rgba(255,255,255,.85); text-shadow: 0 3px 0 rgba(0,0,0,.35);
  opacity: 0; transition: opacity .4s; pointer-events: none; }

/* panels */
.panel { background: linear-gradient(#fff8ea, #ffeecd); border-radius: 26px; padding: 22px 26px;
  display: flex; flex-direction: column; gap: 12px; align-items: center; width: min(92vw, 360px);
  max-height: 92vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.5);
  animation: slideup .3s ease-out; }
.panel.tall { height: min(92vh, 640px); }
@keyframes slideup { from { transform: translateY(60px); opacity: 0 } to { transform: none; opacity: 1 } }
.panel-title { font-size: 26px; font-weight: 900; color: #7a4a1a; }
.big-stars span { font-size: 54px; color: #d8cbb0; transition: all .25s; display: inline-block; }
.big-stars span.lit { color: #ffb400; transform: scale(1.25) rotate(-8deg); text-shadow: 0 0 18px #ffd94b; }
#complete-score { font-size: 30px; font-weight: 900; color: #7a4a1a; }
.tiny { font-size: 12px; color: #8a7458; text-align: center; }
#complete-best { color: #e05252; font-weight: 900; font-size: 15px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; width: 100%;
  font-size: 18px; font-weight: 700; color: #6a4a20; padding: 4px 2px; }
.toggle { width: 62px; height: 34px; border-radius: 18px; border: none; background: #cbb89a; position: relative; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 4px; width: 28px; height: 28px;
  border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.toggle.on { background: #58b368; }
.toggle.on::after { left: 30px; }

/* world select */
#world-strip { display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory;
  width: 100%; padding: 10px 6px 18px; -webkit-overflow-scrolling: touch; touch-action: pan-x; }
.world-card { flex: 0 0 240px; scroll-snap-align: center; border-radius: 22px; padding: 16px;
  min-height: 300px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.4); position: relative; }
.world-card.locked { filter: grayscale(.6) brightness(.75); }
.world-name { font-size: 22px; font-weight: 900; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.world-stars { font-size: 16px; font-weight: 700; }
.world-lock { font-size: 40px; }
.world-need { font-size: 14px; font-weight: 700; }
#world-dots { display: flex; gap: 8px; }
#world-dots span { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.4); }
#world-dots span.on { background: #ffd94b; }

/* level grid */
#level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; width: min(94vw, 380px); }
.level-tile { aspect-ratio: 1; border-radius: 16px; border: none; background: rgba(255,255,255,.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900; color: #6a4a20; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.level-tile .tstars { font-size: 10px; letter-spacing: 1px; color: #c9b globalThis892; }
.level-tile .tstars { color: #c9b892; }
.level-tile .tstars .got { color: #ffb400; }
.level-tile.locked { background: rgba(255,255,255,.35); color: rgba(255,255,255,.6); }
.level-tile.next { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,217,75,.7); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(255,217,75,0); } }

/* achievements */
#ach-list { flex: 1; overflow-y: auto; width: 100%; display: flex; flex-direction: column; gap: 8px;
  touch-action: pan-y; }
.ach-row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.7);
  border-radius: 14px; padding: 8px 10px; }
.ach-row .ic { font-size: 24px; width: 32px; text-align: center; }
.ach-row .txt { flex: 1; }
.ach-row .nm { font-size: 14px; font-weight: 900; color: #6a4a20; }
.ach-row .ds { font-size: 11px; color: #8a7458; }
.ach-row .bar { height: 6px; border-radius: 3px; background: #d8cbb0; margin-top: 4px; overflow: hidden; }
.ach-row .bar i { display: block; height: 100%; background: #58b368; }
.ach-row.done { outline: 2px solid #58b368; }
.ach-row.done .ic { filter: none; }
.ach-row:not(.done) .ic { filter: grayscale(1); }

#intro-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#intro-skip { position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); right: 20px;
  color: rgba(255,255,255,.7); font-size: 14px; }

#toast { position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 90px); left: 50%;
  transform: translateX(-50%); background: rgba(30,20,10,.92); color: #ffe9b0; padding: 10px 18px;
  border-radius: 20px; font-size: 15px; font-weight: 700; opacity: 0; transition: opacity .3s;
  pointer-events: none; max-width: 86vw; text-align: center; }
#toast.show { opacity: 1; }

#reset-input { min-height: 44px; font-size: 16px; padding: 6px 12px; border-radius: 12px; border: 2px solid #c9b892; }
#menu-nibbles { cursor: pointer; }
#settings-account { width: 100%; text-align: center; font-size: 13px; color: #6a4a20; }
#settings-account button { margin-top: 6px; }
