@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;
  --ally: #5fe36a; /* teammates' health: green, so it never looks like an enemy bar */
  --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));
  aspect-ratio: 512 / 258; object-fit: cover; object-position: 50% 51%; } /* the image is mostly empty space: crop to the lettering */
/* centred, but when the menu is taller than the screen it starts at the top (plain centring pushes the logo off-screen) */
#join { justify-content: flex-start; }
#join > :first-child { margin-top: auto; }
#join > :last-child { margin-bottom: auto; }
.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; }
#loadtip { max-width: min(460px, 90vw); text-align: center; color: #d8cdf5; font-family: system-ui, sans-serif; letter-spacing: 0; font-size: 15px; min-height: 40px; transition: opacity .4s; }
/* wide screens: menu on the left, your mage on the right */
@media (min-width: 900px) and (pointer: fine) {
  #join { align-items: flex-start; padding-left: 7vw; background: linear-gradient(90deg, rgba(5, 3, 12, .85) 0%, rgba(5, 3, 12, .55) 45%, rgba(5, 3, 12, 0) 75%); }
  #join .logo, #join .subtitle, #join .hint, #join #boardbtn { align-self: flex-start; }
  #join .logo { margin-left: 30px; }
  #join .hint { max-width: 420px; text-align: left; }
}

.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; }

/* narrower desktop windows: keep the chat clear of the spell bar */
@media (max-width: 1100px) and (pointer: fine) { #chat { bottom: 150px; width: min(280px, 34vw); } #chatlog { max-height: 110px; } }
/* buttons from the GUI Kit Casual Game pack (9-slice capsules) */
.btn { font-family: inherit; font-size: 18px; color: #fff; cursor: pointer; background: none; padding: 0 10px; line-height: 1.2;
  border-style: solid; border-width: 11px 12px 18px; border-image: url('../assets/ui/kit/button_yellow.png') 24 26 40 26 fill / 11px 12px 18px stretch;
  text-shadow: -1px -1px 0 rgba(40, 20, 0, .7), 1px -1px 0 rgba(40, 20, 0, .7), -1px 1px 0 rgba(40, 20, 0, .7), 1px 1px 0 rgba(40, 20, 0, .7), 0 2px 0 rgba(40, 20, 0, .7);
  transition: transform .08s, filter .1s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px) scale(.98); }
