@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Nunito:wght@400;600;700;900&display=swap');

:root {
  --red:        #e63946;
  --red-dark:   #c1121f;
  --yellow:     #ffd60a;
  --yellow-dark:#f4a100;
  --green-light:#52b788;
  --white:      #fffef7;
  --bg:         #1a1a2e;
  --card:       #16213e;
  --card2:      #0f3460;
  --text:       #fffef7;
  --muted:      #a8b2c1;
  --radius:     16px;
  --shadow:     0 8px 32px rgba(0,0,0,.45);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,.025) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,.025) 40px);
}

.screen { display: none; min-height: 100dvh; flex-direction: column; align-items: center; padding: 1.5rem 1rem; }
.screen.active { display: flex; }
.muted  { color: var(--muted); }
.small  { font-size: .85rem; }

/* ---- Loading ---- */
#loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(10,10,30,.93);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1rem;
}
#loading-overlay.hidden { display: none; }
.spinner {
  width: 48px; height: 48px;
  border: 5px solid rgba(255,214,10,.2);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#error-msg {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--red); color: #fff;
  padding: .75rem 1.5rem; border-radius: 99px;
  font-weight: 700; z-index: 999; box-shadow: var(--shadow);
  white-space: nowrap;
}
#error-msg.hidden { display: none; }

/* ============================================
   SPLASH
   ============================================ */
#screen-splash {
  padding: 0;
  position: relative;
  cursor: pointer;
  background: #000;
  justify-content: center;
}
.splash-inner {
  width: 100%; height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  position: relative;
}
.splash-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top;
  animation: splashIn .6s ease-out;
}
@keyframes splashIn {
  from { opacity: 0; transform: scale(1.05); }
  to   { opacity: 1; transform: scale(1); }
}
.splash-hint {
  position: relative; z-index: 2;
  margin-bottom: 2.5rem;
  font-family: 'Bangers', cursive;
  font-size: 1.3rem;
  letter-spacing: .1em;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,.8);
  animation: blink 1.5s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
#screen-splash.fade-out {
  animation: fadeOut .6s ease-out forwards;
}
@keyframes fadeOut { to { opacity: 0; transform: scale(.97); } }

/* ============================================
   START
   ============================================ */
#screen-start {
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(230,57,70,.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(255,214,10,.1) 0%, transparent 60%),
    var(--bg);
}
.logo-block { text-align: center; margin-bottom: 2.5rem; }
.logo-icon  { font-size: 4rem; display: block; animation: bounce 2s infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
.logo-title {
  font-family: 'Bangers', cursive;
  font-size: clamp(3rem, 10vw, 5rem);
  letter-spacing: .05em; line-height: 1;
  color: var(--yellow);
  text-shadow: 4px 4px 0 var(--red), 8px 8px 0 rgba(0,0,0,.3);
}
.logo-sub { color: var(--muted); font-size: .9rem; margin-top: .5rem; }

.panels {
  display: grid; grid-template-columns: 1fr;
  gap: 1.5rem; width: 100%; max-width: 480px;
}
@media (min-width: 700px) { .panels { grid-template-columns: 1fr 1fr; max-width: 860px; } }

.panel {
  background: var(--card); border-radius: var(--radius);
  padding: 1.75rem; border: 2px solid rgba(255,255,255,.07);
  box-shadow: var(--shadow);
}
.panel h2 {
  font-family: 'Bangers', cursive; font-size: 1.6rem;
  letter-spacing: .05em; margin-bottom: 1.2rem; color: var(--yellow);
}

.inp {
  width: 100%; background: rgba(255,255,255,.07);
  border: 2px solid rgba(255,255,255,.12); border-radius: 10px;
  color: var(--text); font-family: 'Nunito', sans-serif;
  font-size: 1rem; padding: .75rem 1rem; margin-bottom: .9rem;
  transition: border-color .2s;
}
.inp:focus { outline: none; border-color: var(--yellow); }
.inp.shake { animation: shake .4s; }
.code-inp  { text-transform: uppercase; font-family: 'Bangers', cursive; font-size: 1.6rem; letter-spacing: .2em; text-align: center; }

@keyframes shake {
  0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)}
  40%{transform:translateX(8px)} 60%{transform:translateX(-5px)} 80%{transform:translateX(5px)}
}

