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

html,
body {
  background: #8fcbe8;
  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: none;
  border-radius: 23px;
  background: rgba(255, 251, 240, 0.92);
  color: #4a3728;
  font-family: inherit;
  font-size: 17px;
  font-weight: bold;
  text-decoration: none;
  box-shadow: 0 3px 0 rgba(120, 90, 50, 0.45), 0 4px 12px rgba(0, 0, 0, 0.25);
  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: #fff; }
.bar-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(120, 90, 50, 0.45), 0 2px 6px rgba(0, 0, 0, 0.25); }
.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, #ffe082, #ffca28);
  color: #5d3b00;
  font-size: 20px;
  cursor: default;
}
#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; border-radius: 22px; }
  .pill { height: 44px; font-size: 18px; }
  #topbar { padding: 8px; }
}

/* --- Toast ----------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 12px 22px;
  border-radius: 18px;
  background: rgba(40, 30, 20, 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; }
#settings-panel input[type='range'] { accent-color: #7cb342; }
#settings-close { background: #7cb342; }
#save-reset {
  display: block;
  margin: 18px auto 0;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 14px;
  border: none;
  border-radius: 12px;
  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, 20, 30, 0.55);
  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(820px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 26px 28px;
  background: #fff6dc;
  border: 6px solid #8d6e4a;
  border-radius: 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  color: #4a3728;
  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: #2f5d2f; }

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

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

.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 10px 14px;
  border: 4px solid #8d6e4a;
  border-radius: 20px;
  background: #e8f5d8;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 5px 0 #8d6e4a;
  transition: transform 0.1s;
  color: #4a3728;
}
.level-card:hover { transform: scale(1.04); }
.level-card:active { transform: translateY(3px); box-shadow: 0 2px 0 #8d6e4a; }
.level-card.done { background: #fff3c4; border-color: #c9a63a; box-shadow: 0 5px 0 #c9a63a; }
.level-card .emoji { font-size: 44px; }
.level-card .name { font-size: 20px; font-weight: bold; color: #2f5d2f; }
.level-card .sub { font-size: 13px; color: #6b5a44; line-height: 1.3; }
.level-card .cast { font-size: 18px; letter-spacing: 4px; margin-top: 2px; }
.level-card .best { font-size: 14px; color: #8a6d00; font-weight: bold; min-height: 18px; }

.how { margin: 10px 0 14px; font-size: 14px; color: #6b5a44; 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: none;
  border-radius: 16px;
  cursor: pointer;
  background: #f3e5c3;
  color: #4a3728;
  box-shadow: 0 3px 0 #b89b6a;
}
.panel-buttons button:active,
.tab:active { transform: translateY(2px); box-shadow: 0 1px 0 #b89b6a; }
.go { background: #7cb342 !important; color: #fff !important; box-shadow: 0 3px 0 #4b7a26 !important; }

.tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.tab { font-size: 15px; padding: 8px 12px; opacity: 0.7; }
.tab.active { opacity: 1; background: #ffd966; }

/* --- Shop ---------------------------------------------------------- */
.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.item {
  position: relative;
  border: 3px solid #c9b48a;
  border-radius: 16px;
  padding: 10px 8px 12px;
  background: #fffdf5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.item.equipped { border-color: #4caf50; background: #eaf7e4; }
.item.affordable { border-color: #ffc107; box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.25); }
.item canvas { width: 96px; height: 96px; }
.item .item-name { font-weight: bold; font-size: 15px; }
.item .item-desc { font-size: 12px; color: #6b5a44; min-height: 30px; }
.item .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: bold;
  background: #4caf50;
  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: 52px 1fr; align-items: center; gap: 6px; font-size: 11px; color: #6b5a44; text-align: left; }
.stat .bar { height: 8px; border-radius: 4px; background: #eadfc4; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: #7cb342; border-radius: 4px; }
.item button {
  font-family: inherit;
  font-size: 15px;
  font-weight: bold;
  padding: 7px 14px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: #ffd966;
  color: #4a3728;
  box-shadow: 0 3px 0 #c9a63a;
}
.item button.equip { background: #a5d6a7; box-shadow: 0 3px 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(255, 246, 220, 0), #fff6dc 40%);
}

.level-select {
  display: block;
  margin: 6px auto;
  width: min(320px, 100%);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 18px;
  font-weight: bold;
  border: 3px solid #c9b48a;
  border-radius: 12px;
  background: #fffdf5;
  color: #2f5d2f;
}
.party { border: 4px solid #7cb342; border-radius: 18px; padding: 10px; background: #fffdf5; margin: 12px 0; }
.party h3 { margin-bottom: 8px; font-size: 20px; }
.party ul { list-style: none; }
.party li { padding: 6px 8px; margin: 4px 0; border-radius: 10px; background: #f3e5c3; font-size: 16px; }
.party li.me { background: #ffd966; font-weight: bold; }
.party li.empty { opacity: 0.6; font-size: 14px; }

/* --- Online -------------------------------------------------------- */
.field { display: block; margin: 10px auto; font-size: 18px; }
.field input,
.code-input {
  display: block;
  margin: 6px auto 0;
  width: min(260px, 100%);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 20px;
  border: 3px solid #c9b48a;
  border-radius: 12px;
  text-align: center;
  background: #fffdf5;
  color: #4a3728;
}
.code-input { width: 130px; display: inline-block; margin: 0; letter-spacing: 4px; text-transform: uppercase; }
.code { font-family: monospace; letter-spacing: 6px; background: #ffd966; padding: 2px 12px; border-radius: 10px; }
.error { min-height: 22px; color: #b53b2f; font-size: 15px; margin: 8px 0; }
.invite { margin-bottom: 10px; }
.invite button { font-size: 15px; padding: 8px 14px; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.side { border: 4px solid; border-radius: 18px; padding: 10px; background: #fffdf5; }
.side-0 { border-color: #4caf50; }
.side-1 { border-color: #e53935; }
.side h3 { margin-bottom: 8px; font-size: 20px; }
.side ul { list-style: none; min-height: 60px; }
.side li { padding: 6px 8px; margin: 4px 0; border-radius: 10px; background: #f3e5c3; font-size: 16px; }
.side li.me { background: #ffd966; font-weight: bold; }
.side li.empty { opacity: 0.6; font-size: 14px; }
.pick { margin-top: 6px; padding: 6px 14px; font-family: inherit; font-size: 15px; font-weight: bold; border: none; border-radius: 12px; cursor: pointer; background: #a5d6a7; box-shadow: 0 3px 0 #5a9e5c; }
.results { list-style: none; margin: 10px 0 16px; }
.results li { font-size: 18px; padding: 4px 0; }

@media (max-width: 560px) {
  .sides { grid-template-columns: 1fr; }
  .panel { padding: 18px 14px; border-width: 4px; border-radius: 20px; }
  .panel h2 { font-size: 26px; }
}
