:root {
  --bg: #0b0f1a;
  --panel: #141b2d;
  --ink: #e8ecf5;
  --accent: #ffcc00;
  --accent2: #ff5a5f;
  --mario-blue: #5c94fc;
  --mario-green: #4ea24e;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Press Start 2P', ui-monospace, Menlo, monospace;
  height: 100vh; overflow: hidden;
}
body { font-family: ui-monospace, Menlo, monospace; }

#app {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: 100vh;
}

#game-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  gap: 10px;
  background: linear-gradient(180deg, #1a2140 0%, #0b0f1a 100%);
}

#hud {
  width: 1024px;
  max-width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
  background: #000;
  padding: 10px 14px;
  border: 2px solid #333;
  border-radius: 4px;
}
#hud b { color: #fff; }

#canvas-wrap {
  position: relative;
  width: 1024px;
  max-width: 100%;
}

canvas#game {
  width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--mario-blue);
  border: 4px solid #000;
  box-shadow: 0 0 0 2px #333, 0 20px 40px rgba(0,0,0,.6);
  outline: none;
  display: block;
}

/* Touch controls — always rendered, visible on touch devices */
#touch-pad {
  position: absolute;
  bottom: 12px;
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 14px;
  pointer-events: none;
}
.touch-btn {
  pointer-events: all;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 10px;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  transition: background 0.08s;
  backdrop-filter: blur(2px);
}
.touch-btn:active, .touch-btn.pressed {
  background: rgba(255,204,0,0.35);
  border-color: #ffcc00;
}
.jump-btn {
  background: rgba(255,80,80,0.2);
  border-color: rgba(255,80,80,0.5);
  font-size: 18px;
  font-family: monospace;
  font-weight: 900;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  color: #ff8080;
}
/* On non-touch desktops, make them subtle */
@media (hover: hover) {
  .touch-btn { opacity: 0.4; }
  .touch-btn:hover { opacity: 0.75; }
}

#controls-hint {
  font-size: 11px;
  color: #8892b0;
  letter-spacing: 1px;
}

#lesson {
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  background: #000;
  color: #fff;
  border: 3px solid var(--accent);
  padding: 24px 28px;
  max-width: 600px;
  border-radius: 6px;
  z-index: 20;
  box-shadow: 0 10px 60px rgba(0,0,0,.8);
  font-size: 13px;
  line-height: 1.6;
}
#lesson.hidden { display: none; }
#lesson h2 {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 14px;
  letter-spacing: 2px;
}
#lesson code {
  background: #222;
  padding: 2px 6px;
  border-radius: 3px;
  color: #7fffd4;
}
#lesson .hint { margin-top: 10px; font-size: 11px; color: #8892b0; }

#sidebar {
  background: var(--panel);
  border-left: 2px solid #000;
  display: flex;
  flex-direction: column;
  height: 100vh;
}
#sidebar header {
  padding: 14px;
  border-bottom: 1px solid #222a44;
  background: #0f1424;
}
#sidebar h1 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 2px;
}
#bridge-row {
  margin-top: 6px;
  font-size: 11px;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: #aab;
}
.toggle-label input[type=checkbox] { accent-color: var(--accent); }
.bridge-hint { color: #ffcc0099; font-size: 10px; }
#key-row, #model-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
}
#api-key, #model-select, #chat-input {
  flex: 1;
  background: #0b0f1a;
  color: #fff;
  border: 1px solid #2a3354;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 3px;
}
button {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 6px 10px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 3px;
  font-family: inherit;
  font-size: 11px;
}
button:hover { background: #ffd84d; }

#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
}
.msg {
  padding: 8px 10px;
  border-radius: 6px;
  max-width: 92%;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user { align-self: flex-end; background: #2a3a6a; }
.msg.asst { align-self: flex-start; background: #1d2640; border-left: 3px solid var(--accent); }
.msg.sys  { align-self: center; font-size: 11px; color: #8892b0; font-style: italic; }

#chat-form {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid #222a44;
}