.btn {
  display: block; width: 100%;
  font-family: 'Bangers', cursive; font-size: 1.3rem;
  letter-spacing: .08em; padding: .8rem 1.2rem;
  border: none; border-radius: 10px; cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  box-shadow: 0 4px 0 var(--red-dark), 0 6px 20px rgba(230,57,70,.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--red-dark), 0 10px 28px rgba(230,57,70,.5); }
.btn-secondary {
  background: linear-gradient(135deg, var(--yellow), var(--yellow-dark));
  color: #1a1a2e;
  box-shadow: 0 4px 0 var(--yellow-dark), 0 6px 20px rgba(255,214,10,.3);
}
.btn-secondary:hover { transform: translateY(-2px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.big-btn { font-size: 1.5rem; padding: 1rem; }

/* ============================================
   LOBBY
   ============================================ */
#screen-lobby { gap: 1.2rem; justify-content: flex-start; }
.lobby-header { text-align: center; }
.lobby-header h1 { font-family: 'Bangers', cursive; font-size: 2rem; color: var(--yellow); letter-spacing: .05em; }
.code-badge {
  display: inline-flex; align-items: center; gap: .75rem;
  background: var(--red); padding: .7rem 1.5rem; border-radius: 99px;
  font-family: 'Bangers', cursive; font-size: 2.2rem; letter-spacing: .18em;
  box-shadow: 0 4px 0 var(--red-dark), var(--shadow); margin: .5rem 0;
}
.code-label { font-size: .75rem; opacity: .8; font-family: 'Nunito',sans-serif; letter-spacing: 0; }

.lobby-content {
  display: grid; grid-template-columns: 1fr;
  gap: 1.2rem; width: 100%; max-width: 560px;
}
@media (min-width: 500px) { .lobby-content { grid-template-columns: auto 1fr; } }

.qr-box {
  background: var(--card); border-radius: var(--radius);
  padding: 1rem; text-align: center; border: 2px solid rgba(255,255,255,.07);
}
.qr-box img { border-radius: 8px; background: #fff; padding: 4px; }
.qr-box p   { font-size: .78rem; color: var(--muted); margin-top: .4rem; }

.players-box {
  background: var(--card); border-radius: var(--radius);
  padding: 1.2rem; border: 2px solid rgba(255,255,255,.07);
}
.players-box h3 { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: .7rem; }
#player-count   { font-size: .82rem; color: var(--muted); margin-bottom: .5rem; }
#player-list    { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; }

.player-chip {
  display: flex; align-items: center; gap: .4rem;
  background: rgba(255,255,255,.07); border-radius: 99px;
  padding: .4rem .9rem; font-size: .88rem;
  border: 2px solid transparent;
}
.player-chip.me { border-color: var(--yellow); }
.player-chip.offline { opacity: .35; }
.player-avatar {
  width: 26px; height: 26px; background: var(--red);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-weight: 900; font-size: .78rem;
}
.player-chip.me .player-avatar { background: var(--yellow); color: #1a1a2e; }

.lobby-actions { width: 100%; max-width: 560px; text-align: center; }

/* ============================================
   SPIL
   ============================================ */
#screen-game { padding: 0; justify-content: flex-start; }
.game-top {
  background: var(--red); padding: .75rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10; width: 100%;
}
.round-info { font-family: 'Bangers', cursive; font-size: 1.2rem; letter-spacing: .05em; }
.timer-wrap {
  display: flex; align-items: center; gap: .4rem;
  background: rgba(0,0,0,.25); border-radius: 99px;
  padding: .3rem .9rem; font-family: 'Bangers', cursive; font-size: 1.4rem;
}
#timer-val { min-width: 28px; text-align: center; transition: color .3s; }
#timer-val.warning { color: var(--yellow); }
#timer-val.danger  { color: #ff6b6b; animation: pulse .5s infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.2)} }

.product-card {
  margin: 1rem; background: var(--card);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); border: 2px solid rgba(255,255,255,.07);
  width: calc(100% - 2rem);
}
.store-header {
  background: var(--card2); padding: .6rem 1rem;
  display: flex; align-items: center; gap: .7rem;
  font-size: .85rem; color: var(--muted);
}
#store-logo { height: 28px; object-fit: contain; border-radius: 4px; }
#product-store { font-weight: 700; color: var(--text); }

.product-img-wrap {
  height: 220px; background: #fff;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
#product-img { max-height: 100%; max-width: 100%; object-fit: contain; padding: 1rem; }

.product-info { padding: .8rem 1rem; }
#product-name { font-size: 1.15rem; font-weight: 900; line-height: 1.3; }

/* Prisskilt */
.price-sign {
  background: var(--yellow); color: #1a1a2e;
  border-radius: var(--radius); padding: 1.2rem 1rem;
  margin: 0 1rem 1rem; position: relative; text-align: center;
  border: 3px dashed rgba(0,0,0,.15);
  box-shadow: 0 4px 0 var(--yellow-dark);
  width: calc(100% - 2rem);
}
.price-sign::before {
  content: '?'; font-family: 'Bangers', cursive; font-size: 3.5rem;
  color: rgba(0,0,0,.1); position: absolute; right: 1rem;
  top: 50%; transform: translateY(-50%);
}
.price-sign h3 {
  font-family: 'Bangers', cursive; font-size: 1.1rem;
  letter-spacing: .08em; color: rgba(0,0,0,.55); margin-bottom: .6rem;
}
.guess-row { display: flex; gap: .6rem; align-items: stretch; }
.guess-inp {
  flex: 1; background: rgba(0,0,0,.1);
  border: 2px solid rgba(0,0,0,.15); border-radius: 10px;
  font-family: 'Bangers', cursive; font-size: 1.8rem;
  letter-spacing: .05em; color: #1a1a2e; padding: .4rem .8rem; text-align: center;
}
.guess-inp::placeholder { color: rgba(0,0,0,.3); font-size: 1.2rem; }
.guess-inp:focus { outline: none; border-color: var(--red); }
.kr-label {
  font-family: 'Bangers', cursive; font-size: 1.5rem;
  display: flex; align-items: center; color: rgba(0,0,0,.45); letter-spacing: .05em;
}
#btn-guess {
  padding: .7rem 1.2rem; font-size: 1.1rem; border-radius: 10px;
  background: var(--red); color: #fff;
  box-shadow: 0 4px 0 var(--red-dark);
  font-family: 'Bangers', cursive; letter-spacing: .08em;
  border: none; cursor: pointer; white-space: nowrap;
}
#btn-guess:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--red-dark); }
#guess-feedback { font-size: .82rem; color: var(--red); margin-top: .4rem; min-height: 1.2em; }

#waiting-msg {
  margin: 1rem; text-align: center; padding: 1.5rem;
  background: var(--card); border-radius: var(--radius);
  color: var(--muted); font-size: 1rem; line-height: 1.8;
  width: calc(100% - 2rem);
}
.waiting-icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; animation: spin 3s linear infinite; }

/* ============================================
   RESULTATER
   ============================================ */
#screen-results { justify-content: flex-start; gap: 1rem; }
.results-header { text-align: center; width: 100%; }
.results-header h2 {
  font-family: 'Bangers', cursive; font-size: 2rem;
  letter-spacing: .05em; color: var(--yellow);
}
.results-layout {
  display: grid; gap: 1rem; grid-template-columns: 1fr;
  max-width: 800px; width: 100%;
}
@media (min-width: 640px) { .results-layout { grid-template-columns: 1fr 240px; } }

.result-product-mini {
  background: var(--card); border-radius: var(--radius);
  padding: 1rem; display: flex; gap: 1rem; align-items: center;
  border: 2px solid rgba(255,255,255,.07); margin-bottom: .75rem;
}
#result-product-img {
  width: 70px; height: 70px; object-fit: contain;
  background: #fff; border-radius: 8px; padding: 4px; flex-shrink: 0;
}
.result-product-info h3 { font-weight: 900; font-size: 1rem; margin-bottom: .25rem; }
.correct-price-label { font-size: .78rem; color: var(--muted); }
.correct-price-val {
  font-family: 'Bangers', cursive; font-size: 1.8rem;
  color: var(--green-light); letter-spacing: .05em;
}

