﻿/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Spillsidene.no color scheme - matching 2048, Evig-match, Astroidejeger */
:root{
  --bg:#0f1220;
  --panel:#171a2b;
  --panel-2:#1e2338;
  --text:#e9ecf1;
  --muted:#aab3c8;
  --accent:#5da9ff;
  --win:#f7d35b;
  --gap:12px;
  --radius:18px;
  --tile-radius:14px;
  --shadow:0 10px 30px rgba(0,0,0,.35);
}

html, body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% 0%, #1b2040 0%, #0d1122 60%, #070a16 100%);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: min(1100px, 96vw);
  margin: 0 auto;
  padding: 56px 12px calc(5vh + 12px) 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 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: 8px 0;
  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;
}

/* Mobile adjustment for header */
@media (max-width: 480px) {
  body {
    padding: 44px 8px calc(5vh + 8px) 8px;
  }
  .logo-header {
    padding: 6px 0;
  }
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 30px;
}

.header h1 {
  margin: 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;
}

.subtitle {
  font-size: 1.2rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 8px;
}

/* Game wrapper */
.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex: 1;
}

/* Score counter in game frame */
#counter {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  z-index: 10;
}

/* Game frame */
#game-frame {
  position: relative;
  width: min(90vw, 800px);
  height: min(60vw, 600px);
  background: linear-gradient(180deg, #121730, #0f1530);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 0 1px #2b335b;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

/* Game panel - under the game */
.game-panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: var(--radius);
  border: 1px solid #2b335b;
  box-shadow: var(--shadow);
  padding: 20px;
  width: min(90vw, 800px);
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  gap: 20px;
}

.panel-section {
  text-align: center;
  flex: 1;
}

.panel-section h3 {
  margin: 0 0 8px 0;
  font-size: 1.1rem;
  color: var(--muted);
  font-weight: 500;
}

.score-value, .timer-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.timer-value {
  color: var(--accent);
}

/* Fullscreen button in panel */
.panel-section .fullscreen-btn {
  margin: 0;
  padding: 12px 20px;
  font-size: 1rem;
}

/* Prevent scrolling when interacting with game */
#game-frame:focus {
  outline: none;
}

/* Controls removed - using mouse clicks only */

/* Game over overlay */
.game-over {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 9, 18, 0.95);
  backdrop-filter: saturate(120%) blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  z-index: 100;
}

.game-over-content {
  background: linear-gradient(180deg, #1c2240, #12172e);
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 400px;
  width: 90%;
  border: 1px solid #2b335b;
}

.game-over-content h2 {
  margin: 6px 0 8px;
  color: var(--text);
  font-size: 2rem;
  font-weight: 700;
}

.final-score {
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 1.2rem;
}

.final-score span {
  font-weight: 700;
  color: var(--text);
}

.retry-btn {
  background: #263158;
  color: #e5ecff;
  border: 1px solid #2f3a69;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.2s ease;
  margin-top: 10px;
}

.retry-btn:hover {
  filter: brightness(1.08);
}

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

.fullscreen-btn:hover {
  filter: brightness(1.08);
}

.fullscreen-btn:active {
  transform: translateY(1px) scale(0.995);
}

/* Top 100 and info sections */
.top100, .game-info{
  width: min(92vw, 860px);
  background:linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius:var(--radius);
  padding:16px;
  border:1px solid #2b335b;
  box-shadow:var(--shadow);
  margin: 12px auto 0 auto;
  color: var(--text);
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  color: var(--text);
}

.table th, .table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.table th {
  background: rgba(30, 35, 56, 0.6);
  font-weight: 600;
  color: var(--accent);
  position: sticky;
  top: 0;
}

.table tr:hover {
  background: rgba(30, 35, 56, 0.3);
}

.table td:first-child {
  width: 40px;
  text-align: center;
  font-weight: 600;
  color: var(--accent);
}

.table td:nth-child(2) {
  text-align: center;
  font-weight: 500;
}

.table td:nth-child(3) {
  text-align: right;
  color: var(--muted);
  font-size: 0.9em;
}

/* Trophy celebration styles */
.trophy-celebration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(10px);
}

