@font-face{font-family:Yuanmo;src:url('fonts/yuanmo.ttf') format('truetype');font-display:swap}
@font-face{font-family:Yuanmo;src:url('fonts/eth.ttf') format('truetype');font-display:swap;unicode-range:U+00F0}
:root {
  --ink: #2a2633;
  --muted: #6a6475;
  --paper: #fffbf0;
  --line: #ded5c3;
  --sea: #3f7f9c;
  --accent: #f7d44c;
  --green: #397743;
  --red: #b93e32;
  --shadow: 4px 5px 0 #2a2633;
  --hand: Yuanmo, "Comic Sans MS", "Chalkboard SE", cursive;
  --pink: #f6a5c9; --blue: #8ccaf2; --leaf: #8fd18b; --coral: #f07a63; --purple: #b9a3e8;
  --radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--sea);
  color: var(--ink);
  font: 15px/1.4 ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; display: block; }
#map.dragging { cursor: grabbing; }

.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); }
.hud { position: fixed; z-index: 2; pointer-events: none; }
.hud > * { pointer-events: auto; }

.top-left {
  top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
  display: grid; gap: 10px; width: min(340px, calc(100vw - 24px));
}
.brand { padding: 10px 14px; }
.brand h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; line-height: 1.1; }
.brand h1::after { content: ' ●'; color: var(--accent); font-size: 14px; vertical-align: middle; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.forecast { padding: 12px 14px; border: 2px solid #f1b8b9; }
.fc-head { display: flex; gap: 10px; align-items: center; }
.fc-icon { font-size: 28px; line-height: 1; }
.fc-head strong { display: block; font-size: 16px; }
.fc-when { color: var(--red); font-weight: 600; font-size: 13px; }
.forecast p { margin: 8px 0; font-size: 13.5px; }
.switch { display: flex; gap: 8px; align-items: center; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--red); }
.fc-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 0 !important; font-weight: 600; }
.fc-stats .lost { color: var(--red); }
.fc-stats .saved { color: var(--green); }

