:root {
  --bg: #0f172a;
  --panel: #111c33;
  --panel2: #0b1324;
  --text: #e5e7eb;
  --muted: #a7b0c0;
  --border: rgba(255,255,255,0.10);
  --btn: #1f2a44;
  --btn2: #233155;
  --primary: #2563eb;
  --primary2: #1d4ed8;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);

  background: linear-gradient(
    120deg,
    #0f172a,
    #1e3a8a,
    #312e81,
    #7c3f1d,
    #0b1e3f,
    #0f172a
  );
  background-size: 700% 700%;
  animation: bgShift 45s ease-in-out infinite;
}

@keyframes bgShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.hint {
  width: 1200px;
  max-width: 100%;
  margin: 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.app {
  max-width: 1550px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------- TOPBAR ---------- */

.topbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(17,28,51,0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(6px);
}

.topbar-left h1 {
  margin: 0;
  font-size: 30px;
}

.topbar-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
}


.topbar,
#chatContainer {
  position: relative;
  z-index: 10;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.field span {
  font-size: 12px;
  color: var(--muted);
}

input, select {
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(11,19,36,0.85);
  color: var(--text);
  outline: none;
}

/* ---------- BUTTONS ---------- */

.btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--btn);
  color: var(--text);
  cursor: pointer;
}

.btn:hover { background: var(--btn2); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: rgba(255,255,255,0.14);
}

.btn-primary:hover {
  background: var(--primary2);
}

/* ---------- STATUS ---------- */

.status {
  width: 295px;
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(11,19,36,0.65);
  font-size: 13px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}




.topbar-controls input,
.topbar-controls select {
  width: 140px;
}


/* ---------- MAIN LAYOUT ---------- */

.main {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 306px;
  gap: 12px;
}

.board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.board {
  position: relative;
  width: 1200px;
  max-width: 100%;
  margin: 0 auto;
  background: rgba(11,19,36,0.65);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

canvas {
  display: block;
  width: 1200px;
  height: 580px;
}

/* ---------- HISTORY ---------- */

.history {
  top: 16px;
  height: calc(789px + 2px);
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(17,28,51,0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history-header {
  padding: 12px;
  font-size: 13px;
  color: var(--text);
  background: rgba(11,19,36,0.35);
}

.history-list {
  padding: 10px;
  overflow: auto;
  flex: 1;
}

.history-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px;
}

.history-item {
  border: 1px solid var(--border);
  background: rgba(11,19,36,0.55);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
}

.history-item:last-child { margin-bottom: 0; }

.h-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.h-winner { font-size: 13px; }

.h-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.h-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.h-players {
  font-size: 12px;
  color: var(--text);
  opacity: 0.95;
}

/* ---------- WINNER OVERLAY ---------- */

.winner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.winner-overlay[style*="display: flex"] {
  pointer-events: auto;
}

.winner-box {
  width: min(700px, 92%);
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(17,28,51,0.92);
  padding: 18px;
  text-align: center;
}

.winner-text {
  font-size: 34px;
  margin-bottom: 8px;
}

.winner-sub {
  font-size: 13px;
  color: var(--muted);
}

/* ---------- CHAT ---------- */

#chatContainer {
  width: 100%;
  height: 195px;
  margin: 10px auto 0;
  background: #071024;
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chatMessages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 0px 10px;
  font-size: 13px;
}

/* ---------- CHAT LINES ---------- */

.chat-line {
  margin-bottom: 10px;
  word-break: break-word;
  background: #0f1e3f;
  border-radius: 16px;
  padding: 4px 12px 6px 12px;
  width: fit-content;
  max-width: 90%;
  position: relative;
}

.chat-time {
  color: #757575;
  margin-right: 5px;
}

.chat-name {
  color: white;
  font-weight: 600;
  margin-right: 4px;
}

.chat-text {
  color: var(--text);
}

/* ---------- INPUT ---------- */

#chatInputRow {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--border);
  background: rgba(11,19,36,0.65);
}

