: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);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body{
  margin:0;
  padding: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;
  overflow-x:hidden;
  box-sizing:border-box;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 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;
}

.page{ 
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 56px 20px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.wrap{
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: 100%;
}

h1{
  margin:0;
  font-weight:800;
  letter-spacing:.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;
}

/* Game stats display */
.game-stats {
  display: flex;
  gap: 40px;
  justify-content: center;
  align-items: center;
  font-size: 0.9em;
  color: var(--text);
  width: 100%;
  max-width: 900px;
  margin: 2px 0;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stat-label {
  color: var(--muted);
  font-size: 0.8em;
}
.stat-value {
  font-weight: 700;
  font-size: 1.2em;
}

/* Game controls */
.game-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 2px 0;
}

.control-btn {
  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: 120px;
}

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

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

/* Game info and stats sections */
.game-info, .top100{
  width: 100%;
  max-width: 900px;
  background:linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius:var(--radius);
  padding:16px;
  border:1px solid #2b335b;
  box-shadow:var(--shadow);
  color: var(--text);
}

/* Top 10 specific styles */
.top100 {
  max-height: 350px;
  margin: 2px 0;
  display: flex;
  flex-direction: column;
}

.table-container {
  flex: 1;
  overflow: auto;
  border-radius: 12px;
  max-height: 250px;
  border: 1px solid #2b335b;
  background: #0e1430;
}

/* Table styling for Top 10 */
.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  border-radius:12px;
  border:1px solid #2b335b;
  background:#0e1430;
  overflow:hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.table thead th{
  position:sticky; 
  top:0; 
  background:linear-gradient(180deg, #1e2648, #162048);
  text-align:center; 
  padding:12px 8px; 
  font-size:14px; 
  color:#e9ecf1;
  font-weight:600;
  border-bottom:2px solid #2b335b;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.table tbody td{
  padding:12px 8px; 
  border-bottom:1px solid #1a2140; 
  color:#e9ecf1; 
  font-variant-numeric: tabular-nums;
  text-align:center;
  font-size:14px;
  transition: background-color 0.2s ease;
}

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

.table tbody tr:nth-child(even) td{ 
  background:#0a1026; 
}

.table tbody tr:hover td{ 
  background:#1a2140; 
}

.table tbody tr:last-child td{
  border-bottom: none;
}

/* Special styles for first place */
.table tbody tr:first-child td{
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #000;
  font-weight: bold;
  text-shadow: none;
}

.table tbody tr:first-child:hover td{
  background: linear-gradient(135deg, #ffed4e, #ffd700);
}

/* Gratulasjon overlay */
.celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.5s ease-out;
}

.celebration-overlay.show {
  display: flex;
}

.celebration-container {
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 2px solid #ffd700;
  animation: slideIn 0.6s ease-out;
  position: relative;
  overflow: hidden;
}

.celebration-container::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, #ffd700, #ffed4e, #ffd700, #ffed4e);
  border-radius: 22px;
  z-index: -1;
  animation: borderGlow 2s linear infinite;
}

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

.trophy {
  font-size: 120px;
  animation: trophyBounce 1s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8));
  position: relative;
  z-index: 2;
}

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

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

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

.confetti-piece:nth-child(1) {
  left: 10%;
  animation-delay: 0s;
  background: #ff6b6b;
}

.confetti-piece:nth-child(2) {
  left: 20%;
  animation-delay: 0.2s;
  background: #4ecdc4;
}

.confetti-piece:nth-child(3) {
  left: 30%;
  animation-delay: 0.4s;
  background: #45b7d1;
}

.confetti-piece:nth-child(4) {
  left: 40%;
  animation-delay: 0.6s;
  background: #96ceb4;
}

.confetti-piece:nth-child(5) {
  left: 60%;
  animation-delay: 0.8s;
  background: #feca57;
}

.confetti-piece:nth-child(6) {
  left: 70%;
  animation-delay: 1s;
  background: #ff9ff3;
}

