:root {
  --peach: #fbd9b3;
  --peach-dark: #f0c188;
  --outline: #1a1a1a;
  --outline-soft: #8a8a8a;
  --bg: #202225;
  --panel: #2b2e33;
  --text: #f2f2f2;
  --accent: #49b675;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------------- Header ---------------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 2px solid var(--outline);
}
.site-header h1 { font-size: 1.1rem; margin: 0; }

/* ---------------- Buttons (shared) ---------------- */
.btn {
  border: 2px solid var(--outline);
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
}
.btn-primary { background: var(--accent); color: #06210f; }
.btn-secondary { background: #444; color: var(--text); }
.btn-tiny { padding: 6px 12px; font-size: 0.8rem; background: var(--accent); color: #06210f; border-radius: 6px; }

/* ---------------- Tip modal ---------------- */
.tip-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.tip-overlay[hidden] { display: none; }
.tip-card {
  background: var(--panel);
  border: 2px solid var(--outline);
  border-radius: 14px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  position: relative;
  text-align: center;
}
.tip-card h2 { margin-top: 0; }
.tip-card p { font-size: 0.9rem; line-height: 1.4; color: #d7d7d7; }
.tip-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}
.tip-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 16px 0 8px;
  flex-wrap: wrap;
}
.tip-status { font-size: 0.85rem; min-height: 1.2em; color: var(--accent); }
.tip-address { font-size: 0.7rem; word-break: break-all; color: #999; }
.tip-address code { color: #bbb; }

/* Performance-tips modal specifics */
.perf-list {
  text-align: left;
  font-size: 0.88rem;
  line-height: 1.6;
  margin: 14px 0;
  padding-left: 22px;
  color: #e6e6e6;
}
.perf-note {
  font-size: 0.82rem;
  color: #b9b9b9;
}
.perf-reopen-row {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 620px;
}

/* ---------------- Stage layout ---------------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px 12px 60px;
}

.game-wrap {
  width: 100%;
  max-width: 900px;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 3px solid var(--outline);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.ruffle-container { width: 100%; height: 100%; }
.ruffle-container ruffle-player { width: 100% !important; height: 100% !important; }

.loading-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 0.95rem;
  background: #000;
}

/* ---------------- Gameboy pad ---------------- */
.gb-pad {
  width: 100%;
  max-width: 620px;
  background: var(--panel);
  border: 2px solid var(--outline);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  user-select: none;
  position: relative;
}

.gb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shoulders { justify-content: space-between; }

.gb-btn {
  background: var(--peach);
  border: 3px solid var(--outline);
  border-radius: 12px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--outline);
  cursor: pointer;
  touch-action: none;
  white-space: nowrap;
}
.gb-btn:active,
.gb-btn.pressed {
  background: var(--peach-dark);
  transform: translateY(2px);
}

.shoulder {
  width: 42%;
  height: 56px;
  border-radius: 14px 14px 10px 10px;
}

.main-row {
  justify-content: space-between;
  align-items: center;
}

/* D-Pad */
.dpad {
  position: relative;
  width: 150px;
  height: 150px;
  flex-shrink: 0;
}
.dpad-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 78px; height: 78px;
  background: var(--peach);
  border: 3px solid var(--outline);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 1;
}
.dpad-btn {
  position: absolute;
  background: var(--peach);
  border: 3px solid var(--outline);
  cursor: pointer;
  touch-action: none;
}
.dpad-btn:active, .dpad-btn.pressed { background: var(--peach-dark); }
.dpad-up    { top: 0;   left: 50%; width: 50px; height: 55px; transform: translateX(-50%); border-radius: 10px 10px 0 0; }
.dpad-down  { bottom: 0;left: 50%; width: 50px; height: 55px; transform: translateX(-50%); border-radius: 0 0 10px 10px; }
.dpad-left  { top: 50%; left: 0;   width: 55px; height: 50px; transform: translateY(-50%); border-radius: 10px 0 0 10px; }
.dpad-right { top: 50%; right: 0;  width: 55px; height: 50px; transform: translateY(-50%); border-radius: 0 10px 10px 0; }

/* Face buttons: only A / B (blank circles from reference omitted) */
.face-buttons {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}
.face {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  font-size: 1.3rem;
}

.utility-row {
  justify-content: center;
  gap: 14px;
}
.util {
  padding: 10px 22px;
  border-radius: 16px;
  font-size: 0.95rem;
}

.zoom-popover {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  background: #1c1e21;
  border: 2px solid var(--outline);
  border-radius: 12px;
  padding: 8px;
}
.zoom-popover[hidden] { display: none; }
.zoom-sub {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-size: 1.2rem;
}

/* ---------------- Legend ---------------- */
.legend {
  width: 100%;
  max-width: 620px;
  background: var(--panel);
  border: 1px solid var(--outline-soft);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.85rem;
}
.legend summary { cursor: pointer; font-weight: 700; }
.legend ul { margin: 10px 0 0; padding-left: 18px; line-height: 1.6; }

@media (max-width: 480px) {
  .dpad { width: 120px; height: 120px; }
  .face { width: 52px; height: 52px; }
}