.result-table-wrap {
  background: var(--card); border-radius: var(--radius);
  overflow: hidden; border: 2px solid rgba(255,255,255,.07);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--card2); padding: .55rem .7rem;
  font-size: .72rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); text-align: left;
}
tbody tr { border-bottom: 1px solid rgba(255,255,255,.05); }
tbody tr:last-child { border-bottom: none; }
tbody tr.me { background: rgba(255,214,10,.06); }
tbody td { padding: .6rem .7rem; font-size: .88rem; }
tbody td.close { color: var(--green-light); font-weight: 700; }
tbody td.ok    { color: var(--yellow); }
tbody td.far   { color: var(--red); }
tbody td.pts   { font-family: 'Bangers', cursive; font-size: 1.1rem; color: var(--yellow); letter-spacing: .05em; }
.you-tag       { font-size: .75rem; color: var(--muted); }

#scoreboard {
  background: var(--card); border-radius: var(--radius);
  padding: 1rem; border: 2px solid rgba(255,255,255,.07); height: fit-content;
}
#scoreboard h3 {
  font-family: 'Bangers', cursive; font-size: 1.3rem;
  letter-spacing: .05em; color: var(--yellow); margin-bottom: .8rem;
}
#scoreboard ul  { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
#scoreboard li  {
  display: flex; align-items: center; gap: .5rem;
  font-size: .88rem; padding: .35rem .5rem; border-radius: 8px;
}
#scoreboard li.me { background: rgba(255,214,10,.1); }
.rank    { font-weight: 900; width: 20px; }
.sb-name { flex: 1; }
.sb-score {
  font-family: 'Bangers', cursive; font-size: 1.1rem;
  color: var(--yellow); letter-spacing: .05em;
}

