/* Spillsidene.no color scheme */
:root {
  --bg1: #07122a;
  --bg2: #0c1d3f;
  --panel: #171a2b;
  --panel-2: #1e2338;
  --text: #eaf1ff;
  --muted: #a7b2c9;
  --accent: #5ba8ff;
  --border: rgba(255, 255, 255, 0.1);
  --gap: 12px;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

* {
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 800px at 20% 0%, #1b2040 0%, #0d1122 60%, #070a16 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 12px 20px 12px; /* Reduced top padding */
}

/* Logo header */
.logo-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  padding: 4px 0; /* Reduced padding */
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.logo-header a {
  font-family: Arial, sans-serif;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.2rem;
  user-select: none;
}

.logo-header a:hover {
  opacity: 0.8;
}

/* Main game section */
.game-section {
  width: min(1100px, 96vw);
  min-height: calc(100vh - 80px); /* Account for header */
  display: flex;
  flex-direction: column;
  gap: 4px; /* Very small gap between elements */
  align-items: center;
}

/* Game title */
.game-title {
  margin: 0;
  padding: 0;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-align: center;
  font-size: clamp(16px, 4vw, 28px);
  background: linear-gradient(90deg, #c7d6ff, #fff, #c7d6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  flex-shrink: 0;
}

/* Controls above game */
.game-controls-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: min(75vw, 75vh); /* Same width as the game canvas */
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid #2b335b;
  box-shadow: var(--shadow);
  flex-shrink: 0; /* Don't shrink */
}

.control-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.control-group label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text);
  font-weight: 600;
}

.control-group select {
  background: #263158;
  color: #e5ecff;
  border: 1px solid #2f3a69;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  font-size: 0.9em;
  cursor: pointer;
}

.hud {
  display: flex;
  gap: 24px;
  color: var(--muted);
  font-weight: 600;
}

/* Canvas wrapper */
.canvas-wrap {
  position: relative;
  width: min(75vw, 75vh); /* 75% of viewport, whichever is smaller */
  height: min(75vw, 75vh);
  aspect-ratio: 1;
  background: linear-gradient(180deg, #121730, #0f1530);
  border-radius: var(--radius);
  padding: var(--gap);
  box-shadow: var(--shadow), inset 0 0 0 1px #2b335b;
  overflow: hidden;
  flex-shrink: 0; /* Don't shrink the game */
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #0e1729;
  border-radius: 12px;
}

/* Overlay */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  background: linear-gradient(180deg, #1c2240, #12172e);
  border: 1px solid #2b335b;
  border-radius: 20px;
  padding: 20px;
  color: #eaf2ff;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow);
}

.overlay-card h2 {
  margin: 0 0 10px 0;
}

.overlay-card button {
  margin-top: 10px;
  background: #1a3a6a;
  border: 1px solid #2a518f;
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

.overlay-card button:hover {
  background: #21457d;
}

/* Controls under game */
.game-controls-bottom {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  flex-shrink: 0; /* Don't shrink */
}

.control-button {
  appearance: none;
  border: none;
  cursor: pointer;
  background: #263158;
  color: #e5ecff;
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9em;
  letter-spacing: 0.2px;
  transition: transform 0.06s ease, filter 0.2s ease, background 0.2s ease;
  border: 1px solid #2f3a69;
  min-width: 100px;
}

.control-button:hover {
  filter: brightness(1.08);
}

.control-button:active {
  transform: translateY(1px) scale(0.995);
}

/* Leaderboard */
.leaderboard {
  width: min(92vw, 860px);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid #2b335b;
  box-shadow: var(--shadow);
  flex: 0 0 auto; /* Don't grow, fixed size */
  display: flex;
  flex-direction: column;
}

.leaderboard h3 {
  margin: 0 0 16px 0;
  font-size: clamp(16px, 2.5vw, 20px);
  color: var(--accent);
  text-align: center;
  flex-shrink: 0;
}

.top-scores-container {
  flex: 1;
  min-height: 0;
  border-radius: 12px;
}

.top-scores-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid #2b335b;
  background: #0e1430;
}

.top-scores-table thead th {
  position: sticky;
  top: 0;
  background: #162048;
  text-align: left;
  padding: 12px;
  font-size: 13px;
  color: #cdd6ff;
  font-weight: 600;
}

.top-scores-table tbody td {
  padding: 12px;
  border-top: 1px solid #222a54;
  color: #e6ebff;
  font-variant-numeric: tabular-nums;
}

.top-scores-table tbody tr:nth-child(odd) td {
  background: #0d132e;
}

.top-scores-table tbody tr:nth-child(1) td {
  color: #FFD700;
  font-weight: 700;
}

.top-scores-table tbody tr:nth-child(2) td {
  color: #C0C0C0;
  font-weight: 700;
}

.top-scores-table tbody tr:nth-child(3) td {
  color: #CD7F32;
  font-weight: 700;
}

.date {
  color: #a9b3d4;
  font-size: 12px;
}

/* Info text */
.info-text {
  width: min(92vw, 860px);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid #2b335b;
  box-shadow: var(--shadow);
  margin-top: 0;
  flex-shrink: 0;
  flex-grow: 0;
}

.info-text h3 {
  margin: 0 0 12px 0;
  font-size: clamp(16px, 2.5vw, 20px);
  color: var(--text);
}

.info-text p {
  margin: 0 0 12px 0;
  color: var(--muted);
  line-height: 1.6;
}

.info-text strong {
  color: var(--text);
  font-weight: 600;
}

/* Responsive design */
@media (max-width: 768px) {
  .canvas-wrap {
    width: min(80vw, 80vh); /* Slightly smaller on mobile */
    height: min(80vw, 80vh);
  }
  
  .game-controls-top {
    width: min(80vw, 80vh); /* Match canvas width on mobile */
    padding: 8px;
  }
  
  .control-group {
    gap: 8px;
  }
  
  .hud {
    gap: 12px;
    font-size: 0.9em;
  }
  
  .game-controls-bottom {
    gap: 8px;
  }
  
  .control-button {
    padding: 6px 12px;
    font-size: 0.8em;
    min-width: 80px;
  }
  
  .leaderboard {
    width: min(95vw, 100%);
    padding: 8px;
  }
  
  .info-text {
    width: min(95vw, 100%);
    padding: 8px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 32px 8px 8px 8px; /* Reduced mobile padding */
  }
  
  .logo-header {
    padding: 4px 0; /* Reduced mobile header padding */
  }
  
  .logo-header a {
    font-size: 1rem;
  }
  
  .canvas-wrap {
    width: min(85vw, 85vh); /* Larger on very small screens */
    height: min(85vw, 85vh);
  }
  
  .game-controls-top {
    width: min(85vw, 85vh); /* Match canvas width on very small screens */
  }
  
  .control-group {
    flex-direction: column;
    gap: 6px;
  }
  
  .hud {
    flex-direction: column;
    gap: 6px;
    text-align: center;
    font-size: 0.85em;
  }
  
  .game-controls-bottom {
    gap: 6px;
  }
  
  .control-button {
    padding: 6px 10px;
    font-size: 0.75em;
    min-width: 70px;
  }
  
  .leaderboard {
    padding: 6px;
  }
  
  .info-text {
    padding: 6px;
    font-size: 0.9em;
  }
}

/* Focus styles */
:focus {
  outline: 2px solid #6aa0ff;
  outline-offset: 2px;
}