.top-right { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; }
.chip {
  border: 0; background: var(--paper); border-radius: 999px; padding: 9px 14px; box-shadow: var(--shadow);
  font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
}
.chip.round { width: 40px; height: 40px; padding: 0; justify-content: center; }
.chip:hover { background: #fff; }
.badge { background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; }

.ticker { position: fixed; z-index: 2; right: 12px; top: 64px; display: grid; gap: 6px; justify-items: end; pointer-events: none; }
.tick {
  background: rgba(251, 248, 241, .92); border-radius: 999px; padding: 5px 12px; font-size: 13px; box-shadow: var(--shadow);
  pointer-events: auto; animation: slide-in .25s ease-out; transition: opacity 1s;
}
.tick.fade { opacity: 0; }

.bottom { left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; width: max-content; max-width: calc(100vw - 16px); }
.tools { display: flex; gap: 4px; background: var(--paper); padding: 6px; border-radius: 20px; box-shadow: var(--shadow); }
.tool {
  border: 0; background: transparent; border-radius: 14px; padding: 6px 10px 5px; min-width: 60px;
  display: grid; justify-items: center; gap: 1px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.tool .ico { font-size: 22px; line-height: 28px; height: 28px; }
#flis-ico { width: 22px; height: 22px; margin: 3px 0; border-radius: 5px; border: 2px solid rgba(0, 0, 0, .2); }
.tool:hover { background: rgba(31, 42, 46, .06); }
.tool.on { background: var(--ink); color: #fff; }
.palette { display: grid; grid-template-columns: repeat(8, 28px); gap: 6px; background: var(--paper); padding: 8px; border-radius: 16px; box-shadow: var(--shadow); order: -1; }
.swatch { width: 28px; height: 28px; border-radius: 8px; border: 2px solid rgba(0, 0, 0, .15); padding: 0; }
.swatch.on { outline: 3px solid var(--ink); outline-offset: 1px; }
.cooldown { background: rgba(31, 42, 46, .86); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; order: -2; }
.cooldown.ready { background: var(--green); }

.tile-panel {
  position: fixed; z-index: 3; left: max(12px, env(safe-area-inset-left)); bottom: calc(var(--bar-h, 90px) + max(24px, env(safe-area-inset-bottom)));
  width: min(340px, calc(100vw - 24px)); padding: 14px 16px; animation: slide-in .2s ease-out;
}
.tile-panel h2 { margin: 0 28px 6px 0; font-size: 16px; }
.tile-info { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.tile-info li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tile-info q { font-weight: 700; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .2); }
.muted { color: var(--muted); }
.warn { color: var(--red); }
#sign-text { width: 100%; margin-bottom: 8px; }
.tile-extra { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
.reason { color: var(--red); font-size: 13px; margin: 6px 0 0; min-height: 0; }
.reason:empty { display: none; }

input { border: 1.5px solid var(--line); border-radius: 12px; padding: 9px 12px; background: #fff; min-width: 0; }
input:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.primary { border: 0; background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 16px; font-weight: 700; }
.primary:disabled { background: #b9c0c3; cursor: not-allowed; }
.primary:not(:disabled):hover { background: #33454b; }
.wide { width: 100%; }
.link { border: 0; background: none; padding: 0; color: var(--sea); font-weight: 600; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.link.danger { color: var(--red); }
.close { position: absolute; top: 8px; right: 8px; border: 0; background: none; font-size: 22px; line-height: 1; padding: 6px 10px; color: var(--muted); }
.coord { border: 0; background: #e6f0f4; color: var(--sea); border-radius: 6px; padding: 0 5px; font-weight: 700; font-size: .95em; }

.drawer {
  position: fixed; z-index: 4; top: 64px; right: max(12px, env(safe-area-inset-right)); bottom: calc(var(--bar-h, 90px) + max(24px, env(safe-area-inset-bottom)));
  width: min(360px, calc(100vw - 24px)); display: flex; flex-direction: column; animation: slide-in .2s ease-out;
}
.drawer-head { position: relative; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-head .close { top: 4px; }
.messages, .annals { list-style: none; margin: 0; padding: 10px 14px; overflow-y: auto; flex: 1; display: grid; align-content: start; gap: 8px; }
.messages li { overflow-wrap: anywhere; }
.messages time { color: var(--muted); font-size: 11px; margin-left: 6px; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; }
.annals li h3 { margin: 6px 0 2px; font-size: 15px; }
.annals li p { margin: 0; color: var(--muted); font-size: 13.5px; }
.annals li p.event { color: var(--ink); font-weight: 600; margin-top: 4px; }

.timeline { padding: 10px 14px; width: min(720px, calc(100vw - 24px)); justify-items: stretch; }
.tl-row { display: flex; align-items: center; gap: 10px; }
.tl-row.small { font-size: 13px; color: var(--muted); display: grid; }
#tl-range { flex: 1; accent-color: var(--ink); padding: 0; border: 0; }
.tl-marks { position: relative; height: 16px; margin: 0 52px 0 50px; }
.mark { position: absolute; transform: translateX(-50%); font-size: 13px; }
.timeline .chip { box-shadow: none; background: #ece7db; }

dialog { border: 0; border-radius: 20px; padding: 0; max-width: min(460px, calc(100vw - 24px)); box-shadow: var(--shadow); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(16, 32, 40, .35); backdrop-filter: blur(2px); }
dialog form { padding: 22px; display: grid; gap: 10px; }
dialog h2 { margin: 0; font-size: 22px; }
dialog p { margin: 0; }
dialog label { display: grid; gap: 6px; font-weight: 700; margin-top: 6px; }
.rules { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 14px; }
.row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.row button:not(.primary) { border: 0; background: none; color: var(--muted); font-weight: 600; }

.toast {
  position: fixed; z-index: 10; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 14px; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px); font-weight: 600; animation: drop .25s ease-out;
}
.toast.error { background: var(--red); }
.toast.event { background: #7a2e1f; font-size: 16px; padding: 14px 20px; }

@keyframes slide-in { from { transform: translateY(8px); opacity: 0; } }
@keyframes drop { from { transform: translate(-50%, -10px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 700px) {
  .top-left { width: calc(100vw - 24px); gap: 8px; }
  .brand { padding: 8px 12px; margin-right: 144px; }
  .brand h1 { font-size: 20px; }
  .brand p { font-size: 12px; }
  .forecast { padding: 10px 12px; }
  .forecast p#fc-text { display: none; }
  .top-right { gap: 6px; }
  .top-right .chip:not(.round) { width: 40px; height: 40px; padding: 0; justify-content: center; position: relative; font-size: 17px; }
  .top-right .lbl { display: none; }
  .top-right .badge { position: absolute; top: -4px; right: -4px; font-size: 11px; }
  .ticker { display: none; }
  .tools { gap: 0; padding: 4px; }
  .tool { min-width: 0; width: calc((100vw - 32px) / 6); padding: 5px 2px; font-size: 11px; }
  .palette { grid-template-columns: repeat(8, 1fr); width: calc(100vw - 24px); }
  .swatch { width: 100%; height: 30px; }
  .tile-panel { left: 12px; right: 12px; width: auto; }
  .drawer { top: 60px; left: 12px; right: 12px; width: auto; bottom: 12px; z-index: 6; }
  .timeline { bottom: 12px; }
}

/* Same paper, ink and playful lettering as líf.is, iss! and quis?. */
:focus-visible{outline:3px dashed var(--ink);outline-offset:4px}
.card,dialog{border:2.5px solid var(--ink);border-radius:24px 14px 27px 15px}
.brand.card{background:transparent;border:0;box-shadow:none;padding:4px 8px 8px;transform:rotate(-3deg)}
.brand h1{font-family:var(--hand);font-size:55px;font-weight:400;letter-spacing:-1px;line-height:.95}
.brand h1::after{content:none}.brand h1 span{display:inline-block;color:#bb4b36;transform:rotate(14deg);margin-left:3px}
.brand p{font-family:var(--hand);font-size:16px;color:var(--ink);margin-top:6px}
.forecast{background:#fff3c4;border-color:var(--ink);border-radius:20px 13px 24px 12px;box-shadow:4px 5px 0 #f7d44c;transform:rotate(-.5deg)}
.fc-head strong,.tile-panel h2,.drawer-head h2,dialog h2,.annals h3{font-family:var(--hand);font-weight:400;font-size:23px;line-height:1.15}
.fc-head strong{font-size:24px}.fc-icon{font-size:32px}
.chip{border:2px solid var(--ink);border-radius:14px 9px 17px 10px;box-shadow:2px 3px 0 var(--ink);font-family:var(--hand);font-size:18px;font-weight:400;transition:transform .15s}
#open-chat{background:var(--pink);transform:rotate(-2deg)}#open-history{background:var(--blue);transform:rotate(2deg)}#open-help{background:var(--accent);transform:rotate(-3deg)}
.chip:hover{filter:brightness(1.04);transform:translateY(-2px)!important}
.tick{background:var(--paper);border:1.5px solid var(--ink);box-shadow:2px 2px 0 #2a263333;border-radius:10px 6px 12px 7px}
.tools{border:2.5px solid var(--ink);border-radius:22px 13px 25px 14px;padding:8px;gap:7px;box-shadow:4px 5px 0 var(--ink)}
.tool{--tool:#f7d44c;border:2px solid var(--ink);background:var(--tool);color:var(--ink);border-radius:13px 9px 15px 10px;font-family:var(--hand);font-weight:400;font-size:15px;box-shadow:2px 2px 0 var(--ink);min-width:66px;transition:transform .15s,box-shadow .15s;line-height:1.1;padding:7px 9px}
.tool[data-kind=tre]{--tool:#8fd18b}.tool[data-kind=hus]{--tool:#f6a5c9}.tool[data-kind=veggur]{--tool:#b9a3e8}.tool[data-kind=skilti]{--tool:#8ccaf2}.tool[data-kind=brjota]{--tool:#f07a63}
.tool:nth-child(2n){border-radius:9px 15px 10px 13px}
.tool:hover{background:var(--tool);transform:translateY(-3px)}
.tool.on{background:var(--tool);color:var(--ink);box-shadow:inset 0 0 0 2px var(--ink),2px 2px 0 var(--ink);transform:translateY(-5px) rotate(-3deg)}
.palette{border:2px solid var(--ink);border-radius:16px 10px 19px 12px;box-shadow:3px 4px 0 var(--ink)}
.swatch{border:1.5px solid var(--ink);border-radius:9px 6px 10px 7px}
.cooldown{border:2px solid var(--ink);background:var(--paper);color:var(--ink);border-radius:12px 8px 15px 9px;box-shadow:2px 3px 0 var(--ink)}
.cooldown.ready{background:var(--leaf);color:var(--ink)}
.tile-panel{background:#e2f5dc}.tile-panel h2{font-size:25px}.drawer-head{background:#fde3ef;border-bottom:2px solid var(--ink);border-radius:20px 10px 0 0}
#history .drawer-head{background:#ddf0fc}.chat-form{border-top:2px solid var(--ink)}
input:not([type=range]):not([type=checkbox]){border:2px solid var(--ink);background:var(--paper);border-radius:12px 8px 15px 9px}
.primary{background:var(--accent);color:var(--ink);border:2px solid var(--ink);border-radius:15px 9px 17px 10px;box-shadow:3px 3px 0 var(--ink);font-family:var(--hand);font-weight:400;font-size:20px;line-height:1.1}
.primary:not(:disabled):hover{background:#ffe27a;transform:rotate(-1deg)}.primary:disabled{background:#ded5c3;color:var(--muted);box-shadow:none}
.link{color:#315e83}.coord{background:#ddf0fc;color:#315e83;border:1px solid var(--ink);border-radius:7px 4px 8px 5px}
.timeline .chip{background:var(--blue);border:2px solid var(--ink)}
dialog{box-shadow:6px 7px 0 var(--ink);max-height:calc(100dvh - 36px);overflow-y:auto}
dialog h2{font-size:32px;transform:rotate(-1deg);margin:4px 0 10px}dialog form{padding:24px}
dialog::backdrop{background:#2a26335e;backdrop-filter:blur(4px)}
.toast{border:2px solid var(--ink);border-radius:15px 9px 18px 11px;box-shadow:3px 4px 0 var(--ink)}
@media(max-width:700px){
 .brand h1{font-size:38px}.brand p{font-size:13px}.brand.card{padding:4px 4px 8px;margin-right:144px}.top-left{gap:6px}
 .tools{padding:6px;gap:4px;max-width:calc(100vw - 16px)}.tool{min-width:0;width:calc((100vw - 56px)/6);padding:6px 1px;font-size:12px}.tool .ico{font-size:20px}
 .fc-head strong{font-size:21px}.forecast{padding:10px 12px}.fc-when{font-size:11px}.fc-stats{font-size:12px}
 .drawer{top:62px;bottom:max(12px,env(safe-area-inset-bottom))}.drawer-head h2{font-size:24px}
 dialog form{padding:20px}dialog h2{font-size:28px}.primary{font-size:18px}
}
@media(max-height:550px){.forecast p,.fc-stats{display:none}.brand h1{font-size:34px}.brand p{font-size:12px}.forecast{padding:8px 12px}.top-left{gap:4px}.drawer{top:60px}.tile-panel{max-height:calc(100dvh - var(--bar-h,90px) - 45px);overflow:auto}}
/* Status messages must not cover the navigation or intercept map controls. */
.toast{pointer-events:none}
@media(max-width:700px){.toast{top:auto;bottom:calc(var(--bar-h,90px) + max(24px,env(safe-area-inset-bottom)));font-size:13px}}
