/* ============================================================
   VM-TIPS 2026 — World Cup Pixel Art Theme
   Inspired by classic 8-bit football games & World Cup aesthetics
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-dark: #0a3d0a;
  --green-field: #1a6b1a;
  --green-light: #2a9d2a;
  --gold: #ffd700;
  --gold-dark: #b8860b;
  --orange: #ff8c00;
  --orange-dark: #cc7000;
  --white: #f0f0f0;
  --black: #111;
  --red: #cc0000;
  --blue: #003d8b;
  --yellow: #ffcc00;
  --pixel-border: 4px solid var(--black);
  --pixel-border-thin: 2px solid var(--black);
  --font-pixel: 'Press Start 2P', 'Courier New', monospace;
  --font-body: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  font-family: var(--font-body);
  background: var(--green-dark);
  color: var(--white);
  min-height: 100vh;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
}

/* Pixel border utility */
.pixel-border {
  border: var(--pixel-border);
  box-shadow: 0 4px 0 rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.1);
}

/* --- Header --- */
.header {
  background: linear-gradient(180deg, var(--green-dark) 0%, var(--green-field) 100%);
  border-bottom: var(--pixel-border);
  box-shadow: 0 4px 0 rgba(0,0,0,0.4);
  position: relative;
}

.header-stripe {
  height: 6px;
  background: repeating-linear-gradient(
    90deg,
    var(--gold) 0px, var(--gold) 16px,
    var(--black) 16px, var(--black) 18px,
    var(--gold) 18px, var(--gold) 34px,
    var(--red) 34px, var(--red) 36px,
    var(--gold) 36px, var(--gold) 52px,
    var(--black) 52px, var(--black) 54px
  );
}

.header-stripe.bottom {
  margin-top: 0;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px 16px;
  text-align: center;
  position: relative;
}

.info-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-pixel);
  font-size: 18px;
  width: 36px;
  height: 36px;
  border: var(--pixel-border-thin);
  background: var(--green-field);
  color: var(--gold);
  cursor: pointer;
  transition: all 0.1s step-start;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.4);
  line-height: 1;
}

.info-btn:hover {
  background: var(--gold);
  color: var(--black);
  transform: translateY(-50%) scale(1.1);
}

/* Info modal content */
.info-modal-body {
  padding: 24px;
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--white);
  line-height: 2;
  text-shadow: 1px 1px 0 var(--black);
}

.info-modal-body ul {
  list-style: none;
  padding: 0;
}

.info-modal-body li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.info-modal-body li::before {
  content: '▸ ';
  color: var(--gold);
}

.info-modal-body li:last-child {
  border-bottom: none;
}

.trophy-container {
  font-size: 48px;
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.5));
  image-rendering: pixelated;
}

.title {
  font-family: var(--font-pixel);
  font-size: 24px;
  color: var(--gold);
  text-shadow:
    3px 3px 0 var(--black),
    -1px -1px 0 var(--black),
    1px -1px 0 var(--black),
    -1px 1px 0 var(--black);
  letter-spacing: 2px;
  line-height: 1.4;
}

.subtitle {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--white);
  margin-top: 8px;
  letter-spacing: 6px;
  text-shadow: 2px 2px 0 var(--black);
}

/* --- Loading / Penalty Game --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.penalty-game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#penalty-canvas {
  border: var(--pixel-border);
  background: var(--green-field);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
  image-rendering: pixelated;
  width: 400px;
  height: 300px;
  cursor: crosshair;
}

.penalty-ui {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.penalty-score {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--black);
  letter-spacing: 4px;
}

.penalty-hint {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--white);
  text-shadow: 1px 1px 0 var(--black);
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* --- Error --- */
.error {
  text-align: center;
  padding: 60px 16px;
}

.error.hidden { display: none; }

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

#error-text {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--red);
  text-shadow: 2px 2px 0 var(--black);
}

/* --- Main Content --- */
main.hidden { display: none; }

main {
  padding: 24px 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.max-score-info {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--gold);
  text-align: center;
  margin-bottom: 20px;
  text-shadow: 1px 1px 0 var(--black);
}

/* --- Scoreboard Table --- */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 32px;
  border: var(--pixel-border);
  background: var(--green-field);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-pixel);
  font-size: 9px;
  table-layout: auto;
}

.score-table th {
  background: linear-gradient(180deg, #0a4a0a, #062d06);
  color: var(--gold);
  padding: 12px 6px;
  text-align: center;
  border-bottom: 3px solid var(--black);
  white-space: nowrap;
  text-shadow: 1px 1px 0 var(--black);
}

.score-table th:first-child { text-align: left; padding-left: 12px; }

.score-table th.rank-col { width: 40px; }
.score-table th.avatar-col { width: 70px; }
.score-table th.name-col { text-align: left; }
.score-table th.q-col { width: 36px; }
.score-table th.q-col.th-final { color: var(--gold) !important; }
.score-table th.q-col.th-temp { color: var(--orange) !important; }
.score-table th.total-col { min-width: 50px; }

.score-table td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  vertical-align: middle;
  color: var(--white);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}

.score-table td:first-child { padding-left: 12px; }

.score-table tr:hover td {
  background: rgba(255, 255, 255, 0.05);
}

.score-table tr.top-three td.rank-cell {
  font-weight: bold;
}

