/* Skissa – borðspilaþema: litríkir reitir, spjöld, stundaglas. */
:root {
  --navy: #1f2041;
  --board: #123b52;
  --board-2: #0d2c3e;
  --yellow: #ffc93c;
  --blue: #2d7dd2;
  --orange: #ff7f11;
  --green: #3bb273;
  --red: #e84855;
  --purple: #7b5ea7;
  --card: #fffdf6;
  --muted: #6b6f86;
  --font-head: "Baloo 2", "Arial Rounded MT Bold", sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
  --shadow: 0 5px 0 var(--navy);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--navy);
  background-color: var(--board);
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.07) 2px, transparent 2px),
    radial-gradient(rgba(255, 255, 255, 0.05) 2px, transparent 2px);
  background-size: 28px 28px;
  background-position: 0 0, 14px 14px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--red); font-weight: 800; min-height: 1.2em; margin: 6px 0 0; }

/* ------------------------------------------------------------------
   Reitir (lógó) – eins og stafir á spilareitum
   ------------------------------------------------------------------ */
.tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  margin: 0 0.04em;
  border: 4px solid var(--navy);
  border-radius: 0.18em;
  color: #fff;
  box-shadow: 0 5px 0 var(--navy);
  -webkit-text-stroke: 2px var(--navy);
  paint-order: stroke fill;
}
/* Litlir stafareitir: orð, vísbendingar, fyrirsagnir, sæti */
.tiles { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 3px; font-family: var(--font-head); font-weight: 800; line-height: 1; vertical-align: middle; }
.lt {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.45em; height: 1.45em; border: 3px solid var(--navy); border-radius: 0.25em;
  box-shadow: 0 3px 0 var(--navy); color: #fff; -webkit-text-stroke: 1.5px var(--navy); paint-order: stroke fill;
  background: #fff;
}
.lt:nth-child(odd) { transform: rotate(-3deg); }
.lt:nth-child(even) { transform: rotate(3deg); }
.lt.blank { background: #f4efe0; box-shadow: inset 0 -4px 0 rgba(31, 32, 65, 0.12), 0 3px 0 var(--navy); }
.lt.shown { background: var(--yellow); color: var(--navy); -webkit-text-stroke: 0; }
.lt.green { background: var(--green); }
.tile-gap { width: 0.6em; }
.tile-dash { font-weight: 800; }
.tiles.xs { font-size: 0.82rem; gap: 2px; }
.tiles.xs .lt { border-width: 2px; box-shadow: 0 2px 0 var(--navy); -webkit-text-stroke: 1px var(--navy); }
.tiles.sm { font-size: clamp(0.85rem, 2.2vw, 1.15rem); }
.tiles.lg { font-size: clamp(1.4rem, 5vw, 2.1rem); gap: 5px; }
.tiles.lg .lt { border-width: 4px; box-shadow: 0 5px 0 var(--navy); -webkit-text-stroke: 2px var(--navy); }
.t1 { background: var(--red); transform: rotate(-6deg); }
.t2 { background: var(--yellow); transform: rotate(4deg); }
.t3 { background: var(--blue); transform: rotate(-3deg); }
.t4 { background: var(--green); transform: rotate(5deg); }
.t5 { background: var(--orange); transform: rotate(-4deg); }
.t6 { background: var(--purple); transform: rotate(3deg); }

.logo {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(2.6rem, 11vw, 4.4rem);
  margin: 10px 0 0;
  line-height: 1.2;
  text-align: center;
}
.tagline { color: #d6ecf5; font-weight: 800; text-align: center; margin: 10px 0 18px; }

/* ------------------------------------------------------------------
   Spjöld, takkar, reitir
   ------------------------------------------------------------------ */
.card {
  background: var(--card);
  border: 4px solid var(--navy);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.btn {
  border: 4px solid var(--navy);
  border-radius: 14px;
  background: #fff;
  color: var(--navy);
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--navy);
  transition: transform 0.06s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--navy); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-big { width: 100%; font-size: 1.35rem; padding: 12px; }
.btn-yellow { background: var(--yellow); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-small { font-size: 0.95rem; padding: 4px 12px; }

.input {
  width: 100%;
  border: 4px solid var(--navy);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 1.05rem;
  font-weight: 700;
  background: #fff;
  color: var(--navy);
  outline: none;
}
.input:focus { box-shadow: 0 0 0 4px rgba(255, 201, 60, 0.7); }
.label { display: block; font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; margin: 12px 0 6px; }

.back-link {
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  align-self: flex-start;
}
.back-link.small {
  font-size: 1.4rem;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  border-radius: 12px;
  flex: none;
}

/* ------------------------------------------------------------------
   Inngöngusíða
   ------------------------------------------------------------------ */
.screen-join {
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px 30px;
}
.join-card { padding: 6px 18px 18px; display: flex; flex-direction: column; }
.join-card #btn-resume { margin-top: 12px; }
.figure-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
  margin-bottom: 16px;
}
.figure-btn {
  aspect-ratio: 1;
  font-size: 1.6rem;
  border: 3px solid var(--navy);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  padding: 0;
}
.figure-btn.selected { background: var(--yellow); transform: scale(1.08) rotate(-4deg); box-shadow: 0 3px 0 var(--navy); }
.figure-btn.taken { opacity: 0.2; pointer-events: none; }

/* ------------------------------------------------------------------
   Leikskjár
   ------------------------------------------------------------------ */
.game {
  display: grid;
  height: 100vh;
  height: 100dvh;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "top top top"
    "scores stage chat";
}
.topbar { grid-area: top; }
.scores { grid-area: scores; }
.stage { grid-area: stage; }
.chat { grid-area: chat; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 4px solid var(--navy);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 6px 12px;
  min-height: 64px;
}
.mini-logo { font-family: var(--font-head); font-weight: 800; font-size: 1.3rem; flex: none; }
.mini-logo .tile { border-width: 3px; box-shadow: 0 3px 0 var(--navy); }
.word-area { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.category {
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--purple);
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  border: 3px solid var(--navy);
  border-radius: 8px;
  box-shadow: 0 3px 0 var(--navy);
  transform: rotate(-3deg);
}
.word-display {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.1rem, 3vw, 1.8rem);
  letter-spacing: 0.08em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.word-display { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; white-space: normal; letter-spacing: 0; overflow: visible; padding-bottom: 3px; }
.word-display .count { font-size: 0.8rem; color: var(--muted); }
.wd-label { font-size: 0.9rem; color: var(--muted); }
.word-display .known { color: var(--green); }
.word-display .to-draw { color: var(--red); }

.turn-info { display: flex; align-items: center; gap: 10px; flex: none; }
.turn-label { font-weight: 800; color: var(--muted); font-size: 0.9rem; }
.timer {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.35rem;
  background: var(--yellow);
  border: 4px solid var(--navy);
  border-radius: 14px;
  padding: 0 10px;
  min-width: 96px;
  justify-content: center;
  box-shadow: 0 4px 0 var(--navy);
  transform: rotate(2deg);
}
.hourglass { display: inline-block; animation: flip 4s ease-in-out infinite; }
@keyframes flip { 0%, 80% { transform: rotate(0); } 100% { transform: rotate(180deg); } }
.timer.urgent { background: var(--red); color: #fff; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }

/* Stigatafla */
.scores { padding: 10px; display: flex; flex-direction: column; min-height: 0; }
.panel-title { font-family: var(--font-head); font-weight: 800; font-size: 1.25rem; margin: 2px 0 12px; display: flex; justify-content: center; }
.scoreboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 0; flex: 1; }
.scoreboard li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 3px solid var(--navy);
  border-radius: 12px;
  background: #fff;
  font-weight: 800;
}
.scoreboard li { box-shadow: 0 3px 0 var(--navy); }
.scoreboard li.me { background: #fff4cc; }
.scoreboard li.drawer { background: #ffe1d0; }
.scoreboard li.guessed { background: #d8f5e3; }
.scoreboard li.offline { opacity: 0.45; }
.sb-rank { flex: none; font-family: var(--font-head); font-size: 0.85rem; }
.sb-rank.lt { width: 1.7em; height: 1.7em; }
.sb-fig { font-size: 1.3rem; }
.sb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-badge { font-size: 0.95rem; }
.sb-score { font-family: var(--font-head); font-size: 1.05rem; background: var(--yellow); border: 3px solid var(--navy); border-radius: 8px; padding: 0 7px; min-width: 2.2em; text-align: center; box-shadow: 0 2px 0 var(--navy); transform: rotate(2deg); }
.sb-delta { color: var(--green); font-size: 0.85rem; }
.sb-remove {
  border: 2px solid var(--navy);
  background: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 0.7rem;
  cursor: pointer;
  flex: none;
  padding: 0;
}
.rules { margin-top: 10px; font-size: 0.85rem; }
.rules summary { font-family: var(--font-head); font-weight: 800; cursor: pointer; }
.rules ul { padding-left: 18px; margin: 6px 0 0; }

/* Svið: strigi + verkfæri */
.stage { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#canvas {
  box-sizing: content-box;
  background: #fff;
  border: 5px solid var(--navy);
  border-radius: 14px;
  box-shadow: 0 7px 0 var(--navy);
  touch-action: none;
  display: block;
  user-select: none;
  -webkit-user-select: none;
}
#canvas.can-draw { cursor: crosshair; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(18, 59, 82, 0.55);
  border-radius: 14px;
  z-index: 5;
}
.overlay-card {
  background: var(--card);
  border: 4px solid var(--navy);
  border-radius: 20px;
  box-shadow: 0 7px 0 var(--navy);
  padding: 18px 20px;
  max-width: 460px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
}
.overlay-card h2 { font-family: var(--font-head); font-weight: 800; font-size: 1.7rem; margin: 0 0 6px; }
.overlay-card .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.big-word {
  display: inline-block;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 2.4rem;
  background: var(--yellow);
  border: 4px solid var(--navy);
  border-radius: 14px;
  padding: 0 18px;
  margin: 6px 0 10px;
  transform: rotate(-2deg);
  box-shadow: 0 5px 0 var(--navy);
}
.big-word:has(.tiles) { background: none; border: 0; box-shadow: none; transform: none; padding: 4px 0; }
.points-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; text-align: left; }
.points-list li { display: flex; gap: 8px; font-weight: 800; }
.points-list .pts { margin-left: auto; color: var(--green); }
.points-list .zero { color: var(--muted); }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 12px 0 4px; }
.podium .step {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  width: 92px; border: 4px solid var(--navy); border-radius: 12px 12px 0 0;
  font-weight: 800; padding: 6px 4px; color: var(--navy);
}
.podium .fig { font-size: 2rem; }
.podium .p1 { height: 140px; background: var(--yellow); }
.podium .p2 { height: 110px; background: #d9dde8; }
.podium .p3 { height: 90px; background: #f0b27a; }
.podium .nm { font-size: 0.85rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.drawer-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: var(--red);
  color: #fff;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.3rem;
  border: 4px solid var(--navy);
  border-radius: 14px;
  padding: 4px 16px;
  box-shadow: 0 5px 0 var(--navy);
  animation: pop-in 0.3s ease-out, fade-out 0.5s ease-in 3s forwards;
  white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 16px 12px;
}
.drawer-banner .tiles { font-size: 1.3rem; }
.banner-label { font-size: 1rem; }
@keyframes pop-in { from { transform: translateX(-50%) scale(0.6); } }
@keyframes fade-out { to { opacity: 0; visibility: hidden; } }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  background: var(--card);
  border: 4px solid var(--navy);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 6px 10px;
}
.colors, .sizes { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 3px solid var(--navy);
  cursor: pointer;
  padding: 0;
}
.swatch.active { transform: scale(1.18) rotate(-6deg); box-shadow: 0 3px 0 var(--navy); }
.size-btn, .tool-btn {
  width: 38px;
  height: 38px;
  border: 3px solid var(--navy);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.1rem;
}
.size-btn span { display: block; background: var(--navy); border-radius: 50%; }
.size-btn.active, .tool-btn.active { background: var(--yellow); transform: rotate(-5deg); }
.size-btn, .tool-btn { box-shadow: 0 3px 0 var(--navy); }
.overlay-card h2 { display: inline-block; background: var(--yellow); border: 4px solid var(--navy); border-radius: 12px; padding: 0 14px; box-shadow: 0 4px 0 var(--navy); transform: rotate(-2deg); margin-bottom: 12px !important; }
.podium .step { box-shadow: 0 4px 0 var(--navy); }
.podium .p1 { transform: rotate(-1deg); }
.podium .p3 { transform: rotate(1.5deg); }
.chat-list li { border: 2px solid transparent; }
.chat-list .correct { border-color: var(--green); }
.host-bar { display: flex; justify-content: center; }
.hint-btn {
  height: 38px; padding: 0 12px; border: 3px solid var(--navy); border-radius: 10px;
  background: var(--yellow); font-family: var(--font-head); font-weight: 800; font-size: 0.95rem;
  color: var(--navy); cursor: pointer; white-space: nowrap; box-shadow: 0 3px 0 var(--navy);
}
.hint-btn:disabled { background: #eee; color: var(--muted); box-shadow: none; cursor: default; }
.standings { list-style: none; padding: 0; margin: 8px auto; max-width: 320px; text-align: left; }
.standings li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 10px; border-radius: 8px; font-weight: 800; }
.standings li:first-child { background: #fff1c2; }
.vote-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.vote-btns .btn { min-width: 150px; }
.vote-btns .btn.chosen { outline: 4px solid var(--blue); outline-offset: 2px; }
.vote-btns .vc { display: inline-block; min-width: 1.6em; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 0.85em; }

/* Spjall */
.chat { padding: 10px; display: flex; flex-direction: column; min-height: 0; }
.chat-list { list-style: none; margin: 0; padding: 0 2px; flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.chat-list li { font-size: 0.95rem; line-height: 1.3; padding: 3px 8px; border-radius: 10px; word-wrap: break-word; }
.chat-list li:nth-child(odd) { background: #f3f1ea; }
.chat-list .who { font-weight: 800; }
.chat-list .system { background: transparent !important; color: var(--muted); font-style: italic; text-align: center; font-size: 0.85rem; }
.chat-list .correct { background: #d8f5e3 !important; color: #17663a; font-weight: 800; }
.chat-list .knower { background: #e8e3f5 !important; }
.chat-list .private { background: #fff1c2 !important; font-weight: 800; }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form .input { flex: 1; min-width: 0; padding: 8px 10px; }
.chat-form .btn { flex: none; }

/* ------------------------------------------------------------------
   Tilkynningar
   ------------------------------------------------------------------ */
.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: var(--red); color: #fff; font-weight: 800; text-align: center;
  padding: calc(4px + env(safe-area-inset-top)) 10px 4px;
}
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--yellow); color: var(--navy);
  border: 4px solid var(--navy); border-radius: 14px; box-shadow: var(--shadow);
  padding: 8px 16px; font-weight: 800; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 70; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------------------
   Sími / mjór skjár: strigi efst, stigatafla sem rönd, spjall neðst
   ------------------------------------------------------------------ */
@media (max-width: 999px) {
  .game {
    gap: 8px;
    padding: calc(6px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom));
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(150px, 1fr);
    grid-template-areas: "top" "scores" "stage" "chat";
  }
  .topbar { min-height: 52px; padding: 4px 8px; gap: 8px; }
  .mini-logo { display: none; }
  .turn-label { display: none; }
  .timer { font-size: 1.1rem; min-width: 76px; }
  .scores { padding: 6px; box-shadow: 0 3px 0 var(--navy); }
  .scores .panel-title, .rules { display: none; }
  .scoreboard { flex-direction: row; overflow-x: auto; overflow-y: hidden; gap: 5px; scrollbar-width: none; }
  .scoreboard::-webkit-scrollbar { display: none; }
  .scoreboard li { flex: none; padding: 2px 8px; font-size: 0.85rem; }
  .sb-rank { display: none; }
  .sb-score { font-size: 0.9rem; padding: 0 5px; }
  .tiles.sm { font-size: 0.85rem; gap: 2px; }
  .tiles.sm .lt { border-width: 2px; box-shadow: 0 2px 0 var(--navy); }
  .wd-label { display: none; }
  .sb-name { max-width: 70px; }
  .stage { gap: 6px; }
  .canvas-wrap { flex: none; height: min(60vw, 46vh); }
  .toolbar { padding: 4px 6px; gap: 6px; }
  .colors { gap: 4px; }
  .swatch { width: 23px; height: 23px; border-width: 2px; border-radius: 6px; }
  .size-btn, .tool-btn { width: 32px; height: 32px; }
  .chat { padding: 6px; }
  .chat .panel-title { display: none; }
  .hint-btn { height: 32px; padding: 0 8px; font-size: 0.85rem; }

  /* Teiknarinn fær stærri striga; spjallið minnkar í staðinn */
  .game.me-drawing { grid-template-rows: auto auto auto minmax(96px, 1fr); }
  .game.me-drawing .canvas-wrap { height: min(calc((100vw - 16px) * 0.75 + 8px), 62vh); }
  .game.me-drawing .stage { gap: 4px; }
  .game.me-drawing .chat-list li { font-size: 0.82rem; padding: 1px 6px; }
  .game.me-drawing .chat-form { margin-top: 4px; }
  .game.me-drawing .chat-form .input { padding: 5px 8px; }
}
