:root {
  color-scheme: light;
  --bg: #e6eef8;
  --surface: #e6eef8;
  --shadow-dark: #c2cedd;
  --shadow-light: #ffffff;
  --accent: #2589e6;
  --accent-deep: #0c63b8;
  --ink: #1e2d3d;
  --muted: #60748a;
  --neu-out: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
  --neu-out-sm: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
  --neu-in: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
  --neu-in-sm: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b2230;
  --surface: #1b2230;
  --shadow-dark: #111620;
  --shadow-light: #263044;
  --accent: #38bdf8;
  --accent-deep: #7dd3fc;
  --ink: #e8eff8;
  --muted: #94a3b8;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  gap: 0.75rem;
}

.gba-shell {
  width: 100%;
  height: 100%;
  background: var(--surface);
  border-radius: 22px;
  padding: 0.85rem 1rem;
  box-shadow: var(--neu-out);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.gba-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.gba-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 800;
  font-size: 1rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--neu-out-sm);
  color: var(--accent-deep);
  font-weight: 900;
  font-size: 0.85rem;
}

.screen-frame {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  background: #0b0f17;
  border-radius: 18px;
  padding: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--neu-in);
}

#screen {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #0b0f17;
  border-radius: 10px;
  display: block;
  image-rendering: pixelated;
}

#screen:fullscreen,
#screen:-webkit-full-screen,
#screen.css-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  object-fit: contain !important;
  background: #000 !important;
}

.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

#preload, #ingame {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.hidden, .dead {
  display: none !important;
}

input[type="file"] {
  display: none;
}

button, .chk {
  border: 0;
  border-radius: 12px;
  min-height: 2.35rem;
  padding: 0 0.9rem;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--neu-out-sm);
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: transform 0.14s ease, box-shadow 0.15s ease;
}

button:hover, .chk:hover {
  transform: translateY(-1px);
  color: var(--accent-deep);
}

button:active {
  box-shadow: var(--neu-in-sm);
}

.bigbutton {
  background: linear-gradient(145deg, #2d96f2, #1b77cc);
  color: #ffffff;
}

.bigbutton:hover {
  color: #ffffff;
}

.icon-btn {
  width: 2.35rem;
  padding: 0;
  justify-content: center;
}

#sound {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--surface);
  box-shadow: var(--neu-in-sm);
  padding: 0.3rem 0.7rem;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

#sound input[type="range"] {
  width: 68px;
}

.keys-hint {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.touch-pad {
  display: none;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.15rem;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 38px);
  gap: 4px;
}

.dpad button {
  height: 38px;
  min-height: 38px;
  justify-content: center;
  padding: 0;
}

.ab-btns {
  display: flex;
  gap: 10px;
}

.ab-btns button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  justify-content: center;
  background: linear-gradient(145deg, #f43f5e, #e11d48);
  color: #fff;
}

@media (max-width: 700px) {
  .touch-pad {
    display: flex;
  }
  .keys-hint {
    display: none;
  }
}