.confetti-piece:nth-child(7) {
  left: 80%;
  animation-delay: 1.2s;
  background: #54a0ff;
}

.confetti-piece:nth-child(8) {
  left: 90%;
  animation-delay: 1.4s;
  background: #5f27cd;
}

.celebration-text {
  margin-bottom: 30px;
}

.congratulations {
  font-size: 3rem;
  font-weight: 900;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  margin: 0 0 20px 0;
  animation: textGlow 2s ease-in-out infinite alternate;
}

.achievement {
  font-size: 1.5rem;
  color: #e9ecf1;
  margin: 0 0 20px 0;
  font-weight: 600;
}

.score-display, .position-display {
  font-size: 1.2rem;
  color: #aab3c8;
  margin: 10px 0;
}

.score-display span, .position-display span {
  color: #ffd700;
  font-weight: bold;
  font-size: 1.4rem;
}

.celebration-btn {
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #000;
  border: none;
  padding: 15px 30px;
  font-size: 1.1rem;
  font-weight: bold;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
}

.celebration-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 215, 0, 0.6);
  background: linear-gradient(135deg, #ffed4e, #ffd700);
}

.celebration-btn:active {
  transform: translateY(0);
}

/* Animasjoner */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { 
    opacity: 0;
    transform: translateY(-50px) scale(0.8);
  }
  to { 
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.3; }
}

@keyframes borderGlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes textGlow {
  from { text-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
  to { text-shadow: 0 0 30px rgba(255, 215, 0, 1), 0 0 40px rgba(255, 215, 0, 0.8); }
}

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

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

.game-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 15px 20px;
  background: rgba(255,255,255,.06);
  border-radius: 15px;
  border: 1px solid rgba(255,255,255,.1);
}

.score-info {
  display: flex;
  gap: 20px;
  align-items: center;
}

.score-label, .lives-label, .status-label {
  font-weight: 500;
  font-size: 14px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-label span, .lives-label span, .status-label span {
  color: #ffffff;
  font-weight: 700;
  background: rgba(91,168,255,.2);
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(91,168,255,.3);
}

.game-status {
  display: flex;
  align-items: center;
}

.status-label {
  color: #ffd700;
}

/* Game board sizing: responsive */
.board-outer{ 
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.game-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.game-wrap canvas {
  max-width: 100%;
  width: 100%;
  height: auto;
  border: 2px solid #2b335b;
  border-radius: var(--radius);
  display: block;
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, #121730, #0f1530);
  transition: all 0.3s ease;
}

.game-wrap canvas:hover {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  transform: scale(1.01);
}

.title {
  font-size: 48px;
  font-weight: 900;
  margin: 20px 0 30px;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
  text-align: center;
  background: linear-gradient(90deg,#c7d6ff, #fff, #c7d6ff);
  -webkit-background-clip: text; 
  background-clip: text; 
  color: transparent;
}

.title span:nth-child(1) {
  color: hsl(30, 70%, 60%);
  text-shadow: 0 0 10px hsl(30, 70%, 60%);
  animation: glow 2.1s ease-in-out infinite alternate;
}

.title span:nth-child(2) {
  color: hsl(60, 70%, 60%);
  text-shadow: 0 0 10px hsl(60, 70%, 60%);
  animation: glow 2.2s ease-in-out infinite alternate;
}

.title span:nth-child(3) {
  color: hsl(90, 70%, 60%);
  text-shadow: 0 0 10px hsl(90, 70%, 60%);
  animation: glow 2.3s ease-in-out infinite alternate;
}

.title span:nth-child(4) {
  color: hsl(120, 70%, 60%);
  text-shadow: 0 0 10px hsl(120, 70%, 60%);
  animation: glow 2.4s ease-in-out infinite alternate;
}

.title span:nth-child(5) {
  color: hsl(150, 70%, 60%);
  text-shadow: 0 0 10px hsl(150, 70%, 60%);
  animation: glow 2.5s ease-in-out infinite alternate;
}

.title span:nth-child(6) {
  color: hsl(180, 70%, 60%);
  text-shadow: 0 0 10px hsl(180, 70%, 60%);
  animation: glow 2.6s ease-in-out infinite alternate;
}

.title span:nth-child(7) {
  color: hsl(210, 70%, 60%);
  text-shadow: 0 0 10px hsl(210, 70%, 60%);
  animation: glow 2.7s ease-in-out infinite alternate;
}

.title span:nth-child(8) {
  color: hsl(240, 70%, 60%);
  text-shadow: 0 0 10px hsl(240, 70%, 60%);
  animation: glow 2.8s ease-in-out infinite alternate;
}

.title span:nth-child(9) {
  color: hsl(270, 70%, 60%);
  text-shadow: 0 0 10px hsl(270, 70%, 60%);
  animation: glow 2.9s ease-in-out infinite alternate;
}

.title span:nth-child(10) {
  color: hsl(300, 70%, 60%);
  text-shadow: 0 0 10px hsl(300, 70%, 60%);
  animation: glow 3s ease-in-out infinite alternate;
}

.title span:nth-child(11) {
  color: hsl(330, 70%, 60%);
  text-shadow: 0 0 10px hsl(330, 70%, 60%);
  animation: glow 3.1s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    text-shadow: 0 0 10px currentColor;
  }
  to {
    text-shadow: 0 0 20px currentColor, 0 0 30px currentColor;
  }
}

.instructions, .game-description {
  margin: 20px 0;
  text-align: left;
}

.instructions p, .game-description p {
  margin: 12px 0;
  font-size: 16px;
  line-height: 1.6;
  color: #e0e0e0;
}

.instructions p strong, .game-description p strong {
  color: #00ff88;
  font-weight: 500;
}

code {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  color: #ecf0f1;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.game-stats {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin: 30px 0;
  padding: 20px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.3) 0%, rgba(26, 26, 46, 0.3) 100%);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(0, 255, 136, 0.2);
  transition: all 0.3s ease;
  min-width: 100px;
}

