
:root{
  --bg1:#07122a;
  --bg2:#0c1d3f;
  --panel:#101b35;
  --card:#0f1a33;
  --text:#eaf1ff;
  --muted:#a7b2c9;
  --accent:#5ba8ff;
  --border:#ffffff;
  --gap: 1rem;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color: var(--text);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  min-height:100vh;
}

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

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(1.2) blur(6px);
  background: linear-gradient(160deg, rgba(7,18,42,.85), rgba(12,29,63,.85));
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.nav-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  font-family: Arial, sans-serif;
  font-size: clamp(1.1rem, 2.2vw, 1.6rem);
  font-weight: 800;
  letter-spacing: .3px;
  color: #fff;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.menu { display:flex; gap: 1rem; }
.menu a {
  padding: .5rem .8rem;
  border-radius: 10px;
  background: rgba(255,255,255,.06);
  color: #fff;
}
.menu a[aria-current="page"]{ outline: 2px solid rgba(255,255,255,.25); }

/* Layout */
.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 1rem;
}

.main-container {
  width: 90%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  box-sizing: border-box;
}

/* Desktop - bruk begrenset bredde */
@media (min-width: 1400px) {
  .main-container {
    width: 70%;
    max-width: 1400px;
  }
}

/* Ny layout med spill øverst (auto-høyde), deretter info og statistikk */
.games-section {
  background: transparent;
  border-radius: 20px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.info-section {
  margin-bottom: 1.5rem;
}

.stats-section {
  margin-bottom: 1.5rem;
}

/* Cards grid - responsive grid layout */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  height: 200px;
}

.card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 25px rgba(0,0,0,.2);
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  transition: all 0.3s ease;
}

.card img { 
  width: 100%; 
  height: 140px; 
  object-fit: cover; 
  display: block;
}

/* Clickable card elements */
.card-image-link {
  display: block !important;
  text-decoration: none !important;
  transition: opacity 0.2s ease;
  cursor: pointer;
}

.card-image-link:hover {
  opacity: 0.9;
}

.card-title-link {
  text-decoration: none !important;
  color: inherit;
  transition: color 0.2s ease;
  cursor: pointer;
}

.card-title-link:hover {
  color: var(--accent) !important;
}

.card-title-link h3 {
  margin: 0;
  cursor: pointer;
}

.card-body {
  padding: 1rem;
  display: flex; 
  flex-direction: column; 
  justify-content: center;
  flex: 1;
  text-align: center;
}

.card-body h3 {
  color: #374151;
  margin: 0;
  font-size: 1.1rem;
}

.tag {
  font-size: .75rem;
  opacity: .85;
  margin-right: .4rem;
}

.btn {
  background: #1b2a55;
  color: #fff;
  border: 0;
  padding: .55rem .9rem;
  border-radius: 10px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }

/* Sidebar */
.sidebar {
  background: var(--panel);
  border-radius: 16px;
  padding: 1rem;
  height: fit-content;
  border: 1px solid rgba(255,255,255,.06);
}

.sidebar h3 { margin-top:0; }

.table {
  width:100%;
  border-collapse: collapse;
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.table th, .table td {
  border: 1px solid var(--border);
  padding: .5rem .6rem;
  text-align: left;
}

.table th {
  background: rgba(255,255,255,.08);
}

/* Info table */
.info-table {
  margin-top: 1rem;
}

.info-table th,
.info-table td {
  border: none;
}

/* Game header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
}

.game-header h2 {
  margin: 0;
  flex: 1;
}

.fullscreen-btn {
  flex-shrink: 0;
}

/* Search + sections */
.toolbar {
  display:flex; gap: .75rem; align-items:center; margin-bottom: 1rem;
}

input[type="search"] {
  width: 320px; max-width: 100%;
  padding:.6rem .8rem; border-radius:10px;
  border:1px solid #d1d5db;
  background:#fff; 
  color: #374151;
}

input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 168, 255, 0.1);
}

input[type="search"]::placeholder {
  color: #9ca3af;
}

/* Game iframe wrapper */
.frame-wrap {
  width: 100%;
  max-width: 100%;
  background:#000;
  border-radius:16px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%; /* Take full height of parent */
}

.frame-wrap.auto-size {
  height: 100%;
  min-height: 400px;
}

.frame-wrap.fixed-ratio {
  height: 100%;
  aspect-ratio: var(--ar, 16/9);
}

iframe { 
  width:100%; 
  height:100%; 
  border:0; 
  display:block;
  max-width: 100%;
  max-height: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .frame-wrap.auto-size {
    min-height: 300px;
    height: calc(100vh - 150px);
  }
  
  .frame-wrap.direct-embed {
    height: calc(100vh - 150px);
  }
}

/* Direct embed styles */
.frame-wrap.direct-embed {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  height: auto;
  min-height: auto;
  overflow: visible;
}

.responsive-game-wrapper {
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  height: auto;
  min-height: auto;
}

.game-content {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  height: auto;
  min-height: auto;
}

/* Fullscreen styles */
.frame-wrap.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  border-radius: 0;
  max-height: none;
  min-height: auto;
}

.frame-wrap.fullscreen iframe {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
}

.frame-wrap.fullscreen.direct-embed {
  overflow: auto;
}

.frame-wrap.fullscreen .game-content {
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Fullscreen overlay */
.fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1001;
  display: none;
  justify-content: center;
  align-items: center;
}

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

.fullscreen-instructions {
  background: var(--card);
  padding: 2rem;
  border-radius: 16px;
  text-align: center;
  max-width: 400px;
  border: 1px solid rgba(255,255,255,.1);
}

.fullscreen-instructions h3 {
  margin-top: 0;
  color: var(--accent);
}

