@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

:root {
  --panel: #081325;
  --panel-border: #6be7ff;
  --panel-highlight: #9be8ff;
  --muted: #8ab3d9;

  font-family: "Press Start 2P", "Pixel Emulator", "Courier New", monospace;
}

/* --- BASE LAYOUT --- */

html, body {
  height: 100%;
  margin: 0;
  color: #e6eef8;
}

body {
  background: #020712;
  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: radial-gradient(circle at 50% -20%, #284b85 0%, #112446 35%, #050a17 68%, #01030b 100%);
  image-rendering: pixelated;
}

.sky-layer {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 15%, rgba(153, 224, 255, 0.45) 0 3px, rgba(0, 0, 0, 0) 4px),
    radial-gradient(circle at 78% 20%, rgba(153, 224, 255, 0.5) 0 2px, rgba(0, 0, 0, 0) 3px),
    radial-gradient(circle at 40% 60%, rgba(153, 224, 255, 0.35) 0 2px, rgba(0, 0, 0, 0) 3px);
  image-rendering: pixelated;
}

.background::before {
  content: "";
  position: absolute;
  width: 280px;
  height: 120px;
  left: 50%;
  top: 13%;
  transform: translateX(-50%);
  border-radius: 50% 50% 40% 40%;
  background:
    radial-gradient(ellipse at center, rgba(129, 222, 255, 0.95) 0%, rgba(83, 200, 247, 0.9) 45%, rgba(17, 58, 90, 0.85) 75%, rgba(0, 0, 0, 0) 80%);
  box-shadow: 0 0 18px rgba(94, 223, 255, 0.55);
  image-rendering: pixelated;
}

.background::after {
  content: "";
  position: absolute;
  inset: 62% 0 0 0;
  background:
    linear-gradient(180deg, rgba(5, 18, 38, 0) 0%, rgba(12, 41, 80, 0.55) 25%, rgba(8, 23, 47, 0.92) 100%),
    repeating-linear-gradient(90deg, rgba(107, 231, 255, 0.15) 0 6px, rgba(0, 0, 0, 0) 6px 16px);
  image-rendering: pixelated;
}

.background .island {
  position: absolute;
  inset: 58% 0 auto 0;
  height: 42%;
  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, #06172b 0%, #04111f 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, #0b2f52 0%, #0a223a 64%, rgba(0, 0, 0, 0) 64%),
    radial-gradient(circle at 50% 20%, #6be7ff 0 34px, 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 #113b5a;
  image-rendering: pixelated;
}

/* --- GAME CANVAS --- */

canvas {
  background: linear-gradient(180deg, #08172f 0%, #123c72 45%, #04111f 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: #dff8ff;
}

.sub {
  color: var(--muted);
  font-size: 11px;
}

.panel {
  --panel-row-height: clamp(28px, 6vw, 36px);
  --panel-rule-size: 2px;
  background: #102846;
  line-height: var(--panel-row-height);
  padding: calc(var(--panel-row-height) / 2) 12px;
  border-radius: 8px;
  color: #dff8ff;
  border: 3px solid var(--panel-border);
  box-shadow: inset 0 0 0 2px #1b4f73;
  text-shadow: none;
  image-rendering: pixelated;
}

.panel > * {
  line-height: inherit;
}

.panel .sub,
.panel .muted {
  color: #ffffff;
}

.panel button {
  background: #6be7ff;
  border: 2px solid #1b4f73;
  color: #042139;
}

.sidebar .panel {
  background: #14365c;
  border-radius: 8px;
}

.sidebar .panel:nth-of-type(1) {
  background: #1d4f82;
}

.sidebar .leaderboard-panel {
  background: #225d97;
}

.sidebar .info-panel {
  background: #1a4875;
}
.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: #dff8ff;
  border: 4px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 0 0 2px #113b5a;
  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 #1b4f73;
}

.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: #dff8ff;
  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;
  }
}






