/* Róbó ratar! — stílar */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

button, .flis, .flis-haus, .ilat, .reitur, header, #stjornbord {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

:root {
  --blar: #4f8ff7;
  --fjolublar: #9b6bf2;
  --appelsinugulur: #ff9f43;
  --bleikur: #f368a8;
  --graenn: #2ecc71;
  --raudur: #ff6b6b;
  --dokk: #2d3550;
  --spjald-bg: #ffffff;
}

body {
  font-family: "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(160deg, #a8e0ff 0%, #cdb4f9 55%, #ffd6e8 100%);
  min-height: 100vh;
  color: var(--dokk);
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
}

h1 {
  font-size: 1.7rem;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(45,53,80,.35);
  letter-spacing: 1px;
}

#bordaval { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }

.bord-takki {
  width: 46px; height: 46px;
  border: none; border-radius: 12px;
  background: rgba(255,255,255,.85);
  font-family: inherit; font-weight: bold; font-size: .95rem;
  color: var(--dokk);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1;
  box-shadow: 0 3px 0 rgba(45,53,80,.25);
  transition: transform .1s;
}
.bord-takki:hover:not(:disabled) { transform: translateY(-2px); }
.bord-takki.valinn { background: var(--appelsinugulur); color: #fff; }
.bord-takki:disabled { opacity: .4; cursor: default; }
.bord-takki .stjornur { font-size: .55rem; color: #f5b301; margin-top: 2px; }
.bord-takki.valinn .stjornur { color: #fff; }

#hljod {
  border: none; background: rgba(255,255,255,.85);
  width: 46px; height: 46px; border-radius: 12px;
  font-size: 1.2rem; cursor: pointer;
  box-shadow: 0 3px 0 rgba(45,53,80,.25);
}

main {
  display: grid;
  grid-template-columns: minmax(320px, 440px) 1fr;
  gap: 18px;
  padding: 0 20px 30px;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}

/* ---------- talbóla ---------- */
#tal { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
#tal-robot {
  font-size: 2.2rem;
  background: #fff; border-radius: 50%;
  width: 58px; height: 58px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 0 rgba(45,53,80,.2);
}
#talbola {
  background: #fff;
  border-radius: 16px; border-top-left-radius: 4px;
  padding: 10px 14px;
  font-size: .95rem;
  box-shadow: 0 3px 0 rgba(45,53,80,.2);
  min-height: 58px;
  display: flex; align-items: center;
}
#talbola.villa { background: #ffe3e3; }
#talbola.gledi { background: #dcf7e7; }

/* ---------- spjöld ---------- */
.spjald {
  background: var(--spjald-bg);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 5px 0 rgba(45,53,80,.18);
}
.spjald h2 { font-size: 1.05rem; margin-bottom: 10px; }
#teljari { font-size: .8rem; color: #7a82a3; font-weight: normal; float: right; }
#teljari.fullt { color: var(--raudur); font-weight: bold; }

/* ---------- kubbaval ---------- */
#skipanaval { display: flex; flex-wrap: wrap; gap: 8px; }

.kubbur {
  border: none;
  border-radius: 12px;
  padding: 9px 13px;
  font-family: inherit; font-size: .92rem; font-weight: bold;
  color: #fff; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.22);
  transition: transform .08s;
}
.kubbur:active { transform: translateY(2px); box-shadow: none; }
.kubbur.afram   { background: var(--blar); }
.kubbur.vinstri, .kubbur.haegri { background: var(--fjolublar); }
.kubbur.endurtaka { background: var(--appelsinugulur); }
.kubbur.ef      { background: var(--bleikur); }

body.keyrandi #skipanaval, body.keyrandi #forrit { opacity: .55; pointer-events: none; }

/* ---------- forritið ---------- */
#forrit-ytra { max-height: 46vh; overflow-y: auto; }
#forrit { min-height: 60px; }

.ilat { border-radius: 10px; padding: 2px; }
.ilat.virkt-ilat {
  outline: 2px dashed var(--graenn);
  outline-offset: 2px;
  background: rgba(46,204,113,.06);
}

.tomt-skilabod {
  color: #9aa1c0; font-size: .9rem;
  padding: 14px 6px; text-align: center;
}

