:root {
  --bg-page: #020617;
  --bg-card: #02081b;
  --bg-card-soft: #020920;
  --bg-panel: #020819;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --accent-text: #4ade80;
  --danger: #f97316;
  --text-main: #e5e7eb;
  --text-soft: #9ca3af;
  --border-soft: #0f172a;
  --radius-lg: 1.5rem;
  --radius-md: 0.9rem;
  --radius-sm: 0.5rem;
  --shadow-card: 0 24px 60px rgba(15, 23, 42, 0.7);
  --font-main: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top, #020617 0, #000 55%, #020617 100%);
  color: var(--text-main);
  font-family: var(--font-main);
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

/* PAGE STRUCTURE */

.game-page {
  width: 100%;
  max-width: 1100px;
  padding: 2.25rem 1.5rem 3rem;
}

.game-header {
  margin-bottom: 1.25rem;
}

.game-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.game-brand {
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.game-title {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 2.4rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.game-tagline {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 1.5rem;
  margin-top: 1.25rem;
}

/* MAIN CARD */

.game-card {
  background: radial-gradient(circle at top left, #02091e, #020617 70%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
  padding: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#platformer-canvas {
  display: block;
  width: 100%;
  max-width: 720px;
  height: auto;
  border-radius: 0.9rem;
  background: #fcdfcd; /* fallback while loading */
}

/* SIDEBAR */

.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.game-panel {
  background: linear-gradient(135deg, var(--bg-card-soft), var(--bg-panel));
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-soft);
}

.game-panel h2 {
  margin: 0 0 0.45rem;
  font-size: 0.9rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.95rem;
}

.stat-row span:first-child {
  color: var(--text-soft);
}

.stat-value {
  font-weight: 600;
  color: var(--accent-text);
}

.status-text {
  margin: 0;
  font-size: 0.9rem;
}

.controls-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.86rem;
  color: var(--text-soft);
}

/* BUTTONS */

.back-button {
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: #020715;
  color: var(--text-soft);
  font-size: 0.8rem;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.12s;
}

.back-button:hover {
  background: #020b1f;
  color: var(--text-main);
  border-color: #1f2937;
  transform: translateY(-1px);
}

/* MOBILE TOUCH CONTROLS */

.pf-touch {
  margin-top: 1.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.pf-touch-row {
  display: flex;
  gap: 0.45rem;
}

.pf-touch-btn {
  min-width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: #020617;
  color: var(--text-main);
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.12s, box-shadow 0.2s;
}

.pf-touch-btn:active {
  transform: translateY(1px) scale(0.96);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.7);
  background: #02091e;
}

/* RESPONSIVE */

@media (max-width: 920px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .game-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .game-panel {
    flex: 1 1 45%;
  }
}

@media (max-width: 640px) {
  .game-page {
    padding-inline: 0.75rem;
  }

  .game-sidebar {
    flex-direction: column;
  }

  .game-panel {
    flex: 1 1 auto;
  }

  .game-title {
    font-size: 1.6rem;
  }

  .game-tagline {
    font-size: 0.82rem;
  }
}
/* Make sure the card can hold an absolute overlay */
.game-card {
  position: relative;
  overflow: hidden;
}

/* Win / lose overlay */
.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 18, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.game-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.game-overlay-card {
  background: rgba(15, 23, 42, 0.98);
  border-radius: 16px;
  padding: 20px 24px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  color: #e5e7eb;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
}

.game-overlay-card h2 {
  margin-bottom: 6px;
  font-size: 1.3rem;
}

.game-overlay-detail {
  margin: 8px 0 14px;
  font-size: 0.9rem;
  opacity: 0.85;
}

/* Small rounded button */
.btn-primary {
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #020617;
  cursor: pointer;
}
.btn-primary:hover {
  filter: brightness(1.06);
}