.btn:disabled { filter: grayscale(.6) brightness(.85); }
.btn.orange { border-image-source: url('../assets/ui/kit/button_yellow.png'); }
.btn.green { border-image-source: url('../assets/ui/kit/button_green.png'); }
.btn.blue { border-image-source: url('../assets/ui/kit/button_blue.png'); }
.btn.grey { border-image-source: url('../assets/ui/kit/button_gray.png'); }
.btn.big { font-size: 24px; padding: 0 18px; border-width: 13px 14px 21px; border-image-width: 13px 14px 21px; }
.btn.small { font-size: 14px; padding: 0 4px; border-width: 7px 8px 12px; border-image-width: 7px 8px 12px; }
#create { flex: 1; }
/* menu: quick play / with friends */
.tabs { display: flex; gap: 6px; margin: 12px 0 2px; }
.tabs button { flex: 1; font-family: inherit; font-size: 16px; padding: 7px 6px; border-radius: 10px; border: 3px solid #b48a55; background: #fff4dc; color: var(--ink); cursor: pointer; }
.tabs button.on { border-color: #e5741a; background: #ffd98a; }
.row.duo .btn { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; padding: 2px 6px; }
.row.duo .btn b { font-weight: normal; font-size: 22px; }
.row.duo .btn small { font-family: system-ui, sans-serif; font-size: 12px; letter-spacing: 0; opacity: .95; white-space: nowrap; }
#online { margin-top: 8px; text-align: center; font-family: system-ui, sans-serif; letter-spacing: 0; min-height: 18px; }
#online .live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #3cb043; margin-right: 5px; box-shadow: 0 0 6px #3cb043; }
.panel label.check { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 16px; cursor: pointer; white-space: nowrap; }
.panel label.check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: #e5741a; }
#openrooms .room .kind { font-size: 12px; padding: 0 6px; border-radius: 6px; background: #3cb043; color: #fff; margin-left: 6px; }
#lobbycount { font-size: 16px; margin: 2px 0 6px; color: #7a4a1e; }
#lobbycount b { color: #c0391b; }
#lobbypanel .row { margin-top: 12px; align-items: stretch; }
#lobbypanel .row #startbtn { flex: 1; margin-top: 0; }
#lobbypanel .row #leavebtn { flex: none; }

#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(--ally); }
.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(180deg, #ff9a8a 0%, #ff3b3b 45%, #c41a2a 100%); transition: width .15s; }
.mybars .bar { border: 2px solid rgba(255, 230, 190, .55); box-shadow: 0 2px 6px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .15); padding-left: 0; }
.mybars .bar i { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); z-index: 2; font-style: normal; font-size: 12px; text-shadow: 0 1px 2px #000; }
.mybars .bar::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 45%; background: linear-gradient(rgba(255, 255, 255, .28), rgba(255, 255, 255, 0)); pointer-events: none; border-radius: 10px 10px 0 0; }
.mybars .bar.low { animation: lowbar .9s ease-in-out infinite; }
@keyframes lowbar { 50% { box-shadow: 0 0 14px rgba(255, 70, 70, .9), inset 0 1px 0 rgba(255, 255, 255, .15); } }
.mybars .bar span { z-index: 2; }
#manafill { position: absolute; left: 0; top: 0; height: 100%; background: linear-gradient(180deg, #a8ecff 0%, #3a9bff 45%, #1d5fd0 100%); }
#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%; }
#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 .35s, transform .45s cubic-bezier(.2, 1.6, .4, 1), letter-spacing .6s; transform: translateY(-14px) scale(.85); letter-spacing: .12em; }
#banner.show { opacity: 1; transform: none; letter-spacing: .02em; }
#banner::before { content: ''; position: absolute; left: 50%; top: 50%; width: min(620px, 90vw); height: 1.6em; transform: translate(-50%, -55%); background: radial-gradient(ellipse at center, rgba(20, 10, 40, .55), rgba(20, 10, 40, 0) 70%); z-index: -1; }
#banner.boss { color: #ff6a4a; text-shadow: 0 4px 0 #5a0d0d, 0 0 26px rgba(255, 60, 30, .8); }
#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; }
.card { position: relative; }
.card .rar { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #8a5a2b; margin: -6px 0 2px; }
.card .own { font-family: system-ui, sans-serif; font-size: 12px; letter-spacing: 0; margin-top: 6px; color: #6b4a2a; font-style: italic; }
.card.rare { border-color: #3d84e8; box-shadow: 0 8px 0 rgba(0, 0, 0, .35), 0 0 18px rgba(80, 160, 255, .55); }
.card.rare .rar { color: #2a6fd0; }
.card.epic { border-color: #a24dff; background: linear-gradient(180deg, #fbf0ff 0%, #ead6ff 100%); box-shadow: 0 8px 0 rgba(0, 0, 0, .35), 0 0 22px rgba(190, 110, 255, .75); animation: epicGlow 1.6s ease-in-out infinite; }
.card.epic .rar { color: #8a2be2; font-weight: bold; }
@keyframes epicGlow { 50% { box-shadow: 0 8px 0 rgba(0, 0, 0, .35), 0 0 34px rgba(210, 140, 255, 1); } }
#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(--ally); }
.tag .rv { font-size: 13px; color: #9dffb0; }
#lowhp { position: absolute; inset: 0; pointer-events: none; z-index: 3; opacity: 0; box-shadow: inset 0 0 120px rgba(200, 0, 20, .8); transition: opacity .4s; }
#lowhp.on { opacity: 1; animation: heartbeat 1.1s ease-in-out infinite; }
@keyframes heartbeat { 0%, 100% { opacity: .35; } 15% { opacity: 1; } 30% { opacity: .5; } 45% { opacity: .9; } }
#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; }
/* leaderboard */
#board { z-index: 30; }
.boardpanel { font-family: system-ui, sans-serif; letter-spacing: 0; max-height: 90vh; display: flex; flex-direction: column; width: min(860px, 96vw); }
.boardhead { display: flex; justify-content: space-between; align-items: center; }
.boardhead h2 { font-family: 'Lilita', sans-serif; margin: 0; }
#boardtabs { display: flex; gap: 6px; margin: 10px 0; }
#boardtabs button { font-family: 'Lilita', sans-serif; font-size: 16px; padding: 6px 14px; border-radius: 10px; border: 3px solid #b48a55; background: #fff4dc; color: var(--ink); cursor: pointer; }
#boardtabs button.on { border-color: #e5741a; background: #ffd98a; }
#boardbody { overflow: auto; min-height: 120px; }
#boardbody table { border-collapse: collapse; width: 100%; font-size: 14px; }
#boardbody th { font-family: 'Lilita', sans-serif; font-weight: normal; color: #7a4a1e; text-align: right; padding: 6px 8px; position: sticky; top: 0; background: #f6e3c0; white-space: nowrap; }
#boardbody td { text-align: right; padding: 5px 8px; border-top: 1px solid rgba(138, 90, 43, .2); white-space: nowrap; }
#boardbody .l { text-align: left; white-space: normal; }
#boardbody span[style] { font-weight: 700; text-shadow: 0 0 1px rgba(0, 0, 0, .5); }
#boardbody tr.me td { background: rgba(255, 200, 80, .28); }
#boardbody th.sortable { cursor: pointer; }
#boardbody th.sortable.on { color: #e5741a; text-decoration: underline; }
#boardbody .you { font-size: 11px; background: #e5741a; color: #fff; border-radius: 6px; padding: 1px 5px; }
.muted { color: #8d6d4f; }
.totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.tot { background: rgba(138, 90, 43, .12); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.tot b { font-family: 'Lilita', sans-serif; font-size: 26px; color: #7a3d10; }
.tot span { font-size: 13px; }
#boardbody h3 { font-family: 'Lilita', sans-serif; margin: 14px 0 6px; }
.bar2 { display: grid; grid-template-columns: minmax(110px, 200px) 1fr 50px; gap: 8px; align-items: center; font-size: 14px; margin: 3px 0; }
.bar2 .bt { height: 12px; background: rgba(138, 90, 43, .15); border-radius: 6px; overflow: hidden; }
.bar2 .bt span { display: block; height: 100%; border-radius: 6px; }
.bar2 .bn { text-align: right; }
#boardbtn { margin-top: 4px; }
#lobbypanel #boardbtn2 { width: 100%; margin-top: 8px; }
#overrank { font-size: 20px; color: var(--gold); text-shadow: var(--shadow); min-height: 24px; text-align: center; }
body.touch #boardbody table { font-size: 12px; }
body.touch #boardbody th, body.touch #boardbody td { padding: 4px 5px; }
body.touch .tot b { font-size: 20px; }

#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; }
/* roll: last slot of the action row (Space on desktop), round kit button with a recharge sweep */
#actionrow { display: flex; gap: 6px; align-items: flex-end; }
#rollbtn { position: relative; width: 64px; height: 64px; border-radius: 50%; border: none; color: #fff; pointer-events: auto; cursor: pointer; padding: 0; margin-left: 4px;
  background: url('../assets/ui/kit/play_bottom_btn.png') center / contain no-repeat; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: inherit; transition: transform .1s; }
#rollbtn::before { content: ''; position: absolute; inset: 5px 6px 10px; border-radius: 50%; background: conic-gradient(rgba(5, 3, 15, .72) calc(var(--cd, 0) * 360deg), transparent 0); pointer-events: none; }
#rollbtn span { font-size: 24px; line-height: 1; position: relative; }
#rollbtn small { font-size: 10px; opacity: .9; position: relative; margin-bottom: 4px; }
#rollbtn.ready { filter: drop-shadow(0 0 8px rgba(255, 210, 120, .75)); }
#rollbtn:active { transform: scale(.92); }
body.touch #rollbtn { position: absolute; right: 2px; bottom: 44px; width: 78px; height: 78px; margin: 0; }
body.touch #rollbtn span { font-size: 30px; }
/* your blessings, above the bars */
#myblessings { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; min-height: 0; pointer-events: auto; }
#myblessings .mb { position: relative; font-size: 16px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: rgba(10, 6, 20, .6); border: 1.5px solid rgba(255, 230, 190, .35); cursor: help; }
#myblessings .mb.rare { border-color: #3d84e8; }
#myblessings .mb.epic { border-color: #b46cff; box-shadow: 0 0 8px rgba(180, 108, 255, .6); }
#myblessings .mb b { position: absolute; right: -4px; bottom: -5px; font-size: 10px; background: #e5741a; border-radius: 6px; padding: 0 3px; line-height: 13px; }
body.touch #myblessings .mb { width: 22px; height: 22px; font-size: 12px; }
/* arrows at the screen edge for things you can't see */
#indicators { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.ind { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; font-size: 12px; text-shadow: 0 1px 2px #000; white-space: nowrap; will-change: transform; }
.ind i { font-style: normal; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; background: rgba(10, 6, 20, .75); border: 2px solid currentColor; position: relative; }
.ind i::after { content: ''; position: absolute; left: 50%; top: 50%; width: 0; height: 0; border: 7px solid transparent; border-left-color: currentColor; transform: rotate(var(--rot, 0rad)) translate(22px, -7px); transform-origin: 0 7px; }
.ind.pulse i { animation: indpulse .8s ease-in-out infinite; }
@keyframes indpulse { 50% { transform: scale(1.18); } }
/* multi-kill callouts */
#callout { position: absolute; top: 17%; left: 0; right: 0; text-align: center; pointer-events: none; z-index: 6; opacity: 0; transform: scale(.6); transition: opacity .2s, transform .25s cubic-bezier(.2, 1.8, .4, 1); }
#callout.show { opacity: 1; transform: none; }
#callout span { display: inline-block; font-size: clamp(26px, 4.5vw, 44px); color: #fff; padding: 6px 34px; letter-spacing: .03em;
  background: linear-gradient(90deg, rgba(40, 140, 255, 0), rgba(40, 140, 255, .55) 25%, rgba(40, 140, 255, .55) 75%, rgba(40, 140, 255, 0));
  border-top: 3px solid rgba(140, 220, 255, .9); border-bottom: 3px solid rgba(140, 220, 255, .9); text-shadow: 0 3px 0 #0b3d7a, 0 0 18px rgba(120, 210, 255, .9); }
#callout.gold span { background: linear-gradient(90deg, rgba(255, 170, 30, 0), rgba(255, 170, 30, .55) 25%, rgba(255, 170, 30, .55) 75%, rgba(255, 170, 30, 0)); border-color: #ffe08a; text-shadow: 0 3px 0 #7a3d10, 0 0 18px rgba(255, 200, 90, .9); }
.medal { width: 26px; height: 23px; vertical-align: middle; }
.sp { cursor: help; }

#joystick { position: absolute; left: 30px; bottom: 120px; width: 120px; height: 120px; border-radius: 50%; background: url('../assets/ui/kit/joystick_bg.png') center / contain no-repeat; opacity: .9; }
#stick { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: url('../assets/ui/kit/joystick_handle.png') center / contain no-repeat; }

@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: 0 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); }
@media (max-height: 760px) { body.touch #join { gap: 8px; } body.touch .logo { width: min(220px, 52vw); } body.touch .subtitle { font-size: 18px; margin-bottom: 0; } }
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: 0 8px; }
body.touch #lobbypanel .row { margin-top: 8px; }
body.touch #lobbycount { font-size: 14px; margin: 0 0 4px; }
body.touch .tabs { margin-top: 8px; }
body.touch .tabs button { font-size: 14px; padding: 5px 4px; }
body.touch .row.duo .btn b { font-size: 19px; }
body.touch .row.duo .btn small { font-size: 11px; }
body.touch #cards { width: auto; left: 6px; right: 6px; 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: 16px; padding: 0 8px; white-space: nowrap; }
body.touch #over .row { flex-wrap: wrap; justify-content: center; gap: 6px; width: min(360px, 100%); }
body.touch #over .row #againbtn { flex: 1 0 100%; font-size: 22px; }
body.touch #over .row .btn:not(#againbtn) { flex: 1; min-width: 0; }
body.touch #over .row .btn#boardbtn3 { flex: 0 0 56px; }
body.touch #overrank { font-size: 15px; }
body.touch #over td.bl { white-space: normal; max-width: 90px; text-align: left; font-size: 11px; }
body.touch .overwrap { width: 100%; }
body.touch #over table { margin: 0 auto; }
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 { left: 48px; right: 48px; } /* clear of the side buttons, still centred */
  body.touch #cards h2 { font-size: 18px; margin-bottom: 4px; }
  body.touch #over h1 { font-size: 24px; }
}

/* ---------- menu, settings, developer overlay (2026-11-04) */
#mobtools { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
#mutebtn, #menuopen { width: 36px; height: 36px; padding: 0; font-size: 18px; }
body.touch #mutebtn, body.touch #menuopen { width: 34px; height: 34px; font-size: 16px; }
.menurow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
#notice { max-width: min(460px, 92vw); text-align: center; background: rgba(0, 0, 0, .55); border: 2px solid var(--gold); border-radius: 12px; padding: 8px 14px; font-family: system-ui, sans-serif; letter-spacing: 0; font-size: 15px; }
#menu, #settings { z-index: 40; }
.menupanel { display: flex; flex-direction: column; gap: 10px; width: min(320px, 92vw); text-align: center; }
.menupanel h2 { margin: 0; }
.menupanel p { margin: 0 0 4px; font-family: system-ui, sans-serif; letter-spacing: 0; }
.setpanel { width: min(440px, 94vw); max-height: 92vh; overflow: auto; }
.setpanel h3 { margin: 14px 0 4px; font-weight: normal; color: #7a3d10; }
.setpanel .label { font-size: 16px; margin: 8px 0 0; }
.setpanel .tabs { margin: 4px 0 6px; }
.setpanel label.check { margin: 8px 0; }
.panel label.slider { display: grid; grid-template-columns: 120px 1fr 44px; align-items: center; gap: 10px; font-size: 16px; margin: 6px 0; }
.panel label.slider input { display: block; width: 100%; margin: 0; padding: 0; border: 0; background: none; accent-color: #e5741a; height: 26px; }
.panel label.slider b { font-weight: normal; text-align: right; font-family: system-ui, sans-serif; letter-spacing: 0; font-size: 14px; }
#devsection { border-top: 2px dashed #b48a55; margin-top: 12px; }
#devlock { margin-top: 6px; }
#buildinfo { margin-top: 14px; text-align: center; font-family: system-ui, sans-serif; letter-spacing: 0; font-size: 12px; color: #8a6a4a; cursor: pointer; padding: 6px; }
#devoverlay { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); z-index: 15; pointer-events: none; display: flex; flex-direction: column; gap: 6px; font-family: system-ui, sans-serif; letter-spacing: 0; font-size: 12px; color: #fff; }
#devfps, #devnet { background: rgba(5, 3, 12, .72); border: 1px solid rgba(255, 255, 255, .15); border-radius: 8px; padding: 5px 8px; }
#devfps b { font-size: 15px; color: #7cff6b; }
#devgraph { display: block; width: 250px; height: 150px; }
#devtext { margin-top: 4px; line-height: 1.45; max-width: 250px; }
#toast { position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%); background: rgba(5, 3, 12, .85); border: 2px solid var(--gold); color: #fff; padding: 8px 16px; border-radius: 12px; font-family: system-ui, sans-serif; letter-spacing: 0; font-size: 15px; z-index: 60; opacity: 0; transition: opacity .25s; pointer-events: none; }
#toast.show { opacity: 1; }
body.touch #devoverlay { top: auto; bottom: 150px; transform: none; }
body.touch #devgraph { width: 200px; height: 120px; }
.setpanel label.check { white-space: normal; align-items: flex-start; }

/* ---------- watching a room (spectator) */
body.spectating #bottom, body.spectating #joystick, body.spectating #lobbypanel, body.spectating #chatin,
body.spectating #rollbtn, body.spectating #copylink, body.spectating #cards { display: none !important; }
#spectbar { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); pointer-events: auto; text-align: center; background: rgba(10, 6, 20, .72); border: 2px solid rgba(255, 207, 63, .55); border-radius: 16px; padding: 8px 14px 10px; max-width: 94vw; }
.sb-title { font-size: 18px; color: var(--gold); text-shadow: var(--shadow); margin-bottom: 6px; }
.sb-title span { color: #fff; }
.sb-row { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
#sb-join { font-size: 20px; }
#sb-note { font-family: system-ui, sans-serif; letter-spacing: 0; font-size: 13px; margin-top: 6px; color: #ffd2a0; }
#sb-note:empty { display: none; }
#watching { font-size: 14px; opacity: .9; }
.room .watchbtn { margin-left: 8px; font-size: 13px; padding: 2px 8px; border-radius: 8px; border: 2px solid #b48a55; background: #fff4dc; color: var(--ink); cursor: pointer; font-family: inherit; }
.room .full { color: #a0522d; }

/* ---------- always-on ping (next to the minimap, phones too) */
#pingbadge { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; padding: 1px 8px; border-radius: 10px; background: rgba(10, 6, 20, .55); font-family: system-ui, sans-serif; letter-spacing: 0; font-size: 12px; line-height: 1.5; font-variant-numeric: tabular-nums; }
#pingbadge:empty { display: none; }
#pingbadge i { width: 8px; height: 8px; border-radius: 50%; background: #888; }
#pingbadge i.good { background: #5fe36a; }
#pingbadge i.ok { background: #ffd23f; }
#pingbadge i.bad { background: #ff5a4a; }
body.touch #pingbadge { font-size: 11px; padding: 0 6px; margin-top: 2px; }