.flis {
  display: flex; align-items: center; gap: 8px;
  border-radius: 10px;
  padding: 7px 10px;
  margin: 5px 2px;
  color: #fff; font-weight: bold; font-size: .9rem;
  box-shadow: 0 2px 0 rgba(0,0,0,.2);
  cursor: pointer;
}
.flis-haus { cursor: pointer; }
.flis.afram   { background: var(--blar); }
.flis.vinstri, .flis.haegri { background: var(--fjolublar); }
.flis-haus.endurtaka { background: var(--appelsinugulur); }
.flis-haus.ef { background: var(--bleikur); }

.flis.virk, .flis-haus.virk {
  outline: 3px solid #ffe14d;
  transform: scale(1.03);
}

.eyda {
  margin-left: auto;
  border: none; background: rgba(255,255,255,.3);
  color: #fff; border-radius: 8px;
  width: 30px; height: 30px; line-height: 1;
  flex-shrink: 0;
  cursor: pointer; font-size: .85rem; font-family: inherit;
}
.eyda:hover { background: rgba(255,255,255,.55); }

/* blokkir (endurtaka / ef) */
.blokk { margin: 5px 2px; }
.flis-haus {
  display: flex; align-items: center; gap: 8px;
  border-radius: 10px 10px 0 0;
  padding: 7px 10px;
  color: #fff; font-weight: bold; font-size: .9rem;
}
.blokk-innihald {
  border-left: 5px solid;
  border-radius: 0 0 0 10px;
  margin-left: 6px;
  padding: 3px 3px 3px 8px;
  min-height: 34px;
}
.blokk.endurtaka .blokk-innihald { border-color: var(--appelsinugulur); background: rgba(255,159,67,.09); }
.blokk.ef .blokk-innihald { border-color: var(--bleikur); background: rgba(243,104,168,.09); }

.fjoldi-still { display: flex; align-items: center; gap: 5px; }
.fjoldi-still button {
  border: none; border-radius: 8px;
  width: 32px; height: 32px;
  font-size: 1.1rem;
  background: rgba(255,255,255,.35); color: #fff;
  font-weight: bold; cursor: pointer; font-family: inherit;
}
.fjoldi-still button:hover { background: rgba(255,255,255,.6); }
.fjoldi-tala { min-width: 26px; text-align: center; font-size: 1rem; }

.setja-her {
  color: var(--graenn); font-size: .75rem;
  padding: 3px 6px; opacity: .85;
}

/* ---------- stjórntakkar ---------- */
#stjornbord { display: flex; gap: 8px; margin-top: 12px; }
#stjornbord button {
  border: none; border-radius: 12px;
  padding: 10px 16px;
  font-family: inherit; font-size: 1rem; font-weight: bold;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.22);
  background: #e4e7f5; color: var(--dokk);
}
#stjornbord button:active { transform: translateY(2px); box-shadow: none; }
button.adal { background: var(--graenn) !important; color: #fff !important; }
#stodva { background: var(--raudur) !important; color: #fff !important; }
#kodi-takki { margin-left: auto; font-family: Consolas, Menlo, monospace; }
#kodi-takki.virkur { background: var(--dokk); color: #fff; }

/* ---------- kóðasýn ---------- */
#kodasyn {
  margin-top: 12px;
  background: #23273b;
  color: #dfe4ff;
  border-radius: 12px;
  padding: 12px 14px;
  font-family: Consolas, Menlo, monospace;
  font-size: .85rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}