.results-actions { width: 100%; max-width: 800px; text-align: center; padding-bottom: 1rem; }

/* ============================================
   FINALE
   ============================================ */
#screen-final {
  justify-content: center; text-align: center; gap: 1.5rem;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,214,10,.15) 0%, transparent 60%),
    var(--bg);
}
.final-title {
  font-family: 'Bangers', cursive;
  font-size: clamp(2.5rem, 8vw, 4rem);
  letter-spacing: .06em; color: var(--yellow);
  text-shadow: 3px 3px 0 var(--red-dark);
}
#final-podium {
  display: flex; flex-direction: column; gap: 1rem;
  width: 100%; max-width: 400px;
}
.podium-entry {
  background: var(--card); border-radius: var(--radius);
  padding: 1.2rem; display: flex; align-items: center; gap: 1rem;
  border: 2px solid rgba(255,255,255,.07);
}
.podium-entry.champion {
  background: linear-gradient(135deg, rgba(255,214,10,.15), rgba(255,214,10,.05));
  border-color: var(--yellow); transform: scale(1.03);
}
.podium-entry.winner-me { border-color: var(--green-light); }
.medal        { font-size: 2rem; }
.podium-name  { flex: 1; font-weight: 900; font-size: 1.1rem; text-align: left; }
.podium-score { font-family: 'Bangers', cursive; font-size: 1.5rem; color: var(--yellow); letter-spacing: .05em; }

/* Konfetti */
#confetti-container { position: fixed; inset: 0; pointer-events: none; z-index: 9998; overflow: hidden; }
.confetti-piece { position: absolute; top: -20px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }

@media (max-width: 400px) {
  .product-img-wrap { height: 170px; }
  .logo-title { font-size: 2.8rem; }
}

/* ============================================
   QR-JOIN SKÆRM
   ============================================ */
#screen-join {
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 10%, rgba(230,57,70,.18) 0%, transparent 55%),
    var(--bg);
}
.join-qr-wrap {
  display: flex; flex-direction: column;
  align-items: center; width: 100%; max-width: 420px;
  padding: 0 1rem;
}
.join-qr-panel {
  width: 100%; display: flex; flex-direction: column; gap: 1rem;
}
.join-qr-invited {
  text-align: center; padding: .5rem 0 .25rem;
}
.join-qr-icon {
  font-size: 3rem; display: block; margin-bottom: .5rem;
  animation: bounce 2s infinite;
}
.join-qr-invited p {
  font-size: 1.1rem; color: var(--muted); margin-bottom: .4rem;
}
.join-qr-code-display {
  display: inline-block;
  background: rgba(255,255,255,.07);
  border-radius: 8px; padding: .3rem 1rem;
  font-size: .9rem; color: var(--muted);
}
.join-qr-code-display strong {
  font-family: 'Bangers', cursive;
  font-size: 1.4rem; letter-spacing: .15em; color: var(--yellow);
  margin-left: .3rem;
}
.btn-ghost {
  background: none; border: none;
  color: var(--muted); font-size: .9rem;
  cursor: pointer; text-align: center;
  padding: .4rem; text-decoration: underline;
  font-family: 'Nunito', sans-serif;
  transition: color .2s;
}
.btn-ghost:hover { color: var(--text); }