#chatInput {
  flex: 1;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(11,19,36,0.85);
  color: var(--text);
  outline: none;
}

#chatSend {
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

#chatSend:hover {
  background: var(--primary2);
}

/* ---------- REACTIONS BAR ---------- */

.chat-reactions-bar {
  position: absolute;
  bottom: -10px;
  right: 10px;
  display: inline-flex;
  gap: 4px;
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
}

.chat-reactions-bar:empty {
  visibility: hidden;
}

.chat-reaction-count {
  background-color: #3b3b3b;
  border: 2px solid #071024;
  border-radius: 999px;
  padding: 1px 4px 2px 2px;
}

/* ---------- EMOJI PICKER ---------- */

.chat-reaction-picker {
  position: absolute;
  top: -14px;
  left: 110%;
  transform: translateX(-50%) translateY(-100%);
  display: flex;
  flex-wrap: wrap;
  width: 320px;
  gap: 6px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 6px 8px;
  font-size: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 10;
}

.chat-line:hover .chat-reaction-picker,
.chat-line:focus-within .chat-reaction-picker {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.chat-reaction-picker span {
  cursor: pointer;
  line-height: 1;
}

/* ---------- SCROLLBAR ---------- */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(11, 19, 36, 0.8);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    rgba(96, 165, 250, 0.35),
    rgba(59, 130, 246, 0.55)
  );
  border-radius: 10px;
  border: 2px solid rgba(11, 19, 36, 0.8);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    rgba(96, 165, 250, 0.55),
    rgba(59, 130, 246, 0.75)
  );
}

/* ---------- LOBBY OVERLAY ---------- */

.lobby-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(
    1200px 700px at 30% 0%,
    rgba(20, 32, 70, 0.95),
    rgb(5 10 20 / 75%)
  );
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 24px;
  height: 100vh;
}

.lobby-overlay[hidden] {
  display: none;
}

.lobby-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.lobby-column:first-child .lobby-panel {
  flex: 1;
  overflow: auto;
}

.lobby-column > .lobby-panel {
  flex: 1;
}

/* ---------- LAYOUT ---------- */

.lobby-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1.2fr 1.6fr 1fr;
  gap: 16px;
  height: 100%;
}

/* ---------- PANELS ---------- */

.lobby-panel {
  background: rgba(17,28,51,0.85);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.lobby-panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

/* Kun de to dropdowns under "Indstillinger" (labels med class="field" direkte i .lobby-panel) */
.lobby-panel:has(> label.field) {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;

  /* VIGTIGT: sørger for at felterne starter øverst under overskriften (ikke “midtstilles”) */
  align-content: flex-start;
  justify-content: flex-start;
}

/* Overskriften skal være på egen linje */
.lobby-panel:has(> label.field) > h2 {
  flex: 0 0 100%;
  margin: 0 0 8px; /* lidt mindre luft så felterne ligger tættere under */
}

/* 50/50 felter */
.lobby-panel:has(> label.field) > label.field {
  flex: 1 1 calc(50% - 7px);
  min-width: 0;
  margin: 0; /* undgå evt. default margin på label */
}

/* Select fylder hele feltet */
.lobby-panel:has(> label.field) > label.field select {
  width: 100%;
}

/* Mobil: under hinanden */
@media (max-width: 720px) {
  .lobby-panel:has(> label.field) > label.field {
    flex: 0 0 100%;
  }
}


/* ---------- LISTS ---------- */

.lobby-list {
  padding-left: 0px;
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  list-style: none;
}

.lobby-list li {
  margin-bottom: 6px;
}

/* ---------- ICON GRID ---------- */

.lobby-icons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.lobby-icon {
  background: rgba(11,19,36,0.8);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}

.lobby-icon img {
  width: 42px;
  height: 42px;
  margin-bottom: 6px;
}

.lobby-icon strong {
  display: block;
  font-size: 13px;
}

.lobby-icon span {
  font-size: 12px;
  color: var(--muted);
}

/* ---------- PLAYERS ---------- */

.lobby-players {
  list-style: none;
  padding: 0;
  margin: 0;
  border-radius: 12px;
}

.lobby-players li {
  padding: 8px 0;
  font-size: 14px;
}

/* ---------- PLAYER LIST (NAME LEFT, SCORE RIGHT) ---------- */

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.player-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.player-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 14px;
}