.k-afram  { color: #7fb5ff; }
.k-snua   { color: #c9a6ff; }
.k-lykkja { color: #ffbe76; }
.k-ef     { color: #ff9ff3; }
.k-aths   { color: #8b91b5; font-style: italic; }

/* ---------- brettið ---------- */
#bord-heiti { font-weight: bold; font-size: 1.1rem; margin-bottom: 10px; text-align: center; }
#bretti-umgjord { display: flex; justify-content: center; }
#bretti {
  position: relative;
  display: grid;
  gap: 3px;
  background: #7dbb6b;
  padding: 8px;
  border-radius: 14px;
  box-shadow: inset 0 0 0 4px #5da04d;
}
.reitur {
  background: #b9e8a3;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
}
.reitur.dokkur { background: #a5dd8e; }
.reitur.veggur { background: #b0623c; box-shadow: inset 0 0 0 2px #8c4526; }
.reitur.mark { background: #ffe9a8; }
.reitur .tafn { line-height: 1; transition: opacity .35s, transform .35s; }
.reitur.mark .tafn { animation: tindra 1.2s ease-in-out infinite; }
.reitur.demantur { background: #cfeef7; }
.reitur.demantur .tafn { animation: tindra 1.6s ease-in-out infinite; }
.reitur.demantur.safnad { background: #b9e8a3; }
.reitur.demantur.safnad .tafn { opacity: 0; transform: scale(2.2); animation: none; }
@keyframes tindra {
  0%,100% { transform: scale(1) rotate(-6deg); }
  50%     { transform: scale(1.25) rotate(6deg); }
}

/* ---------- Róbó sjálfur ---------- */
#robot {
  position: absolute;
  z-index: 5;
  transition: left .28s ease, top .28s ease, transform .28s ease;
  pointer-events: none;
}
#robot .skrokkur {
  width: 100%; height: 100%;
  background: linear-gradient(180deg, #35c4c9, #1d9ba0);
  border-radius: 22%;
  position: relative;
  box-shadow: 0 3px 6px rgba(0,0,0,.3), inset 0 -4px 0 rgba(0,0,0,.15);
}
#robot .loftnet {
  position: absolute; top: -14%; left: 50%;
  width: 8%; height: 16%;
  background: #17777b;
  transform: translateX(-50%);
}
#robot .loftnet::after {
  content: ''; position: absolute;
  top: -70%; left: 50%; transform: translateX(-50%);
  width: 220%; padding-top: 220%;
  background: var(--raudur); border-radius: 50%;
}
#robot .augu {
  position: absolute; top: 18%; left: 0; right: 0;
  display: flex; justify-content: center; gap: 18%;
}
#robot .augu span {
  width: 20%; padding-top: 20%;
  background: #fff; border-radius: 50%;
  position: relative;
}
#robot .augu span::after {
  content: ''; position: absolute;
  top: 12%; left: 30%;
  width: 42%; height: 42%;
  background: var(--dokk); border-radius: 50%;
}
#robot .munnur {
  position: absolute; bottom: 20%; left: 50%;
  transform: translateX(-50%);
  width: 38%; height: 14%;
  border: 3px solid #fff; border-top: none;
  border-radius: 0 0 40px 40px;
}
#robot.skjalfa { animation: skjalfti .4s; }
@keyframes skjalfti {
  0%,100% { margin-left: 0; }
  20%,60% { margin-left: -6px; }
  40%,80% { margin-left: 6px; }
}

/* ---------- sigur ---------- */
#sigur {
  position: fixed; inset: 0;
  background: rgba(45,53,80,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
#sigur[hidden] { display: none; }
#sigur-kassi {
  background: #fff;
  border-radius: 22px;
  padding: 28px 36px;
  text-align: center;
  box-shadow: 0 8px 0 rgba(0,0,0,.25);
  animation: skoppa .45s cubic-bezier(.2,1.6,.4,1);
  position: relative; z-index: 2;
}
@keyframes skoppa { from { transform: scale(.4); opacity: 0; } }
#sigur-stjornur { font-size: 2.6rem; letter-spacing: 6px; margin-bottom: 6px; }
#sigur-stjornur .fengin { animation: stjarna-inn .5s backwards; }
#sigur-stjornur .fengin:nth-child(2) { animation-delay: .25s; }
#sigur-stjornur .fengin:nth-child(3) { animation-delay: .5s; }
#sigur-stjornur .grá { filter: grayscale(1); opacity: .35; }
@keyframes stjarna-inn { from { transform: scale(3) rotate(40deg); opacity: 0; } }
#sigur-titill { font-size: 1.6rem; margin-bottom: 4px; }
#sigur-texti { color: #666f94; margin-bottom: 18px; }
#sigur .takkar { display: flex; gap: 10px; justify-content: center; }
#sigur button {
  border: none; border-radius: 12px;
  padding: 11px 18px;
  font-family: inherit; font-size: 1rem; font-weight: bold;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.22);
  background: #e4e7f5; color: var(--dokk);
}

#skraut { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.skraut-bútur {
  position: absolute; top: -20px;
  width: 12px; height: 12px;
  animation: falla linear forwards;
}
@keyframes falla {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ---------- símar / spjaldtölvur ---------- */
@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  #haegri { order: -1; }
  #forrit-ytra { max-height: 34vh; }
}