.stat-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 255, 136, 0.2);
  border-color: rgba(0, 255, 136, 0.4);
}

.stat-icon {
  font-size: 24px;
  margin-bottom: 5px;
}

.stat-label {
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  color: #b0b0b0;
  font-weight: 400;
  text-align: center;
}

.stat-value {
  font-family: 'Orbitron', monospace;
  font-size: 18px;
  font-weight: 700;
  color: #00ff88;
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: auto;
}

/* Responsive design */
@media (max-width: 768px) {
  .page {
    padding: 44px 12px 20px 12px;
  }
  .wrap {
    gap: 4px;
  }
  .title {
    font-size: 36px;
  }
  .game-stats {
    gap: 30px;
  }
  .control-btn {
    padding: 8px 16px;
    font-size: 0.85em;
    min-width: 100px;
  }
  .table-container {
    max-height: 200px;
  }
  .table thead th {
    padding: 10px 6px;
    font-size: 12px;
  }
  .table tbody td {
    padding: 10px 6px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .page {
    padding: 44px 8px 20px 8px;
  }
  .wrap {
    gap: 3px;
  }
  .title {
    font-size: 28px;
  }
  .logo-header {
    padding: 6px 0;
  }
  .logo-header a {
    font-size: 1rem;
  }
  .game-stats {
    flex-direction: row;
    gap: 20px;
  }
  .control-btn {
    padding: 6px 12px;
    font-size: 0.8em;
    min-width: 80px;
  }
  .table-container {
    max-height: 150px;
  }
  .table thead th {
    padding: 8px 4px;
    font-size: 11px;
  }
  .table tbody td {
    padding: 8px 4px;
    font-size: 11px;
  }
  .celebration-container {
    padding: 20px;
    margin: 20px;
  }
  .trophy {
    font-size: 80px;
  }
  .congratulations {
    font-size: 2rem;
  }
  .achievement {
    font-size: 1.2rem;
  }
}
