@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

:root {
  --panel: #2b1407;
  --panel-border: #ffcc55;
  --panel-highlight: #ffd98e;
  --muted: #1f0c05;

  font-family: "Press Start 2P", "Pixel Emulator", "Courier New", monospace;
}

/* --- BASE LAYOUT --- */

html, body {
  height: 100%;
  margin: 0;
  color: #e6eef8;
}

body {
  background: #1a0500;
  position: relative;
  min-height: 100vh;
  overflow-y: auto;
}

.background {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #3b004a 0%, #7a1b6a 35%, #ff6b6b 65%, #ffb347 78%, #1d5b7a 100%);
  image-rendering: pixelated;
}

.sky-layer {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 226, 160, 0.45) 0%, rgba(255, 127, 80, 0.12) 45%, rgba(0, 0, 0, 0) 70%);
  image-rendering: pixelated;
}

.background::before {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  left: 50%;
  top: 14%;
  transform: translateX(-50%);
  background: radial-gradient(circle, #ffeaa0 0%, #ffd166 45%, rgba(255, 122, 89, 0.7) 68%, rgba(255, 122, 89, 0.0) 70%);
  image-rendering: pixelated;
}

.background::after {
  content: "";
  position: absolute;
  inset: 60% 0 0 0;
  background:
    linear-gradient(180deg, rgba(14, 54, 80, 0.92) 0%, #052438 50%, #01131f 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 8px, rgba(0, 0, 0, 0) 8px 16px);
  image-rendering: pixelated;
}

.background .island {
  position: absolute;
  inset: 55% 0 auto 0;
  height: 45%;
  pointer-events: none;
  image-rendering: pixelated;
}

.background .island::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 420px;
  height: 120px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, #1a0f08 0%, #120905 55%, rgba(0, 0, 0, 0) 70%);
  filter: none;
}

.background .island::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 180px;
  height: 220px;
  transform: translateX(-50%);
  background:
    linear-gradient(180deg, #1a0f08 0%, #1a0f08 60%, rgba(0, 0, 0, 0) 60%),
    radial-gradient(circle at 50% 20%, #1a0f08 0 36px, rgba(0, 0, 0, 0) 38px);
  clip-path: polygon(50% 0%, 64% 30%, 58% 34%, 72% 70%, 50% 100%, 28% 70%, 42% 34%, 36% 30%);
}

.wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  z-index: 1;
}

/* --- GAME CARD (600 × 1100 px) --- */

.game-card {
  width: min(600px, calc(100vw - 32px));
  height: min(1100px, calc(100vh - 32px));
  max-width: 600px;
  max-height: 1100px;

  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
  align-items: start;
}

.game-pane {
  position: relative;
  padding: 5px;
  background: var(--panel);
  border-radius: 8px;
  border: 4px solid var(--panel-border);
  box-shadow: 0 0 0 2px #4a1f09;
  image-rendering: pixelated;
}

/* --- GAME CANVAS --- */

canvas {
  background: linear-gradient(180deg, #5d00a8 0%, #ff8a5c 45%, #0d3b5f 100%);
  border-radius: 6px;
  display: block;
  position: relative;
  z-index: 1;

  width: 100%;
  height: 700px;    /* fits inside 1100px total layout */
  object-fit: cover;
  image-rendering: pixelated;
}

/* --- SIDEBAR ---- */

.sidebar {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud {
  display: flex;
  gap: 12px;
  align-items: center;
}

.score {
  font-size: 16px;
  font-weight: 700;
  color: #fff4c2;
}

.sub {
  color: var(--muted);
  font-size: 11px;
}

.panel {
  --panel-row-height: clamp(28px, 6vw, 36px);
  --panel-rule-size: 2px;
  background: #3b1c0b;
  line-height: var(--panel-row-height);
  padding: calc(var(--panel-row-height) / 2) 12px;
  border-radius: 8px;
  color: #fff4c2;
  border: 3px solid var(--panel-border);
  box-shadow: inset 0 0 0 2px #4a1f09;
  text-shadow: none;
  image-rendering: pixelated;
}

.panel > * {
  line-height: inherit;
}

.panel .sub,
.panel .muted {
  color: #ffffff;
}

.panel button {
  background: #ff8a5c;
  border: 2px solid #4a1f09;
  color: #1f0c05;
}

.sidebar .panel {
  background: #6b3a1e;
  border-radius: 8px;
}

.sidebar .panel:nth-of-type(1) {
  background: #ffcf5c;
}

.sidebar .leaderboard-panel {
  background: #ff8a5c;
}

.sidebar .info-panel {
  background: #2b7a78;
}
.info-panel {
  padding: 10px 12px;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  table-layout: fixed;
}

.info-table tr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.info-table .label {
  font-weight: 600;
  padding: 0 8px 0 0;
  white-space: nowrap;
  color: #ffffff;
  height: var(--panel-row-height);
  flex: 0 0 auto;
}

.info-table .value {
  padding: 0;
  vertical-align: middle;
  min-height: var(--panel-row-height);
  width: auto;
  display: flex;
  justify-content: flex-end;
  flex: 1 1 0;
  min-width: 0;
}

.x-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border: 2px solid #4a1f09;
  border-radius: 6px;
  background: #ffd166;
  color: #1f0c05;
  text-decoration: none;
  max-width: 100%;
}

.x-link:hover {
  background: #ffe27a;
}

.x-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.copyable {
  display: block;
  width: 100%;
  background: #ffe9b3;
  border: 2px solid #4a1f09;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 10px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  position: relative;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.copyable[data-status="copied"]::after {
  content: "Copied!";
  position: absolute;
  right: 8px;
  top: -18px;
  font-size: 11px;
  background: #000000;
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.pwr {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

button {
  background: #ffd166;
  border: 2px solid #4a1f09;
  color: #1f0c05;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  max-width: 100%;
  box-sizing: border-box;
}

.large-btn {
  font-size: 16px;
  padding: 12px;
}

/* --- OVERLAYS --- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(43, 20, 7, 0.88), rgba(3, 17, 28, 0.95));
  padding: 14px;
  box-sizing: border-box;
  z-index: 2;
  image-rendering: pixelated;
}

#startScreen,
#settingsModal,
#gameOverScreen {
  z-index: 3;
}

#gameOverScreen {
  background: url('images/gameover.png');
  background-position: center;
  background-size: cover;
  image-rendering: pixelated;
}

#startScreen {
  background: url('images/open.png');
  background-position: center;
  background-size: cover;
  image-rendering: pixelated;
}

/* --- OVERLAY WINDOWS (energy / fire theme) --- */

.xp-window {
  width: min(92vw, 700px);
  background: linear-gradient(180deg, #2b7a78 0%, #144b5c 100%);
  color: #fff4c2;
  border: 4px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 0 0 2px #4a1f09;
  overflow: hidden;
  text-align: center;
  font-family: inherit;
  image-rendering: pixelated;
}

.xp-titlebar {
  background: linear-gradient(90deg, #ff8a5c 0%, #ffd166 100%);
  color: #1f0c05;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 2px #4a1f09;
}

.xp-controls { display: none; gap: 6px; }
.xp-control {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(180deg, #fff2a3 0%, #f7d94a 100%);
  border: 1px solid #f7d94a;
  box-shadow: inset 0 0 4px rgba(255, 246, 200, 0.6);
  display: inline-block;
}
.xp-control.xp-close {
  background: linear-gradient(180deg, #ffe4e0 0%, #e25a2a 100%);
  border-color: #f5b49c;
}

.xp-body {
  padding: 18px 20px 22px;
  background: linear-gradient(180deg, #2b7a78 0%, #144b5c 100%);
  text-align: center;
  border-top: 2px solid #4a1f09;
}

.xp-heading {
  margin: 0 0 8px;
  color: #fff4c2;
  text-shadow: none;
}

.xp-subtext { margin: 0 0 12px; color: #fff4c2; }
.xp-footnote { margin-top: 6px; color: #fff4c2; }

.xp-field-row {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

.xp-input {
  width: min(360px, 100%);
  padding: 12px 14px;
  border-radius: 6px;
  border: 2px solid #4a1f09;
  background: #ffe9b3;
  color: #1f0c05;
  font-size: 12px;
  box-shadow: none;
}

.xp-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.xp-btn {
  background: linear-gradient(180deg, #ffd166 0%, #ff8a5c 100%);
  border: 2px solid #4a1f09;
  color: #1f0c05;
  padding: 12px 16px;
  border-radius: 6px;
  box-shadow: none;
  cursor: pointer;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.xp-btn.large { padding: 14px 24px; }
.xp-btn:hover { transform: translateY(-1px); filter: none; }
.xp-btn:active { transform: translateY(0); background: linear-gradient(180deg, #ff8a5c 0%, #ff6b6b 100%); }
.xp-btn:disabled { cursor: not-allowed; color: #4a1f09; background: linear-gradient(180deg, #b7a05e 0%, #8c6b3f 100%); border-color: #4a1f09; }

.xp-window .sub,
.xp-window .muted { color: #ffffff; }

.dragonballer-title,
#startScreen .xp-heading { color: #ffd166; }

#startScreen .xp-titlebar span { display: none; }

#startScreen .xp-window,
#gameOverScreen .xp-window {
  position: relative;
  background: linear-gradient(180deg, #2b7a78 0%, #144b5c 100%);
  border-width: 4px;
}

#startScreen .xp-window::before,
#gameOverScreen .xp-window::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 209, 102, 0.18) 0%, rgba(0, 0, 0, 0) 45%);
  pointer-events: none;
  mix-blend-mode: normal;
}

#startScreen .xp-titlebar,
#startScreen .xp-body,
#gameOverScreen .xp-titlebar,
#gameOverScreen .xp-body {
  background: linear-gradient(180deg, #2b7a78 0%, #144b5c 100%);
}

.start-window { max-width: 520px; }
.settings-window { max-width: 720px; }
.gameover-window { max-width: 460px; }

/* --- LEADERBOARD --- */

.lb {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.lb li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--panel-row-height);
  padding: 0 6px;
  border-radius: 6px;
}

.muted {
  color: var(--muted);
}

.leaderboard-panel {
  display: flex;
  flex-direction: column;
}

.leaderboard-panel > div {
  flex-wrap: wrap;
  gap: 6px;
}

.leaderboard-panel #clearLb {
  padding: 6px 8px;
  font-size: 10px;
}

.leaderboard-panel .lb {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 320px;
  overflow: auto;
}

/* --- SETTINGS GRID (choose somale) --- */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.skin-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-direction: row;
  flex-wrap: wrap;
}

.skin-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.skin-option input {
  transform: scale(1.05);
}

.skin-option span {
  white-space: nowrap;
  text-align: left;
}

.preview {
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-repeat: no-repeat;
  background-position: center;
}

.player-preview {
  height: 96px;
  background-size: contain;
  background-position: center bottom;
  border: 1px solid rgba(17, 64, 139, 0.25);
}

.background-preview {
  height: 140px;
  aspect-ratio: 9 / 16;
  background-size: contain;
  background-position: center top;
  border: 1px solid rgba(17, 64, 139, 0.25);
}

/* --- RESPONSIVE (mobile fallback) --- */

@media (max-width: 860px) {
  body {
    overflow-y: auto;
  }

  .wrap {
    align-items: flex-start;
    padding-top: 28px;
    padding-bottom: 32px;
  }

  .game-card {
    width: 100%;
    max-width: 760px;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .sidebar {
    flex-direction: column;
  }

   .leaderboard-panel .lb {
    max-height: min(50vh, 420px);
  }

  canvas {
    height: 60vh;
  }
}






