/* =========================
   B+ MATH UI — CLEAN UPGRADE
   ========================= */

:root {
  --primary: #b584fa;
  --bg: #ffffff;
  --text: #222;
  --card: #f5f5f5;
  --border: #e6e6e6;
  --shadow: rgba(0,0,0,0.08);
  --popup: #ffffff;
  --radius: 12px;
  --transition: 0.2s ease;
  --font: "Comic Sans MS", "Arial Rounded MT Bold", sans-serif;
}

.dark-mode {
  --primary: #7a4dff;
  --bg: #121212;
  --text: #eaeaea;
  --card: #1e1e1e;
  --border: #2c2c2c;
  --shadow: rgba(0,0,0,0.4);
  --popup: #1e1e1e;
}

/* =========================
   BASE
   ========================= */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: var(--transition);
}

/* =========================
   HEADER (CLEANER + MODERN)
   ========================= */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  box-shadow: 0 4px 12px var(--shadow);
}

.header-content {
  max-width: 1200px;
  margin: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  white-space: nowrap;
}

/* =========================
   INPUTS
   ========================= */

#searchBar,
#sortOptions {
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  outline: none;
  font-family: var(--font);
  transition: var(--transition);
}

#searchBar {
  flex: 1;
}

/* =========================
   MAIN LAYOUT
   ========================= */

main {
  max-width: 1200px;
  margin: auto;
  padding: 16px;
}

/* unified grid system */
#container,
#featuredZones,
#gameGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

/* =========================
   GAME / CARD STYLE (IMPROVED)
   ========================= */

.zone-item,
.game {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.zone-item:hover,
.game:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px var(--shadow);
}

/* image consistency */
.zone-item img,
.game img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

/* button inside card */
.zone-item button {
  border: none;
  padding: 12px;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.zone-item button:hover {
  background: rgba(0,0,0,0.05);
}

/* =========================
   MODALS (CLEANED)
   ========================= */

#zoneViewer,
#gameModal {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
  z-index: 1000;
}

.zone-header,
.modalTop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--primary);
  color: white;
}

/* unified button style */
.zone-controls button,
.modalButtons button {
  border: 1px solid rgba(255,255,255,0.5);
  background: transparent;
  color: white;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.zone-controls button:hover,
.modalButtons button:hover {
  background: rgba(255,255,255,0.2);
}

#zoneFrame,
#gameFrame {
  flex: 1;
  width: 100%;
  border: none;
  background: black;
}

/* =========================
   POPUP (MODERNIZED)
   ========================= */

#popupOverlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
}

.popup {
  width: 90%;
  max-width: 520px;
  background: var(--popup);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  overflow: hidden;
}

.popup-header {
  background: var(--primary);
  color: white;
  padding: 12px;
  display: flex;
  justify-content: space-between;
}

#popupBody {
  padding: 14px;
}

/* inputs inside popup */
#popupBody input,
#popupBody button {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* =========================
   FOOTER
   ========================= */

footer {
  margin-top: 24px;
  padding: 16px;
  text-align: center;
  background: var(--card);
  border-top: 1px solid var(--border);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}