.player-ready {
  font-size: 12px;
  opacity: 0.9;
  color: var(--muted);
}

.player-score {
  flex: 0 0 auto;
  font-weight: 850;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: 3px 10px;
  border-radius: 999px;
  min-width: 46px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
}

/* Sidebar spacing */
#sidebarPlayers .history-item .player-row {
  padding: 2px 0;
}

#sidebarPlayers .history-item .player-score {
  background: rgba(37,99,235,0.10);
  border-color: rgba(37,99,235,0.18);
}

/* Lobby spacing */
#lobbyPlayers li .player-row {
  padding: 2px 0;
}

/* ---------- TOP PLAYER (GREEN TINT) ---------- */
.player-top {
  background: rgba(34, 197, 94, 0.10);
  border-color: rgba(34, 197, 94, 0.22);
  border-radius: 12px;
}

/* ---------- BUMP (VISUAL POP) ---------- */
.player-bump {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.10), 0 10px 24px rgba(0,0,0,0.25);
}


/* ---------- CLOSE BUTTON ---------- */

.lobby-close {
  align-self: center;
  margin-top: 16px;
  padding: 10px 26px;
}

/* ---------- SCORE PROGRESS BAR ---------- */

.progress-wrap {
  width: 1200px;
  max-width: 100%;
  height: 4px;
  background: rgb(7 16 36);
  overflow: hidden;
}

#scoreProgress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #facc1561, #ef4444);
  transition: width 0.25s ease;
}

#scoreProgress.near-end {
  background: linear-gradient(90deg, #ef4444, #40bb55);
}

@keyframes scorePulse {
  0%   { filter: brightness(1); }
  50%  { filter: brightness(1.4); }
  100% { filter: brightness(1); }
}

/* Indstillinger i lobby */
.powerup-box {
  position: relative;
}

.powerup-toggle {
  position: absolute;
  bottom: 10px;
  right: 10px;
}

.powerup-toggle input {
  display: none;
}

.powerup-toggle span {
  width: 38px;
  height: 20px;
  background: rgba(255,255,255,0.2);
  border-radius: 999px;
  display: inline-block;
  position: relative;
  cursor: pointer;
}

.powerup-toggle span::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.powerup-toggle input:checked + span {
  background: #22c55e;
}

.powerup-toggle input:checked + span::after {
  transform: translateX(18px);
}

/* Indstillinger i lobby stats */

.lobby-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-stat-line {
  font-size: 13px;
  color: var(--text);
  opacity: 0.95;
}

.lobby-stat-line:last-child {
  color: var(--muted);
  opacity: 1;
}


.lobby-settings .powerup-toggle {
  display: inline-flex;
  align-items: center;
}

/* ---------- LOBBY: Spillere online som Scoreboard ---------- */

#lobbyPlayers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#lobbyPlayers li {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(11,19,36,0.55);
}

/* Samme grønne highlight for top-spiller */
#lobbyPlayers li.player-top {
  background: rgba(34, 197, 94, 0.10);
  border-color: rgba(34, 197, 94, 0.22);
}


a.btn-mole {
    color: white;
    border: 1px solid #313131;
    border-radius: 10px;
    padding: 8px 16px;
    text-decoration: none;
    font-size: 14px;
    width: fit-content;
    margin-top: 20px;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  padding-right: 6px;
}

.toggle-password {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.7;
}

.toggle-password:hover {
  opacity: 1;
}

.input-with-icon{
  position: relative;
  display: flex;
  align-items: center;
}

.icon-btn{
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 6px;
  z-index: 5;
}

.icon-btn:focus{
  outline: none;
}

