@import url('../../shared/ui.css');

html,
body {
  background: #1b2a5a;
  cursor: crosshair;
  font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
}

/* --- Top bar --------------------------------------------------------- */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  pointer-events: none;
  z-index: 3;
}
.bar-side { display: flex; gap: 8px; align-items: center; pointer-events: auto; }

.bar-btn,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 46px;
  padding: 0 14px;
  border: 3px solid #1e1e1e;
  border-radius: 6px;
  background: #c6c6c6;
  box-shadow: inset 3px 3px 0 #ffffff, inset -3px -3px 0 #555555, 0 4px 12px rgba(0, 0, 0, 0.35);
  color: #2b2b2b;
  font-family: inherit;
  font-size: 17px;
  font-weight: bold;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
  white-space: nowrap;
}
.bar-btn .ico { font-size: 22px; line-height: 1; }
.bar-btn.icon-only { width: 46px; padding: 0; justify-content: center; }
.bar-btn:hover { background: #d8d8d8; }
.bar-btn:active { transform: translateY(2px); box-shadow: inset 3px 3px 0 #555555, inset -3px -3px 0 #ffffff; }
.bar-btn.attention { animation: wiggle 1.2s ease-in-out infinite; background: #ffe082; }
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-4deg) scale(1.05); }
  40% { transform: rotate(4deg) scale(1.05); }
  60% { transform: rotate(-2deg); }
}

#coins-pill {
  background: linear-gradient(180deg, #b2ebf2, #4dd0e1);
  color: #004d5a;
  font-size: 20px;
  cursor: default;
  box-shadow: inset 3px 3px 0 #e0f7fa, inset -3px -3px 0 #0097a7, 0 4px 12px rgba(0, 0, 0, 0.35);
}
#coins-pill .ico { font-size: 22px; }
#coins-pill.bump { animation: bump 0.4s ease-out; }
@keyframes bump {
  0% { transform: scale(1); }
  30% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@media (max-width: 960px) {
  .bar-btn .lbl { display: none; }
  .bar-btn { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .pill { height: 44px; font-size: 18px; }
  #topbar { padding: 8px; }
}

/* --- Touch pad ------------------------------------------------------- */
#touch-pad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
  z-index: 3;
}
#touch-pad.hidden { display: none; }
.pad-group { display: flex; gap: 10px; }
.pad-btn {
  pointer-events: auto;
  width: 74px;
  height: 74px;
  border: 3px solid #1e1e1e;
  border-radius: 10px;
  background: rgba(198, 198, 198, 0.85);
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.8), inset -3px -3px 0 rgba(60, 60, 60, 0.8);
  font-size: 30px;
  font-family: inherit;
  color: #2b2b2b;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.pad-btn:active, .pad-btn.down { background: rgba(255, 224, 130, 0.95); }
.pad-btn.jump { width: 90px; }

/* --- Toast ----------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  padding: 12px 22px;
  border-radius: 6px;
  border: 3px solid #1e1e1e;
  background: rgba(30, 30, 30, 0.92);
  color: #fff;
  font-size: 19px;
  font-weight: bold;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 6;
  animation: toast-in 0.25s ease-out;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* --- Settings tweaks ------------------------------------------------ */
#settings-panel { z-index: 5; border-radius: 8px; border: 4px solid #3a3a3a; background: #e8e8e8; }
#settings-panel input[type='range'] { accent-color: #5cb85c; }
#settings-close { background: #5cb85c; }
#save-reset {
  display: block;
  margin: 18px auto 0;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 14px;
  border: 2px solid #7a2020;
  border-radius: 6px;
  background: #ffcdd2;
  color: #7a2020;
  cursor: pointer;
}