/* Rank badges */
.rank-1 { color: var(--gold) !important; }
.rank-2 { color: #c0c0c0 !important; }
.rank-3 { color: #cd7f32 !important; }

/* Avatar in table */
.avatar-cell {
  padding: 4px !important;
}

.avatar-img {
  width: 40px;
  height: 40px;
  border: 2px solid var(--black);
  image-rendering: pixelated;
  display: inline-block;
  vertical-align: middle;
  cursor: pointer;
  transition: transform 0.1s step-start;
}

.avatar-img:hover {
  transform: scale(1.1);
}

/* Participant name link */
.participant-link {
  color: var(--white);
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.participant-link:hover {
  color: var(--gold);
}

/* Score cells */
.score-total {
  color: var(--gold) !important;
  font-weight: bold;
  font-size: 11px;
}

.score-cell {
  font-size: 8px;
}

.score-cell.highlight {
  color: var(--green-light);
}

.score-cell.correct {
  color: var(--green-light);
}

.score-cell.wrong {
  color: #666;
}

/* Final vs temp (preliminär) coloring for score cells */
.score-cell.cell-final {
  color: var(--gold) !important;
}

.score-cell.cell-final.highlight {
  color: var(--gold) !important;
  text-shadow: 0 0 4px rgba(255, 215, 0, 0.4);
}

.score-cell.cell-final.correct {
  color: var(--gold) !important;
}

.score-cell.cell-temp {
  color: var(--orange) !important;
}

.score-cell.cell-temp.highlight {
  color: var(--orange) !important;
  text-shadow: 0 0 4px rgba(255, 140, 0, 0.4);
}

.score-cell.cell-temp.correct {
  color: var(--orange) !important;
}

/* --- Participant Cards (mobile fallback) --- */
.participant-cards {
  display: none;
  gap: 12px;
  flex-direction: column;
}

@media (max-width: 768px) {
  .table-wrapper { display: none; }
  .participant-cards { display: flex; }
}

.p-card {
  background: var(--green-field);
  border: var(--pixel-border);
  padding: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.1s step-start;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.4);
}

.p-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 rgba(0,0,0,0.5);
}

.p-card .avatar-img {
  width: 48px;
  height: 48px;
}

.p-card-info {
  flex: 1;
}

.p-card-name {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--white);
  text-shadow: 1px 1px 0 var(--black);
}

.p-card-score {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--black);
}

.p-card-rank {
  font-family: var(--font-pixel);
  font-size: 16px;
  min-width: 32px;
  text-align: center;
}

/* --- Modal --- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
}

.modal-content {
  position: relative;
  background: var(--green-dark);
  border: var(--pixel-border);
  box-shadow: 6px 6px 0 rgba(0,0,0,0.6);
  max-width: 700px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 1001;
  animation: modalIn 0.15s step-start;
}

@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: var(--red);
  color: var(--white);
  border: var(--pixel-border-thin);
  padding: 4px 10px;
  cursor: pointer;
  font-family: var(--font-pixel);
  font-size: 12px;
  z-index: 1002;
  transition: background 0.1s step-start;
}

.modal-close:hover {
  background: #ff0000;
}

/* Modal body */
.modal-body {
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 3px solid var(--gold-dark);
}

.modal-header .avatar-img {
  width: 60px;
  height: 60px;
  border: 3px solid var(--black);
}

.modal-name {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--black);
}

.modal-total {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: var(--white);
  margin-top: 4px;
}

.modal-total span {
  color: var(--gold);
}

/* Question list in modal */
.modal-questions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-q {
  background: var(--green-field);
  border: 2px solid var(--black);
  padding: 10px 12px;
}

.modal-q-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.modal-q-number {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--gold);
}

.modal-q-points {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--white);
}

.modal-q-text {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--white);
  margin-bottom: 6px;
}

.modal-q-answer {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--yellow);
  line-height: 1.6;
  word-break: break-word;
}

.modal-q-answer.empty {
  color: #666;
  font-style: italic;
}

.modal-q-correct {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--green-light);
  margin-top: 4px;
}

.modal-q-points-earned {
  font-family: var(--font-pixel);
  font-size: 9px;
  margin-top: 4px;
}

.modal-q-points-earned.correct { color: var(--green-light); }
.modal-q-points-earned.wrong { color: var(--white); }

.modal-q-pending {
  color: #888;
  font-size: 7px;
  font-style: italic;
}

.modal-q-final {
  color: var(--gold);
  font-size: 7px;
  font-weight: bold;
}

.modal-q-temp {
  color: var(--orange);
  font-size: 7px;
  font-weight: bold;
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 24px 16px;
  border-top: var(--pixel-border);
  background: linear-gradient(0deg, var(--green-dark), var(--green-field));
  margin-top: 32px;
}

.footer-text {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--gold-dark);
  text-shadow: 1px 1px 0 var(--black);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .title { font-size: 16px; }
  .subtitle { font-size: 9px; letter-spacing: 3px; }
  .trophy-container { font-size: 32px; }
  .header-content { gap: 12px; padding: 16px 12px; }
  .score-table { font-size: 7px; }
  .score-table th, .score-table td { padding: 6px 3px; }
  .modal-content { width: 95%; }
  .modal-name { font-size: 11px; }
}

@media (max-width: 480px) {
  .title { font-size: 13px; }
  .subtitle { font-size: 8px; }
  .header-content { gap: 8px; padding: 12px 8px; }
  .trophy-container { font-size: 24px; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--green-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--green-light);
  border: 2px solid var(--black);
}
