@font-face { font-family: 'Lilita'; src: url('../assets/fonts/LilitaOne-Regular.ttf') format('truetype'); font-display: swap; }

:root {
  --ink: #3b2412;
  --gold: #ffcf3f;
  --mana: #4fb8ff;
  --hp: #ff4f4f;
  --panel: #f6e7c8;
  --shadow: 0 3px 0 rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: #0d0b16; color: #fff; font-family: 'Lilita', system-ui, sans-serif; letter-spacing: .02em; -webkit-user-select: none; user-select: none; touch-action: none; }
#app { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hidden { display: none !important; }
input { font-family: inherit; font-size: 18px; padding: 8px 10px; border-radius: 10px; border: 3px solid #8a5a2b; background: #fff8ea; color: var(--ink); outline: none; }
input:focus { border-color: #e08a1e; }
h1, h2, h3 { margin: 0 0 8px; font-weight: normal; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: radial-gradient(ellipse at center, rgba(40, 20, 70, .55), rgba(5, 3, 12, .92)); z-index: 20; padding: 16px; overflow: auto; }
#join { background: radial-gradient(ellipse at center, rgba(40, 20, 70, .35), rgba(5, 3, 12, .8)); }
.logo { width: min(340px, 70vw); filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .6)); margin-bottom: -30px; margin-top: -30px; }
.subtitle { font-size: 22px; color: #ffe9a8; text-shadow: var(--shadow); margin-bottom: 4px; }
.hint { color: #d8cdf5; opacity: .8; text-align: center; }
.bar { position: relative; height: 18px; border-radius: 9px; background: rgba(0, 0, 0, .55); border: 2px solid rgba(255, 255, 255, .25); overflow: hidden; }
#loading .bar { width: min(360px, 80vw); }
#loadfill { height: 100%; width: 0; background: linear-gradient(90deg, #ffb52e, #ffe46b); transition: width .2s; }

.panel { border-radius: 18px; padding: 18px 20px; color: var(--ink); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.paper { background: linear-gradient(180deg, #fbf0da 0%, #f1dcb6 100%); border: 4px solid #8a5a2b; box-shadow: inset 0 0 0 3px #fff6e4, inset 0 0 28px rgba(138, 90, 43, .28), 0 10px 30px rgba(0, 0, 0, .5); }
.panel label, .panel .label { display: block; font-size: 18px; margin: 6px 0; }
.panel label input { display: block; width: 100%; margin-top: 4px; }
.panel .row { display: flex; gap: 8px; margin-top: 10px; }
.panel .row input { flex: 1; text-transform: uppercase; letter-spacing: .2em; text-align: center; min-width: 0; }
#join .panel { width: min(420px, 94vw); }
.wide { width: min(720px, 94vw); }
.small { font-size: 14px; opacity: .8; }

.btn { font-family: inherit; font-size: 18px; color: #fff; border: none; border-radius: 12px; padding: 10px 18px; cursor: pointer; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); box-shadow: 0 4px 0 rgba(0, 0, 0, .35), inset 0 2px 0 rgba(255, 255, 255, .35); transition: transform .08s, filter .1s; }
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.btn.orange { background: linear-gradient(#ffb03a, #e5741a); }
.btn.green { background: linear-gradient(#7bd84a, #3f9f2a); }
.btn.blue { background: linear-gradient(#5ab8ff, #2a73d8); }
.btn.grey { background: linear-gradient(#a9a3b8, #6c6580); }
.btn.big { font-size: 24px; padding: 12px 26px; }
.btn.small { font-size: 14px; padding: 4px 10px; border-radius: 8px; }
#create { flex: 1; }

#looks, #looks2 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.look { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: inherit; font-size: 14px; padding: 8px 2px; border-radius: 10px; border: 3px solid #b48a55; background: #fff4dc; color: var(--ink); cursor: pointer; }
.look.sel { border-color: #e5741a; background: #ffd98a; }
#openrooms { margin-top: 10px; font-size: 15px; }
#openrooms .room { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; border-radius: 8px; background: rgba(138, 90, 43, .15); margin-top: 4px; cursor: pointer; }

/* hud */
#hud { position: absolute; top: env(safe-area-inset-top); right: env(safe-area-inset-right); bottom: env(safe-area-inset-bottom); left: env(safe-area-inset-left); pointer-events: none; z-index: 5; }
#mobtools { position: absolute; right: 10px; bottom: 12px; pointer-events: auto; }
#fsbtn, #zoombtn { display: none; }
body.touch #fsbtn, body.touch #zoombtn { display: block; }
.overwrap { max-width: 100%; overflow-x: auto; }
#hud .btn, #hud input, #lobbypanel, #chat { pointer-events: auto; }
#top { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#wavebox { font-size: 28px; text-shadow: var(--shadow); display: flex; gap: 12px; align-items: baseline; }
#wavesub { font-size: 18px; color: #ffe9a8; }
.towerbar { position: relative; width: min(420px, 60vw); height: 22px; border-radius: 11px; background: rgba(0, 0, 0, .6); border: 2px solid #9fe6ff; overflow: hidden; box-shadow: 0 0 14px rgba(120, 220, 255, .4); }
#towerfill { height: 100%; width: 100%; background: linear-gradient(90deg, #36c7ff, #b4f2ff); transition: width .2s; }
#towertext { position: absolute; inset: 0; text-align: center; font-size: 15px; line-height: 19px; text-shadow: 0 1px 2px #000; }
#party { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; }
.pm { display: flex; align-items: center; gap: 8px; background: rgba(10, 6, 20, .55); padding: 4px 10px 4px 6px; border-radius: 10px; min-width: 170px; }
.pm .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; flex: none; }
.pm .nm { flex: 1; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.pm .mini { width: 60px; height: 8px; border-radius: 4px; background: #0008; overflow: hidden; }
.pm .mini div { height: 100%; background: var(--hp); }
.pm.down { opacity: .6; }
#roominfo { position: absolute; top: 10px; right: 10px; text-align: right; font-size: 16px; line-height: 1.6; text-shadow: var(--shadow); }
#minimap { display: block; width: 150px; height: 150px; margin-top: 6px; margin-left: auto; }
#bottom { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(520px, 94vw); }
.mybars { width: 100%; display: flex; flex-direction: column; gap: 5px; }
.mybars .bar { height: 20px; border-radius: 10px; }
.mybars .bar span { position: absolute; inset: 0; text-align: center; font-size: 14px; line-height: 17px; text-shadow: 0 1px 2px #000; }
#hpfill { height: 100%; background: linear-gradient(90deg, #ff3b3b, #ff8a6b); transition: width .15s; }
#manafill { position: absolute; left: 0; top: 0; height: 100%; background: linear-gradient(90deg, #2f8bff, #7fe0ff); }
#managhost { position: absolute; top: 0; height: 100%; background: rgba(255, 255, 255, .35); }
#managhost.over { background: rgba(255, 60, 60, .75); }
#spellbook { display: flex; gap: 6px; }
.sp { display: flex; flex-direction: column; align-items: center; width: 84px; padding: 4px 2px 3px; border-radius: 10px; background: rgba(10, 6, 20, .55); font-size: 12px; text-align: center; border: 2px solid transparent; transition: border-color .1s, transform .1s; }
.sp svg { width: 34px; height: 34px; }
.sp.on { border-color: var(--gold); transform: translateY(-4px); }
#shapehint { min-height: 26px; font-size: 22px; text-shadow: var(--shadow); color: var(--gold); }
#chat { position: absolute; left: 10px; bottom: 12px; width: min(330px, 40vw); font-size: 14px; font-family: system-ui, sans-serif; letter-spacing: 0; }
#chatlog { max-height: 160px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; text-shadow: 0 1px 2px #000; }
#chatlog div { background: rgba(10, 6, 20, .45); padding: 2px 6px; border-radius: 6px; }
#chatlog .sys { color: #d6c8ff; font-style: italic; }
#chatin { width: 100%; margin-top: 4px; font-size: 14px; padding: 5px 8px; border-width: 2px; opacity: .55; }
#chatin:focus { opacity: 1; }
#lobbypanel { position: absolute; right: 12px; top: 250px; width: min(330px, 92vw); }
#lobbypanel p { font-family: system-ui, sans-serif; font-size: 14px; letter-spacing: 0; margin: 4px 0 10px; }
#lobbypanel #startbtn { width: 100%; margin-top: 12px; }
#lobbylist .lp { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 17px; }
#lobbylist .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
#banner { position: absolute; top: 28%; left: 0; right: 0; text-align: center; font-size: clamp(32px, 6vw, 64px); color: var(--gold); text-shadow: 0 4px 0 #7a3d10, 0 8px 18px rgba(0, 0, 0, .6); opacity: 0; transition: opacity .3s, transform .3s; transform: scale(.9); }
#banner.show { opacity: 1; transform: scale(1); }
#banner small { display: block; font-size: .45em; color: #fff; text-shadow: 0 2px 0 #000; }
#cards { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; text-shadow: var(--shadow); }
#cards h2 { font-size: 34px; color: var(--gold); }
#cardlist { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.card { width: 180px; padding: 16px 12px; border-radius: 16px; color: var(--ink); text-shadow: none; cursor: pointer; pointer-events: auto; background: linear-gradient(180deg, #fbf0da 0%, #f1dcb6 100%); border: 4px solid #8a5a2b; box-shadow: 0 8px 0 rgba(0, 0, 0, .35); transition: transform .12s; }
.card:hover { transform: translateY(-8px) rotate(-1deg); border-color: #e5741a; }
.card .ic { font-size: 44px; }
.card .cn { font-size: 21px; margin: 6px 0; }
.card .ct { font-family: system-ui, sans-serif; font-size: 14px; letter-spacing: 0; }
#cardtimer { margin-top: 14px; font-size: 20px; }
#helpbtn { width: 36px; height: 36px; padding: 0; font-size: 20px; }

#floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.fl { position: absolute; left: 0; top: 0; font-size: 18px; text-shadow: 0 2px 0 #000, 0 0 6px #000; white-space: nowrap; will-change: transform, opacity; }
.tag { position: absolute; left: 0; top: 0; text-align: center; font-size: 14px; text-shadow: 0 1px 2px #000; white-space: nowrap; will-change: transform; }
.tag .tb { width: 60px; height: 6px; margin: 2px auto 0; background: #0009; border-radius: 3px; overflow: hidden; }
.tag .tb div { height: 100%; background: var(--hp); }
.tag .rv { font-size: 13px; color: #9dffb0; }
#vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 160px rgba(255, 0, 0, .7); opacity: 0; transition: opacity .25s; z-index: 3; }

#over table { border-collapse: collapse; background: rgba(0, 0, 0, .45); border-radius: 12px; overflow: hidden; font-family: system-ui, sans-serif; letter-spacing: 0; }
#over td, #over th { padding: 6px 12px; text-align: right; }
#over th { font-family: 'Lilita', sans-serif; color: var(--gold); font-weight: normal; }
#over td:first-child, #over th:first-child { text-align: left; }
#over h1 { font-size: 48px; color: var(--gold); text-shadow: 0 4px 0 #7a3d10; }
#oversub { font-size: 22px; }
#over .row { display: flex; gap: 10px; }
#help .panel { font-family: system-ui, sans-serif; letter-spacing: 0; max-height: 90vh; overflow: auto; }
#help h2, #help h3 { font-family: 'Lilita', sans-serif; }
#helpspells { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: 10px 0; }
#helpspells .hs { display: flex; gap: 8px; align-items: center; background: rgba(138, 90, 43, .12); border-radius: 10px; padding: 6px; }
#helpspells svg { width: 40px; height: 40px; flex: none; }
#scoreboard { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(10, 6, 20, .85); padding: 14px 18px; border-radius: 14px; z-index: 8; font-family: system-ui, sans-serif; }
#scoreboard td, #scoreboard th { padding: 4px 10px; text-align: right; }
#scoreboard td:first-child, #scoreboard th:first-child { text-align: left; }
#joystick { position: absolute; left: 30px; bottom: 120px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .12); border: 2px solid rgba(255, 255, 255, .3); }
#stick { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 255, 255, .5); }

@media (max-width: 700px) {
  #top { top: 6px; left: 8px; transform: none; align-items: flex-start; }
  #wavebox { font-size: 20px; gap: 6px; }
  #wavesub { font-size: 13px; }
  .towerbar { width: 52vw; height: 18px; }
  #towertext { font-size: 12px; line-height: 15px; }
  #party { top: 72px; left: 6px; }
  .pm { min-width: 0; padding: 2px 8px 2px 4px; }
  .pm .nm { font-size: 13px; max-width: 80px; }
  .pm .mini { width: 40px; }
  #roominfo { top: 6px; right: 6px; font-size: 12px; line-height: 1.4; padding: 4px 6px; }
  #roominfo .btn.small { font-size: 11px; padding: 2px 6px; }
  #minimap { width: 90px; height: 90px; }
  #chat { display: none; }
  .sp { width: 58px; font-size: 10px; }
  .sp svg { width: 26px; height: 26px; }
  #lobbypanel { top: 150px; right: 50%; transform: translateX(50%); padding: 12px 7%; }
  #lobbypanel h2 { font-size: 20px; }
  #lobbypanel p { display: none; }
  #lobbypanel .look { font-size: 12px; padding: 5px 2px; }
  #lobbypanel #startbtn { font-size: 20px; padding: 10px; }
  #joystick { bottom: 150px; left: 20px; }
  .card { width: 150px; padding: 10px; }
  #cards h2 { font-size: 24px; }
}

/* ---------------------------------------------------------------- phones and tablets (set from JS: body.touch) */
body.touch #chat, body.touch #spellbook { display: none; }
body.touch #top { top: 4px; left: 6px; transform: none; align-items: flex-start; gap: 3px; }
body.touch #wavebox { font-size: 17px; gap: 6px; }
body.touch #wavesub { font-size: 12px; }
body.touch .towerbar { width: min(46vw, 260px); height: 14px; border-width: 1.5px; }
body.touch #towertext { font-size: 10px; line-height: 11px; }
body.touch #party { top: 48px; left: 6px; gap: 3px; }
body.touch .pm { min-width: 0; padding: 1px 6px 1px 3px; gap: 5px; border-radius: 8px; }
body.touch .pm .dot { width: 10px; height: 10px; border-width: 1.5px; }
body.touch .pm .nm { font-size: 11px; max-width: 70px; }
body.touch .pm .mini { width: 30px; height: 5px; }
body.touch #roominfo { top: 4px; right: 4px; font-size: 11px; line-height: 1.35; }
body.touch #roominfo .rlabel, body.touch #roominfo .slabel { display: none; }
body.touch #top { max-width: calc(100% - 96px); }
body.touch #wavebox { flex-wrap: wrap; row-gap: 0; }
body.touch .card .ct { line-height: 1.25; }
body.touch #join .panel { padding: 14px 16px; }
body.touch #join .look { font-size: 12px; padding: 7px 2px; }
body.touch .logo { width: min(260px, 60vw); }
body.touch #roominfo .btn.small { font-size: 11px; padding: 2px 6px; }
body.touch #minimap { width: 76px; height: 76px; margin-top: 3px; }
body.touch #mobtools { display: flex; flex-direction: column; gap: 6px; right: 4px; top: 128px; bottom: auto; }
body.touch #mobtools .btn, body.touch #helpbtn { position: static; width: 34px; height: 34px; padding: 0; font-size: 17px; border-radius: 10px; }
body.touch #bottom { bottom: 6px; gap: 4px; width: min(94vw, 420px); }
body.touch #shapehint { font-size: 17px; min-height: 20px; }
body.touch .mybars { gap: 3px; }
body.touch .mybars .bar { height: 13px; border-width: 1.5px; border-radius: 7px; }
body.touch .mybars .bar span { font-size: 10px; line-height: 11px; }
body.touch #joystick { left: 14px; bottom: 54px; width: 104px; height: 104px; opacity: .8; }
body.touch #stick { left: 29px; top: 29px; width: 44px; height: 44px; }
body.touch .tag { font-size: 11px; }
body.touch .tag .tb { width: 40px; height: 4px; }
body.touch .fl { font-size: 14px; }
body.touch #banner { top: 22%; font-size: clamp(26px, 8vw, 40px); }
body.touch #lobbypanel { top: auto; bottom: 170px; right: 50%; transform: translateX(50%); width: min(340px, 92vw); padding: 10px 7%; }
body.touch #lobbypanel h2 { font-size: 18px; margin-bottom: 4px; }
body.touch #lobbypanel p { display: none; }
body.touch #lobbylist .lp { font-size: 14px; padding: 1px 0; }
body.touch #lobbypanel .label { font-size: 14px; margin: 4px 0; }
body.touch #lobbypanel .look { font-size: 11px; padding: 4px 2px; border-width: 2px; }
body.touch #lobbypanel #startbtn { font-size: 18px; padding: 8px; margin-top: 8px; }
body.touch #cards { width: auto; left: 6px; right: 48px; transform: translateY(-50%); }
body.touch #cards h2 { font-size: 22px; }
body.touch #cardlist { gap: 6px; flex-wrap: nowrap; }
body.touch .card { width: auto; flex: 1; max-width: 170px; padding: 8px 6px; border-width: 3px; border-radius: 12px; }
body.touch .card .ic { font-size: 28px; }
body.touch .card .cn { font-size: 15px; margin: 3px 0; }
body.touch .card .ct { font-size: 11.5px; }
body.touch #cardtimer { font-size: 15px; margin-top: 8px; }
body.touch #over { justify-content: flex-start; padding-top: max(24px, env(safe-area-inset-top)); gap: 8px; }
body.touch #over h1 { font-size: 30px; text-align: center; }
body.touch #oversub { font-size: 15px; text-align: center; }
body.touch #over td, body.touch #over th { padding: 4px 6px; font-size: 12px; }
body.touch #over .btn { font-size: 17px; padding: 9px 16px; }
body.touch #help .panel { font-size: 13px; padding: 12px 6%; }
body.touch #helpspells { grid-template-columns: 1fr 1fr; }
body.touch #helpspells svg { width: 28px; height: 28px; }
body.touch #scoreboard { font-size: 12px; padding: 8px; }

/* phone held sideways: very little height, so keep everything at the edges */
@media (orientation: landscape) {
  body.touch #party { top: 46px; }
  body.touch #bottom { left: auto; right: 50px; transform: none; width: min(38vw, 340px); }
  body.touch #joystick { bottom: 14px; left: 18px; }
  body.touch #mobtools { top: 104px; }
  body.touch #minimap { width: 62px; height: 62px; }
  body.touch #lobbypanel { bottom: auto; top: 6px; right: 96px; transform: none; max-height: calc(100% - 12px); overflow-y: auto; width: 300px; }
  body.touch #banner { top: 18%; }
  body.touch #cards h2 { font-size: 18px; margin-bottom: 4px; }
  body.touch #over h1 { font-size: 24px; }
}
