/* ============================================
   Game Platform - Shared Styles
   Prefix: gp- to avoid conflicts with game CSS
   ============================================ */

:root {
  --gp-header-h: 80px;
}

[data-theme="light"] {
  --gp-page: #f4f2fb;
  --gp-page-grad: linear-gradient(160deg, #fdf8ff 0%, #f1f3ff 50%, #eaf7ff 100%);
  --gp-surface: #ffffff;
  --gp-surface-2: #f4f2fb;
  --gp-ink: #1f1b45;
  --gp-ink-2: #57537e;
  --gp-ink-3: #8b87ad;
  --gp-line: rgba(31, 27, 69, 0.1);
  --gp-shadow: 0 10px 30px rgba(31, 27, 69, 0.1);
  --gp-overlay: rgba(250, 248, 255, 0.95);
  --gp-accent: #7c3aed;
}

/* Header */
#gp-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: #1a1a2e;
  font-family: 'Segoe UI', sans-serif;
}

.gp-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  height: 48px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.gp-back {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 4px;
  color: #888;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.2s;
}
.gp-back:hover { color: #00d4ff; }

.gp-game-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
}

.gp-header-actions {
  display: flex;
  gap: 8px;
}

.gp-header-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  border-radius: 6px;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.gp-header-actions button:hover {
  background: rgba(255,255,255,0.1);
}
.gp-header-actions button:disabled {
  opacity: 0.35;
  cursor: default;
  background: none;
}

.gp-pause {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(8, 10, 22, 0.78);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  color: #fff;
  font-family: 'Segoe UI', sans-serif;
  text-align: center;
  cursor: pointer;
}
.gp-pause[hidden] { display: none; }
.gp-pause-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 6px;
  text-transform: uppercase;
}
.gp-pause-resume {
  padding: 10px 32px;
  border: 2px solid #00d4ff;
  border-radius: 999px;
  background: rgba(0, 212, 255, 0.12);
  color: #00d4ff;
  font: 700 15px 'Segoe UI', sans-serif;
  letter-spacing: 1px;
  cursor: pointer;
}
.gp-pause-resume:hover { background: rgba(0, 212, 255, 0.25); }
.gp-pause-hint {
  font-size: 12px;
  color: #9aa3c0;
  letter-spacing: 0.5px;
}

.gp-header-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  height: 32px;
  gap: 24px;
  padding: 0 16px;
  font-size: 13px;
  color: #888;
  background: rgba(0,0,0,0.2);
  white-space: nowrap;
}

.gp-stat strong {
  color: #00d4ff;
  font-variant-numeric: tabular-nums;
}

/* Body padding when header is active */
body.gp-has-header {
  padding-top: var(--gp-header-h) !important;
}

@media (max-width: 600px), (max-height: 500px) {
  :root { --gp-header-h: 48px; }
  #gp-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    box-sizing: border-box;
    height: 48px;
    padding: 0 6px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
  }
  .gp-header-top { display: contents; }
  .gp-game-name { display: none; }
  .gp-back { grid-column: 1; grid-row: 1; }
  .gp-header-actions { grid-column: 3; grid-row: 1; gap: 2px; }
  .gp-header-stats {
    grid-column: 2;
    grid-row: 1;
    height: auto;
    gap: 10px;
    padding: 0 4px;
    background: none;
    font-size: 12px;
    overflow: hidden;
  }
}

@media (max-width: 420px) {
  .gp-back { font-size: 0; min-width: 40px; justify-content: center; }
  .gp-back::before { content: '\2190'; font-size: 20px; }
}

/* Toast notifications */
.gp-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-family: 'Segoe UI', sans-serif;
  z-index: 10000;
  transition: transform 0.3s ease;
  max-width: min(400px, calc(100vw - 32px));
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.gp-toast.show {
  transform: translateX(-50%) translateY(0);
}

.gp-toast.gp-toast-success {
  border-color: #00d4ff;
}

.gp-toast.gp-toast-achievement {
  border-color: #ffd700;
  background: linear-gradient(135deg, #1a1a2e, #2a2a1e);
}

.gp-toast .gp-toast-icon {
  font-size: 24px;
  display: block;
  margin-bottom: 4px;
}

.gp-toast .gp-toast-title {
  font-weight: 700;
  color: #ffd700;
  font-size: 15px;
}

.gp-toast .gp-toast-desc {
  color: #aaa;
  font-size: 12px;
  margin-top: 2px;
}

/* Welcome banner on dashboard */
.gp-welcome {
  font-size: 24px;
  margin-bottom: 4px;
}

/* Game canvases prevent scroll; preview canvases in hub should allow scroll */
canvas#gameCanvas,
canvas#game-canvas,
canvas#boardCanvas {
  touch-action: none;
}

/* Preview canvases on the hub must allow scrolling */
.game-banner canvas {
  touch-action: auto;
  pointer-events: none;
}

/* Responsive */
@media (max-width: 500px) {
  .gp-header-stats { gap: 12px; font-size: 12px; }
  .gp-game-name { font-size: 14px; }
}

[data-theme="light"] #gp-header {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 14px rgba(31, 27, 69, 0.08);
}
[data-theme="light"] .gp-header-top,
[data-theme="light"] #gp-header { border-bottom-color: var(--gp-line); }
[data-theme="light"] .gp-back { color: var(--gp-ink-2); }
[data-theme="light"] .gp-back:hover { color: var(--gp-accent); }
[data-theme="light"] .gp-game-name { color: var(--gp-ink); }
[data-theme="light"] .gp-header-actions button:hover { background: rgba(31, 27, 69, 0.07); }
[data-theme="light"] .gp-header-stats { color: var(--gp-ink-2); background: rgba(31, 27, 69, 0.04); }
[data-theme="light"] .gp-stat strong { color: var(--gp-accent); }
[data-theme="light"] .gp-pause { background: rgba(250, 248, 255, 0.84); color: var(--gp-ink); }
[data-theme="light"] .gp-pause-resume { border-color: var(--gp-accent); background: rgba(124, 58, 237, 0.1); color: var(--gp-accent); }
[data-theme="light"] .gp-pause-resume:hover { background: rgba(124, 58, 237, 0.2); }
[data-theme="light"] .gp-pause-hint { color: var(--gp-ink-3); }
[data-theme="light"] .gp-toast { background: #ffffff; color: var(--gp-ink); border-color: var(--gp-line); box-shadow: 0 10px 30px rgba(31, 27, 69, 0.16); }
[data-theme="light"] .gp-toast.gp-toast-achievement { background: linear-gradient(135deg, #ffffff, #fff8e1); border-color: #f5c400; }
[data-theme="light"] .gp-toast .gp-toast-title { color: #a37800; }
[data-theme="light"] .gp-toast .gp-toast-desc { color: var(--gp-ink-2); }

@media (max-width: 420px) {
  .gp-header-actions button { min-width: 34px; padding: 0 3px; }
  .gp-header-stats { gap: 8px; }
}
