:root {
  --pine: #21352c;
  --pine-dark: #16241e;
  --pine-light: #2f4a3d;
  --gold: #c9a544;
  --gold-dim: #8a7332;
  --ink: #0b120f;
  --text: #fff8e0;
  --yellow: #ffe139;
  --cyan: #6ff0ff;
  --red: #ff6a58;
  --green: #6fe07a;
  --berry: #b3261f;
  --slot: 44px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1626; color: var(--text); }
body {
  font: bold 13px/1.25 "Trebuchet MS", "Lucida Grande", Verdana, sans-serif;
  text-shadow: 1px 1px 0 #000;
  -webkit-user-select: none; user-select: none;
  cursor: default;
}
.hidden { display: none !important; }
button, input { font: inherit; color: inherit; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#overlay { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }

/* ------------------------------------------------------------ things over heads */
.ent-name, .ent-say, .ent-hp, .splat { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; }
.ent-name { font-size: 12px; color: #fff; opacity: .92; }
.ent-say { color: var(--yellow); font-size: 14px; max-width: 280px; white-space: normal; text-align: center; text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000; }
.ent-hp { width: 42px; height: 6px; background: #c22a1c; border: 1px solid #000; }
.ent-hp .fill { height: 100%; background: #2fd14a; }
.splat {
  min-width: 24px; height: 24px; padding: 0 5px; line-height: 23px; text-align: center; font-size: 13px; color: #fff;
  background: radial-gradient(circle at 40% 35%, #ff5a48, #a3140c); border: 1px solid #3d0703; border-radius: 12px 12px 12px 3px;
}
.splat.miss { background: radial-gradient(circle at 40% 35%, #6aa8ff, #2a4fa8); border-color: #0e1f4a; }

/* ------------------------------------------------------------ top-left */
#hover { position: absolute; left: 10px; top: 8px; font-size: 15px; color: #fff; pointer-events: none; }
#hover .obj { color: var(--cyan); } #hover .npc { color: var(--yellow); } #hover .more { color: #cfd8d2; font-size: 12px; }
.lv-low { color: #58f060; } .lv-mid { color: var(--yellow); } .lv-high { color: #ff5040; }
#effects { position: absolute; left: 10px; top: 34px; display: flex; flex-direction: column; gap: 3px; pointer-events: none; }
.effect { background: rgba(11, 18, 15, .7); border: 1px solid var(--gold-dim); border-radius: 3px; padding: 1px 7px; font-size: 12px; }
.effect b { color: var(--yellow); }
.effect.cold { border-color: #7fc4ff; color: #bfe6ff; }

#area-toast {
  position: absolute; left: 50%; top: 12%; transform: translateX(-50%); font-size: 30px; letter-spacing: 2px; color: #fff;
  text-shadow: 0 0 12px rgba(98, 232, 192, .9), 2px 2px 0 #000; opacity: 0; transition: opacity .8s; pointer-events: none; white-space: nowrap;
  font-family: Georgia, "Times New Roman", serif; font-style: italic;
}
#area-toast.show { opacity: 1; }
#banner {
  position: absolute; left: 50%; top: 24%; transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; transition: opacity .5s;
  background: rgba(11, 18, 15, .78); border: 2px solid var(--gold); border-radius: 4px; padding: 10px 26px; min-width: 260px;
}
#banner.show { opacity: 1; }
#banner .big { font-size: 20px; color: var(--yellow); }
#banner .small { font-size: 13px; margin-top: 3px; }
#xpdrops { position: absolute; right: 280px; top: 40%; width: 150px; pointer-events: none; }
.xpdrop { position: absolute; right: 0; display: flex; align-items: center; gap: 4px; font-size: 14px; animation: xp 1.6s linear forwards; }
.xpdrop img { width: 20px; height: 20px; }
@keyframes xp { from { transform: translateY(0); opacity: 1; } 70% { opacity: 1; } to { transform: translateY(-90px); opacity: 0; } }

/* ------------------------------------------------------------ panels */
.frame {
  background: var(--pine); border: 2px solid var(--gold); outline: 1px solid var(--ink); border-radius: 3px;
  box-shadow: inset 0 0 0 1px var(--ink), 0 3px 12px rgba(0, 0, 0, .5);
}
#right { position: absolute; right: 8px; top: 8px; width: 256px; display: flex; flex-direction: column; gap: 6px; }
#minimap-box { position: relative; height: 180px; }
#minimap { position: absolute; right: 4px; top: 2px; width: 172px; height: 172px; border-radius: 50%; border: 3px solid var(--gold); outline: 1px solid var(--ink); background: #1c2c50; box-shadow: 0 3px 12px rgba(0,0,0,.5); cursor: pointer; }
#compass { position: absolute; right: 150px; top: 0; width: 30px; height: 30px; line-height: 26px; text-align: center; border-radius: 50%; background: var(--pine-dark); border: 2px solid var(--gold); color: var(--red); cursor: pointer; }
#hp-orb { position: absolute; left: 6px; top: 60px; width: 54px; height: 54px; border-radius: 50%; border: 3px solid var(--gold); outline: 1px solid var(--ink); background: #1b0b0a; overflow: hidden; }
#hp-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 100%; background: linear-gradient(#ff5a48, #9c1810); transition: height .25s; }
#hp-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; }
#online { position: absolute; left: 8px; top: 124px; min-width: 50px; text-align: center; font-size: 12px; background: rgba(11,18,15,.7); border: 1px solid var(--gold-dim); border-radius: 9px; padding: 1px 6px; }
#online::before { content: "\25CF  "; color: var(--green); }
#online.off::before { color: #888; }
#map-btn { position: absolute; left: 14px; top: 20px; width: 36px; height: 30px; background: var(--pine-dark); border: 2px solid var(--gold); border-radius: 4px; cursor: pointer; color: var(--yellow); font-size: 16px; }
#map-btn:hover { background: var(--pine-light); }

#tabs { display: flex; gap: 2px; }
.tab { flex: 1; height: 38px; background: var(--pine-dark) center/26px no-repeat; border: 2px solid var(--gold-dim); border-bottom: none; border-radius: 4px 4px 0 0; cursor: pointer; opacity: .8; }
.tab:hover { opacity: 1; }
.tab.on { background-color: var(--pine); border-color: var(--gold); opacity: 1; }
#panel { margin-top: -6px; padding: 8px; min-height: 308px; max-height: calc(100vh - 250px); overflow: auto; }
#panel h3 { margin: 0 0 6px; font-size: 14px; color: var(--yellow); text-align: center; }
#panel p { margin: 4px 0; font-weight: normal; }

.grid { display: grid; grid-template-columns: repeat(5, var(--slot)); gap: 4px; justify-content: center; }
.slot {
  position: relative; width: var(--slot); height: var(--slot); background: var(--pine-dark) center/36px no-repeat; border: 1px solid var(--ink);
  border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(201, 165, 68, .16);
}
.slot.has { cursor: pointer; }
.slot.has:hover { box-shadow: inset 0 0 0 1px var(--gold); }
.slot.drag { opacity: .4; }
.slot.over { box-shadow: inset 0 0 0 2px var(--yellow); }
.slot .n { position: absolute; left: 2px; top: 0; font-size: 11px; color: var(--yellow); pointer-events: none; }
.slot.dim { opacity: .45; }
.slot .price { position: absolute; right: 2px; bottom: 0; font-size: 10px; color: #fff; pointer-events: none; }

/* equipment */
#doll { display: grid; grid-template-columns: repeat(3, var(--slot)); grid-template-rows: repeat(3, var(--slot)); gap: 8px; justify-content: center; margin: 4px 0 10px; }
#doll .slot[data-slot="head"] { grid-area: 1 / 2; } #doll .slot[data-slot="neck"] { grid-area: 1 / 3; }
#doll .slot[data-slot="weapon"] { grid-area: 2 / 1; } #doll .slot[data-slot="body"] { grid-area: 2 / 2; } #doll .slot[data-slot="shield"] { grid-area: 2 / 3; }
#doll .slot[data-slot="legs"] { grid-area: 3 / 2; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 6px 10px; background: var(--pine-dark); border-radius: 3px; font-weight: normal; }
.stats b { color: var(--yellow); }

/* skills */
#skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.skill { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; background: var(--pine-dark); border: 1px solid var(--ink); border-radius: 3px; padding: 4px 8px 6px 6px; height: 42px; }
.skill:hover { border-color: var(--gold); }
.skill img { width: 28px; height: 28px; }
.skill .lv { color: var(--yellow); font-size: 18px; }
.skill i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--gold); opacity: .85; }
.totals { margin-top: 8px; text-align: center; }
.totals b { color: var(--yellow); }

/* quests */
.quest { padding: 4px 6px; cursor: pointer; border-radius: 3px; }
.quest:hover { background: var(--pine-light); }
.q0 { color: #ff5a4a; } .q1 { color: var(--yellow); } .q2 { color: #5fe06a; }

/* combat + settings */
.choice { display: block; width: 100%; text-align: left; margin: 4px 0; padding: 6px 8px; background: var(--pine-dark); border: 1px solid var(--gold-dim); border-radius: 3px; cursor: pointer; text-shadow: inherit; }
.choice:hover { background: var(--pine-light); }
.choice.on { border-color: var(--yellow); box-shadow: inset 0 0 0 1px var(--yellow); }
.choice small { display: block; font-weight: normal; color: #cfd8d2; }
.btn { padding: 5px 12px; background: var(--berry); border: 2px solid var(--gold); border-radius: 4px; cursor: pointer; text-shadow: 1px 1px 0 #000; }
.btn:hover { filter: brightness(1.2); }
.btn.plain { background: var(--pine-dark); border-width: 1px; border-color: var(--gold-dim); }
.btn:disabled { filter: grayscale(1) brightness(.7); cursor: default; }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.row label { flex: 0 0 62px; font-weight: normal; }
.row input[type=range] { flex: 1; accent-color: var(--gold); }
.tri { text-align: center; margin: 8px 0; font-weight: normal; }
.tri .m { color: #ff7a6a; } .tri .r { color: #7fe08a; } .tri .g { color: #8fc0ff; }
.netline { font-weight: normal; font-size: 12px; color: #cfd8d2; }

/* ------------------------------------------------------------ chat */
#chat { position: absolute; left: 8px; bottom: 8px; width: min(500px, calc(100vw - 290px)); }
#chat-log { height: 150px; overflow-y: auto; padding: 4px 8px; background: linear-gradient(rgba(11, 18, 15, .0), rgba(11, 18, 15, .55) 30%); font-weight: normal; font-size: 13px; scrollbar-width: thin; scrollbar-color: var(--gold-dim) transparent;
  -webkit-mask-image: linear-gradient(transparent, #000 22%); mask-image: linear-gradient(transparent, #000 22%); }
#chat:hover #chat-log { -webkit-mask-image: none; mask-image: none; background: rgba(11, 18, 15, .7); }
#chat-log.quiet .c-theirs { display: none; }
#chat-log div { margin: 1px 0; -webkit-user-select: text; user-select: text; }
.c-game { color: #f4f0e0; } .c-chat { color: var(--yellow); } .c-chat b { color: #fff; } .c-quest { color: var(--cyan); } .c-warn { color: #ffb0a0; } .c-lore { color: #b8f0d0; font-style: italic; }
#chat-row { display: flex; align-items: center; gap: 6px; background: rgba(11, 18, 15, .75); border: 1px solid var(--gold-dim); border-radius: 3px; padding: 3px 8px; }
#chat-name { color: var(--yellow); }
#chat-input { flex: 1; background: none; border: none; outline: none; font-weight: normal; text-shadow: inherit; -webkit-user-select: text; user-select: text; }
#chat-input::placeholder { color: #9aa8a0; }

/* ------------------------------------------------------------ dialogue */
#dialog {
  position: absolute; left: 50%; bottom: 190px; transform: translateX(-50%); width: min(560px, calc(100vw - 20px)); padding: 12px 18px 10px; text-align: center; cursor: pointer;
}
#dialog .who { color: var(--yellow); font-size: 15px; margin-bottom: 4px; }
#dialog .who.me { color: var(--cyan); }
#dialog .text { font-weight: normal; font-size: 15px; line-height: 1.4; min-height: 42px; }
#dialog .note { font-style: italic; color: #cfeede; }
#dialog .cont { margin-top: 6px; font-size: 12px; color: #9fd0ff; }
#dialog .opt { display: block; width: 100%; margin: 3px 0; padding: 5px; background: none; border: none; cursor: pointer; font-size: 15px; text-shadow: inherit; }
#dialog .opt:hover { color: var(--yellow); }
#dialog .opt span { color: var(--gold); margin-right: 6px; }
#dialog .pick { color: var(--yellow); margin-bottom: 4px; }

/* ------------------------------------------------------------ windows */
#window { position: absolute; left: calc(50% - 130px); top: 46%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 290px)); max-height: min(78vh, 640px); display: flex; flex-direction: column; }
#window .bar { display: flex; align-items: center; padding: 6px 10px; background: var(--pine-dark); border-bottom: 1px solid var(--gold-dim); color: var(--yellow); font-size: 15px; }
#window .bar .x { margin-left: auto; width: 24px; height: 24px; line-height: 20px; text-align: center; background: var(--berry); border: 1px solid var(--gold); border-radius: 3px; cursor: pointer; color: #fff; }
#window .body { padding: 10px; overflow: auto; }
#window .foot { padding: 8px 10px; border-top: 1px solid var(--gold-dim); display: flex; align-items: center; gap: 10px; font-weight: normal; font-size: 12px; }
#window .foot .sp { flex: 1; }
.wgrid { display: grid; grid-template-columns: repeat(auto-fill, var(--slot)); gap: 4px; justify-content: center; }
.shopitem { width: 96px; padding: 4px; text-align: center; background: var(--pine-dark); border: 1px solid var(--ink); border-radius: 3px; cursor: pointer; }
.shopitem:hover { border-color: var(--gold); }
.shopitem img { width: 40px; height: 40px; display: block; margin: 0 auto; }
.shopitem small { display: block; font-weight: normal; }
.shopitem .cost { color: var(--yellow); }
.shopgrid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.group { margin: 10px 0 4px; color: var(--gold); border-bottom: 1px solid var(--gold-dim); font-size: 13px; }
.group:first-child { margin-top: 0; }
.recipe { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 3px; }
.recipe:hover { background: var(--pine-light); }
.recipe img { width: 36px; height: 36px; }
.recipe .name { flex: 1; min-width: 0; }
.recipe .name small { display: block; font-weight: normal; color: #cfd8d2; }
.recipe .name small .lack { color: var(--red); }
.recipe.locked .name b { color: var(--red); }
.recipe .btn { padding: 3px 8px; }
.journal p { font-weight: normal; font-size: 14px; line-height: 1.45; margin: 0 0 8px; }
.journal .done { color: #8fe09a; }
.help td { padding: 3px 10px 3px 0; font-weight: normal; vertical-align: top; } .help td:first-child { color: var(--yellow); white-space: nowrap; font-weight: bold; }
#worldmap { display: block; margin: 0 auto; max-width: 100%; image-rendering: pixelated; border: 1px solid var(--ink); }

/* ------------------------------------------------------------ context menu + tooltip */
#menu { position: absolute; min-width: 150px; background: rgba(38, 50, 66, .94); border: 1px solid #000; box-shadow: 2px 3px 8px rgba(0, 0, 0, .6); z-index: 50; font-size: 13px; }
#menu .head { background: #000; color: var(--cyan); padding: 2px 8px; }
#menu .item { padding: 2px 8px; cursor: pointer; white-space: nowrap; color: #fff; }
#menu .item:hover { color: var(--yellow); background: rgba(255, 255, 255, .08); }
#menu .obj { color: var(--cyan); } #menu .npc { color: var(--yellow); } #menu .itm { color: #ffb060; } #menu .plr { color: #fff; }
#tip { position: absolute; max-width: 240px; padding: 5px 8px; background: rgba(11, 18, 15, .94); border: 1px solid var(--gold); border-radius: 3px; z-index: 60; pointer-events: none; font-weight: normal; font-size: 12px; }
#tip b { color: var(--yellow); font-size: 13px; } #tip .st { color: var(--cyan); } #tip .req { color: var(--red); } #tip .ok { color: var(--green); } #tip i { color: #cfd8d2; }

/* ------------------------------------------------------------ title screen */
#title { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; z-index: 100;
  background: radial-gradient(ellipse 120% 60% at 50% 0%, rgba(98, 232, 192, .35), transparent 60%), radial-gradient(ellipse 90% 50% at 70% 5%, rgba(242, 160, 192, .22), transparent 60%), linear-gradient(#0b1430, #1c2c50 60%, #dfe8f4 60%, #eef3fa); }
#title-snow { position: absolute; inset: -100px 0 0 0; pointer-events: none;
  background-image: radial-gradient(2px 2px at 20px 30px, #fff, transparent), radial-gradient(2px 2px at 110px 80px, #fff, transparent), radial-gradient(3px 3px at 60px 140px, #fff, transparent), radial-gradient(2px 2px at 170px 190px, #fff, transparent), radial-gradient(3px 3px at 150px 20px, #fff, transparent);
  background-size: 200px 220px; animation: snowfall 9s linear infinite; opacity: .8; }
@keyframes snowfall { to { transform: translate(40px, 220px); } }
#title-card { position: relative; width: min(470px, calc(100vw - 24px)); padding: 22px 26px 16px; text-align: center; background: rgba(22, 36, 30, .93); border: 2px solid var(--gold); border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
#title h1 { margin: 0; font: italic 54px Georgia, "Times New Roman", serif; letter-spacing: 1px; background: linear-gradient(100deg, #62e8c0, #cfe6ff 45%, #f2a0c0); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; filter: drop-shadow(2px 2px 0 #000); }
#title .tag { margin: 2px 0 16px; font-weight: normal; color: #cfeede; }
#title .fine { margin: 14px 0 0; font-weight: normal; font-size: 11px; color: #9fb4aa; }
#title input[type=text] { width: 210px; padding: 6px 10px; background: var(--pine-dark); border: 2px solid var(--gold-dim); border-radius: 4px; outline: none; text-align: center; font-size: 16px; -webkit-user-select: text; user-select: text; }
#title input[type=text]:focus { border-color: var(--gold); }
#title .field { margin: 10px 0; }
#title .field > span { display: block; margin-bottom: 4px; font-size: 12px; color: var(--gold); }
.swatches { display: flex; gap: 5px; justify-content: center; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); cursor: pointer; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--gold); }
#title .btn { font-size: 17px; padding: 8px 26px; margin-top: 10px; }
#title .link { display: inline-block; margin-top: 10px; font-weight: normal; font-size: 12px; color: #9fd0ff; cursor: pointer; text-decoration: underline; }
#preview { display: block; margin: 0 auto 4px; width: 150px; height: 170px; }
#fatal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .8); padding: 30px; text-align: center; font-size: 16px; white-space: pre-wrap; }

@media (max-width: 760px) {
  #right { transform: scale(.82); transform-origin: top right; }
  #chat { width: calc(100vw - 16px); }
  #chat-log { height: 96px; }
  #window { left: 50%; width: calc(100vw - 16px); }
}