.fullscreen-instructions p {
  margin: 1rem 0;
  color: var(--text);
}

.fullscreen-instructions kbd {
  background: var(--panel);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.2);
  font-family: monospace;
  color: var(--accent);
}

.fullscreen-instructions .btn {
  margin-top: 1rem;
}

/* Game description */
.game-description {
  margin-top: 1.25rem;
  background: var(--panel);
  border-radius: 16px;
  padding: 1rem;
  border: 1px solid rgba(255,255,255,.06);
}

.game-description h3 {
  margin: 0 0 0.5rem 0;
  color: var(--accent);
  font-size: 1.1rem;
}

.game-description p {
  margin: 0;
  line-height: 1.6;
  color: var(--text);
}

/* Loading and error states */
.loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--accent);
  font-size: 1.1rem;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.06);
}

.loading-indicator::before {
  content: "⏳";
  margin-right: 0.5rem;
  animation: spin 1s linear infinite;
}

.error-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  text-align: center;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.06);
  padding: 1rem;
}

.error-message h3 {
  color: #ff6b6b;
  margin: 0 0 0.5rem 0;
}

.error-message p {
  color: var(--text);
  margin: 0;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Game with overlay styles */
.frame-wrap.game-with-overlay {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 400px;
  overflow: visible;
}

.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.9) 0%, rgba(15, 23, 42, 0.7) 50%, transparent 100%);
  backdrop-filter: blur(8px);
  padding: 1rem;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.game-overlay:hover {
  opacity: 1;
}

.overlay-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 100%;
  pointer-events: auto;
}

.overlay-logo {
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.2rem;
  transition: opacity 0.2s ease;
}

.overlay-logo:hover {
  opacity: 0.8;
}

.logo-text {
  color: var(--accent);
}

.overlay-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 1rem;
  transition: all 0.2s ease;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.nav-link:active {
  transform: translateY(0);
}

/* Hide overlay when game content is focused */
body:focus-within .game-overlay {
  opacity: 0.3;
}

body:focus-within .game-overlay:hover {
  opacity: 1;
}

/* Fullscreen overlay styles */
.frame-wrap.game-with-overlay.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  border-radius: 0;
}

.frame-wrap.game-with-overlay.fullscreen .game-overlay {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0.8) 50%, transparent 100%);
}

/* Fullscreen body styles */
body.fullscreen {
  overflow: hidden;
}

body.fullscreen .game-overlay {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0.8) 50%, transparent 100%);
}

/* Override game-specific styles for better fit */
.game-content .wrap {
  width: 100% !important;
  max-width: 100% !important;
  grid-template-columns: 1fr !important;
  gap: 1rem !important;
  margin: 0 !important;
  padding: 0.5rem !important;
}

.game-content .panel {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
}

.game-content .board {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
}

.game-content .grid {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
}

/* Footer */
.footer {
  margin-top: 2rem;
  opacity: .8;
  padding: 1rem;
}

/* Info og stats tabeller */
.info-table, .stats-table {
  margin: 0 auto;
  border-collapse: separate;
  border-spacing: 0;
  max-width: 100%;
  width: 100%;
  background: #1e3a8a;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.info-table td, .stats-table td {
  padding: 2.5rem;
  text-align: left;
  vertical-align: top;
  border-radius: 20px;
}

/* Responsive design */
@media (max-width: 1024px) {
  .main-container {
    width: 95%;
  }
  
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (max-width: 768px) {
  .main-container {
    width: 98%;
    padding: 0.5rem;
  }
  
  .games-section {
    padding: 1rem;
  }
  
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
  }
  
  .card {
    height: 180px;
  }
  
  .card img {
    height: 120px;
  }
  
  .card-body {
    padding: 0.75rem;
  }
  
  .card-body h3 {
    font-size: 1rem;
  }
  
  .info-table td, .stats-table td {
    padding: 2rem;
  }
  
  .info-table h3, .stats-table h3 {
    font-size: 1.1rem;
  }
  
  .info-table h4 {
    font-size: 0.9rem;
  }
}

/* Ekstra små skjermer */
@media (max-width: 480px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
  }
  
  .card {
    height: 160px;
  }
  
  .card img {
    height: 100px;
  }
  
  .card-body {
    padding: 0.5rem;
  }
  
  .card-body h3 {
    font-size: 0.9rem;
  }
}

.info-table h3, .stats-table h3 {
  margin: 0 0 1rem 0;
  color: #93c5fd;
  font-size: 1.2rem;
}

.info-table h4 {
  margin: 0 0 0.5rem 0;
  color: #fbbf24;
  font-size: 1rem;
}

.info-table p {
  margin: 0;
  line-height: 1.6;
  color: #e5e7eb;
}

/* Stats table styling */
.stats-table .table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #3b82f6;
  border-radius: 12px;
  overflow: hidden;
  background: #1e40af;
  margin: 1rem 0;
}

.stats-table .table th, .stats-table .table td {
  border: 1px solid #3b82f6;
  padding: 0.75rem 1rem;
  text-align: left;
}

.stats-table .table th {
  background: #1d4ed8;
  color: #e5e7eb;
  font-weight: 600;
}

.stats-table .table td {
  color: #e5e7eb;
  background: #1e40af;
}

.stats-table .muted {
  color: #9ca3af;
  font-size: 0.9rem;
  margin: 0.5rem 0 0 0;
}

/* Content table for om.html */
.content-table {
  margin: 2rem auto;
  border: 5px solid white;
  border-collapse: collapse;
  max-width: 800px;
  width: 100%;
}

.content-table td {
  padding: 2rem;
  text-align: left;
  vertical-align: top;
}