/* --- Overlays and panels ------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 20, 0.6);
  padding: 16px;
  z-index: 5;
  animation: fade-in 0.15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.overlay.hidden { display: none; }
.hidden { display: none !important; }

.panel {
  width: min(880px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 26px 28px;
  background: #c6c6c6;
  border: 5px solid #1e1e1e;
  border-radius: 8px;
  box-shadow: inset 5px 5px 0 #ffffff, inset -5px -5px 0 #555555, 0 12px 40px rgba(0, 0, 0, 0.6);
  color: #2b2b2b;
  text-align: center;
  animation: pop-in 0.2s ease-out;
}
.panel.small { width: min(480px, 100%); }
@keyframes pop-in {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.panel h2 { font-size: 32px; margin-bottom: 12px; color: #2b2b2b; text-shadow: 2px 2px 0 #ffffff; }

.coins { font-size: 22px; margin-bottom: 14px; font-weight: bold; color: #005f6b; }

.levels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px 12px;
  border: 3px solid #1e1e1e;
  border-radius: 6px;
  background: #8fbc5a;
  background-image: linear-gradient(180deg, #a5d66a 0 26%, #8a6440 26% 100%);
  font-family: inherit;
  cursor: pointer;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.5), inset -3px -3px 0 rgba(0, 0, 0, 0.35), 0 5px 0 #1e1e1e;
  transition: transform 0.1s;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.7);
}
.level-card:hover { transform: scale(1.04); }
.level-card:active { transform: translateY(3px); box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.5), inset -3px -3px 0 rgba(0, 0, 0, 0.35), 0 2px 0 #1e1e1e; }
.level-card.done { background-image: linear-gradient(180deg, #ffe082 0 26%, #c9a63a 26% 100%); }
.level-card.adventure { background-image: linear-gradient(180deg, #80deea 0 26%, #4a8ac8 26% 100%); }
.level-card .emoji { font-size: 40px; }
.level-card .name { font-size: 19px; font-weight: bold; }
.level-card .sub { font-size: 12px; line-height: 1.3; color: #f3e5c3; }
.level-card .cast { font-size: 17px; letter-spacing: 4px; margin-top: 2px; }
.level-card .best { font-size: 13px; color: #ffe082; font-weight: bold; min-height: 18px; }

.how { margin: 10px 0 14px; font-size: 14px; color: #3a3a3a; line-height: 1.5; }

.panel-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.panel-buttons button,
.tab {
  padding: 11px 22px;
  font-size: 18px;
  font-family: inherit;
  font-weight: bold;
  border: 3px solid #1e1e1e;
  border-radius: 4px;
  cursor: pointer;
  background: #8b8b8b;
  color: #fff;
  text-shadow: 2px 2px 0 #3a3a3a;
  box-shadow: inset 3px 3px 0 #b0b0b0, inset -3px -3px 0 #555555;
}
.panel-buttons button:active,
.tab:active { transform: translateY(2px); box-shadow: inset 3px 3px 0 #555555, inset -3px -3px 0 #b0b0b0; }
.go { background: #5cb85c !important; box-shadow: inset 3px 3px 0 #8fd98f, inset -3px -3px 0 #3a7a3a !important; }

.tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.tab { font-size: 15px; padding: 8px 12px; opacity: 0.8; }
.tab.active { opacity: 1; background: #ffd966; color: #3a2a00; text-shadow: none; box-shadow: inset 3px 3px 0 #fff3c4, inset -3px -3px 0 #c9a63a; }

/* --- Shop ---------------------------------------------------------- */
.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.item {
  position: relative;
  border: 3px solid #555;
  border-radius: 4px;
  padding: 10px 8px 12px;
  background: #e0e0e0;
  box-shadow: inset 2px 2px 0 #ffffff, inset -2px -2px 0 #9a9a9a;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.item.equipped { border-color: #3a7a3a; background: #d9efd0; }
.item.affordable { border-color: #e0a800; box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.35), inset 2px 2px 0 #ffffff, inset -2px -2px 0 #9a9a9a; }
.item canvas { width: 96px; height: 96px; image-rendering: pixelated; }
.item .item-name { font-weight: bold; font-size: 15px; }
.item .item-desc { font-size: 12px; color: #4a4a4a; min-height: 30px; }
.item .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: bold;
  background: #3a7a3a;
  color: #fff;
}
.item .badge.new { background: #ffc107; color: #5d3b00; }
.stats { width: 100%; display: flex; flex-direction: column; gap: 3px; margin: 2px 0; }
.stat { display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 6px; font-size: 11px; color: #4a4a4a; text-align: left; }
.stat .bar { height: 8px; border-radius: 2px; background: #b0b0b0; overflow: hidden; border: 1px solid #555; }
.stat .bar i { display: block; height: 100%; background: #5cb85c; }
.item button {
  font-family: inherit;
  font-size: 15px;
  font-weight: bold;
  padding: 7px 14px;
  border: 2px solid #1e1e1e;
  border-radius: 4px;
  cursor: pointer;
  background: #ffd966;
  color: #3a2a00;
  box-shadow: inset 2px 2px 0 #fff3c4, inset -2px -2px 0 #c9a63a;
}
.item button.equip { background: #a5d6a7; box-shadow: inset 2px 2px 0 #d9efd0, inset -2px -2px 0 #5a9e5c; }
.item button.on { background: #4caf50; color: #fff; box-shadow: none; cursor: default; }
.item button:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.item .need { font-size: 11px; color: #a0522d; min-height: 14px; }

.shop-panel .panel-buttons {
  position: sticky;
  bottom: -26px;
  margin: 0 -28px -26px;
  padding: 12px 0 18px;
  background: linear-gradient(180deg, rgba(198, 198, 198, 0), #c6c6c6 40%);
}

@media (max-width: 560px) {
  .panel { padding: 18px 14px; border-width: 4px; }
  .panel h2 { font-size: 26px; }
}
