:root {
  --bg: #000000;
  --card: #111111;
  --text: #ffffff;
  --muted: #999999;
  --line: #333333;
}

/* Light theme (Settings > Theme) */
:root[data-theme="light"] {
  --bg: #ffffff;
  --card: #f2f2f2;
  --text: #000000;
  --muted: #666666;
  --line: #dddddd;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Poppins", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

h1 {
  margin: 0;
  font-size: 2.4rem;
}

h2 {
  margin: 0 0 16px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

/* Shared look for text boxes and dropdowns */
input[type="text"],
select {
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--text);
}

/* ---------- Calculator ---------- */
#calc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 72px 16px;
}

.calculator {
  width: 100%;
  max-width: 320px;
}

#screen {
  padding: 20px 16px;
  margin-bottom: 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 2rem;
  text-align: right;
  overflow-x: auto;
  white-space: nowrap;
}

.keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.keys button {
  padding: 16px 0;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 1.2rem;
  cursor: pointer;
}

.keys button:hover {
  border-color: var(--text);
}

.keys .equals {
  grid-row: span 2;
  background: var(--text);
  color: var(--bg);
}

.keys .zero {
  grid-column: span 2;
}

.code-mode {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  cursor: pointer;
}

/* ---------- Mall layout ---------- */
#site {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 2px solid var(--line);
}

.nav button {
  border: none;
  background: none;
  cursor: pointer;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

/* Logo (flipped to black-on-white in the light theme) */
.logo {
  width: 32px;
  height: 32px;
}

:root[data-theme="light"] .logo {
  filter: invert(1);
}

.hero-logo {
  width: 88px;
  height: 88px;
  margin-bottom: 12px;
}

.nav-icons {
  display: flex;
  gap: 4px;
}

.nav-icons button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.1rem;
  color: var(--muted);
}

.nav-icons button:hover,
.nav-icons button.active {
  background: var(--card);
  color: var(--text);
}

.page {
  flex: 1;
  overflow-y: auto;
  padding: 40px 16px;
}

.page > * {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Home ---------- */
.hero {
  max-width: 640px;
  padding-top: 40px;
  text-align: center;
}

.hero .muted {
  margin: 4px 0 32px;
}

#search {
  display: flex;
  gap: 8px;
}

#address {
  flex: 1;
  min-width: 0;
}

#search button {
  padding: 0 24px;
  border: none;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  cursor: pointer;
}

#proxyHint {
  margin-top: 16px;
}

/* ---------- Games and apps grids ---------- */
#gameSearch {
  display: block;
  width: 100%;
  margin-bottom: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.grid button {
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  overflow: hidden;
}

.grid button:hover {
  border-color: var(--text);
}

.game img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: var(--line);
}

.game span {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.apps button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  text-align: left;
}

.apps img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  filter: grayscale(1);
}

/* ---------- Movies ---------- */
#movies {
  display: flex;
  padding: 0;
}

#moviesFrame {
  flex: 1;
  max-width: none;
  border: none;
}

/* ---------- Settings ---------- */
.settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.setting h3 {
  margin: 0;
  font-size: 1rem;
}

.setting p {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.setting input[type="text"],
.setting select {
  width: 220px;
  max-width: 50%;
  background: var(--bg);
}

.choices {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.choices button,
.action {
  padding: 6px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
}

.choices button.active,
.action:hover {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

@media (max-width: 600px) {
  .setting {
    flex-direction: column;
    align-items: stretch;
  }

  .setting input[type="text"],
  .setting select {
    width: 100%;
    max-width: none;
  }

  .brand {
    display: none;
  }
}

#error {
  color: var(--muted);
}

/* ---------- Viewer ---------- */
#viewer {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 2px solid var(--line);
}

.bar button {
  padding: 4px 14px;
  border: none;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
}

#current {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.85rem;
  color: var(--muted);
}

#frame {
  flex: 1;
  width: 100%;
  border: none;
  background: white;
}