.trophy-celebration.hidden {
  display: none;
}

.celebration-content {
  text-align: center;
  background: linear-gradient(135deg, #f2b179, #f59563);
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 3px solid #f67c5f;
  position: relative;
  overflow: hidden;
  animation: celebrationPulse 0.6s ease-out;
}

@keyframes celebrationPulse {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.trophy-container {
  position: relative;
  margin-bottom: 20px;
}

.trophy {
  font-size: 120px;
  animation: trophyBounce 1s ease-in-out infinite alternate;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
}

@keyframes trophyBounce {
  0% { transform: translateY(0px) rotate(-5deg); }
  100% { transform: translateY(-10px) rotate(5deg); }
}

.trophy-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.4) 0%, transparent 70%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: trophyGlow 2s ease-in-out infinite alternate;
}

@keyframes trophyGlow {
  0% { opacity: 0.6; transform: translate(-50%, -50%) scale(0.8); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}

.celebration-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 10px 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  animation: titleSlideIn 0.8s ease-out 0.3s both;
}

@keyframes titleSlideIn {
  0% { transform: translateY(30px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.celebration-message {
  font-size: 1.3rem;
  color: #fff;
  margin: 0 0 15px 0;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  animation: messageSlideIn 0.8s ease-out 0.5s both;
}

@keyframes messageSlideIn {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.celebration-rank {
  font-size: 1.8rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  animation: rankSlideIn 0.8s ease-out 0.7s both;
}

@keyframes rankSlideIn {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.celebration-rank span {
  background: linear-gradient(45deg, #ffd700, #ffed4e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 2.2rem;
  font-weight: 800;
}

.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffd700;
  animation: confettiFall 3s linear forwards;
}

.confetti:nth-child(2n) { background: #ff6b6b; }
.confetti:nth-child(3n) { background: #4ecdc4; }
.confetti:nth-child(4n) { background: #45b7d1; }
.confetti:nth-child(5n) { background: #96ceb4; }
.confetti:nth-child(6n) { background: #feca57; }

@keyframes confettiFall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

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

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

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

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

.instructions em {
  color: var(--accent);
  font-style: italic;
}

/* Responsive design */
@media (max-width: 900px) {
  .container {
    padding: 15px;
  }
  
  .header h1 {
    font-size: 2.5rem;
  }
  
  .subtitle {
    font-size: 1rem;
  }
  
  #game-frame {
    width: min(90vw, 600px);
    height: min(60vw, 450px);
  }
  
  .game-panel {
    width: min(90vw, 600px);
    padding: 15px;
    gap: 15px;
  }
  
  .score-value, .timer-value {
    font-size: 1.5rem;
  }
}

@media (max-width: 600px) {
  .header h1 {
    font-size: 2rem;
  }
  
  #game-frame {
    height: 400px;
  }
  
  #controlls div {
    gap: 10px;
    margin-bottom: 20px;
  }
  
  #controlls button {
    width: 50px;
    height: 50px;
  }
  
  .instructions {
    padding: 12px;
  }
}

@media (max-width: 480px) {
  .page {
    gap: 6px;
  }
  
  .top10-section {
    width: min(95vw, 100%);
    padding: 12px;
  }
  
  .instructions {
    width: min(95vw, 100%);
    padding: 12px;
  }
}

/* Button focus styles for accessibility */
#controlls button:focus,
.retry-btn:focus,
.fullscreen-btn:focus {
  outline: 3px solid rgba(93, 169, 255, 0.5);
  outline-offset: 2px;
}

/* Smooth animations */
* {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Loading animation for better UX */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.game-wrapper {
  animation: fadeIn 0.6s ease-out;
}

.instructions {
  animation: fadeIn 0.8s ease-out;
}

