/* Fat Cat — storybook medieval UI: parchment, wooden signs, ribbon banners, gold trim. */
:root {
  --ink: #2b190e;
  --ink-soft: #5a3a1e;
  --parch: #f6e7c4;
  --parch-2: #ead2a0;
  --parch-3: #d9b878;
  --wood: #a86a34;
  --wood-2: #8a5226;
  --wood-dark: #4a2a12;
  --gold: #f4c64e;
  --gold-2: #d9a12e;
  --gold-dark: #8f6216;
  --red: #c8402a;
  --red-2: #e8553a;
  --red-dark: #7d1f10;
  --blue: #2f63c9;
  --blue-2: #3a78e8;
  --blue-dark: #15357a;
  --green: #6cc04a;
  --muted: #7d5d3d;
  --radius: 10px;
  --font-display: 'Germania One', 'Lilita One', Georgia, serif;
  --font-num: 'Lilita One', 'Germania One', system-ui, sans-serif;
  --font: 'Nunito', system-ui, -apple-system, sans-serif;
  --wood-grain: repeating-linear-gradient(90deg, rgba(60, 25, 5, .09) 0 2px, transparent 2px 11px, rgba(255, 220, 160, .07) 11px 13px, transparent 13px 21px);
  --parchment: radial-gradient(ellipse at 50% 40%, #fdf3da 0%, #f3dfb2 55%, #e2c286 100%);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2f6b26; color: var(--ink); font-family: var(--font); font-weight: 700; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
input, select, button { font: inherit; }
[hidden] { display: none !important; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: #4f8a34; }
#game3d { position: fixed; inset: 0; width: 100%; height: 100%; display: none; outline: none; background: #2f6b26; }
body.r3d #game3d { display: block; }
body.r3d #game { display: none; }

.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; z-index: 10; }
.screen.active { display: flex; }
.screen.overlay { background: rgba(35, 18, 8, .55); backdrop-filter: blur(3px); z-index: 40; }

/* ------------------------------------------------ building blocks */
.card, .panel {
  position: relative;
  background: var(--parchment);
  border: 4px solid var(--ink-soft);
  border-radius: var(--radius);
  outline: 2px solid var(--gold-2);
  outline-offset: -11px;
  box-shadow: 0 8px 0 var(--wood-dark), 0 14px 30px rgba(0, 0, 0, .35), inset 0 0 40px rgba(150, 95, 30, .35);
  padding: 20px;
}
/* gold corner studs */
.card::before, .panel::before {
  content: ''; position: absolute; inset: 4px; pointer-events: none;
  background:
    radial-gradient(circle at 8px 8px, var(--gold) 0 4px, var(--gold-dark) 5px, transparent 6px),
    radial-gradient(circle at calc(100% - 8px) 8px, var(--gold) 0 4px, var(--gold-dark) 5px, transparent 6px),
    radial-gradient(circle at 8px calc(100% - 8px), var(--gold) 0 4px, var(--gold-dark) 5px, transparent 6px),
    radial-gradient(circle at calc(100% - 8px) calc(100% - 8px), var(--gold) 0 4px, var(--gold-dark) 5px, transparent 6px);
}
.panel { width: min(580px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; margin: auto; }
.panel.wide { width: min(900px, 100%); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ribbon headings */
h2 {
  font-family: var(--font-display); font-weight: 400; font-size: 28px; margin: 0; letter-spacing: .5px; line-height: 1.1;
  display: inline-block; color: var(--gold); padding: 6px 30px 8px;
  background: linear-gradient(#d4492f, #a5301c);
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 50%, 100% 100%, 0 100%, 14px 50%);
  text-shadow: 0 2px 0 var(--red-dark), 0 0 1px #000;
  filter: drop-shadow(0 3px 0 var(--red-dark));
}
h3 { font-family: var(--font-display); font-weight: 400; margin: 0 0 6px; font-size: 22px; letter-spacing: .5px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--red-dark); min-height: 1.2em; margin: 0; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-family: var(--font-display); font-size: 16px; letter-spacing: .06em; color: var(--ink-soft); }
input, select {
  border: 3px solid var(--ink-soft); border-radius: 8px; padding: 10px 12px;
  background: #fffaf0; color: var(--ink); outline: none; min-width: 0; font-weight: 800;
  box-shadow: inset 0 2px 4px rgba(90, 58, 30, .25);
}
input:focus, select:focus { border-color: var(--gold-dark); box-shadow: 0 0 0 3px rgba(244, 198, 78, .6), inset 0 2px 4px rgba(90, 58, 30, .25); }
.code-input { text-transform: uppercase; letter-spacing: .35em; font-size: 26px; text-align: center; font-family: var(--font-num); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--red); }
.form { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checks { justify-content: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }

/* wooden plank buttons with nail heads */
.btn {
  cursor: pointer; position: relative;
  border: 3px solid var(--wood-dark); border-radius: 8px; padding: 11px 26px;
  color: #fff4d8; font-weight: 900; font-size: 16px; letter-spacing: .02em; white-space: nowrap;
  text-shadow: 0 2px 0 var(--wood-dark);
  background:
    radial-gradient(circle at 11px 50%, #e8e2d4 0 2.5px, #6d6458 3px, transparent 3.6px),
    radial-gradient(circle at calc(100% - 11px) 50%, #e8e2d4 0 2.5px, #6d6458 3px, transparent 3.6px),
    var(--wood-grain), linear-gradient(#c07f43, var(--wood-2));
  box-shadow: inset 0 2px 0 rgba(255, 230, 180, .35), inset 0 -3px 0 rgba(60, 25, 5, .35), 0 4px 0 var(--wood-dark);
  transition: transform .06s, box-shadow .06s, filter .1s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255, 230, 180, .35), 0 1px 0 var(--wood-dark); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
/* the big call to action is a red banner */
.btn.primary {
  border: 0; border-radius: 0; color: var(--gold); padding: 12px 40px 14px;
  text-shadow: 0 2px 0 var(--red-dark);
  background: linear-gradient(#e0553a, #a8301c);
  clip-path: polygon(0 0, 100% 0, calc(100% - 18px) 50%, 100% 100%, 0 100%, 18px 50%);
  box-shadow: inset 0 3px 0 rgba(255, 200, 160, .45), inset 0 -4px 0 rgba(90, 20, 8, .45);
  filter: drop-shadow(0 4px 0 var(--red-dark));
}
.btn.primary:active { transform: translateY(3px); filter: drop-shadow(0 1px 0 var(--red-dark)); }
.btn.big { font-family: var(--font-display); font-weight: 400; font-size: 32px; letter-spacing: 1px; }
.btn.small { padding: 6px 14px; font-size: 14px; border-width: 2px; box-shadow: inset 0 2px 0 rgba(255, 230, 180, .3), 0 3px 0 var(--wood-dark); background: var(--wood-grain), linear-gradient(#c07f43, var(--wood-2)); }
.btn.ghost {
  color: var(--ink); text-shadow: none; border-color: var(--ink-soft);
  background: var(--parchment);
  box-shadow: inset 0 0 12px rgba(150, 95, 30, .3), 0 4px 0 var(--ink-soft);
}
.btn.discord { background: linear-gradient(#6d78f5, #4752c4); border-color: #2a2f7a; display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; text-shadow: 0 2px 0 #2a2f7a; }

/* ------------------------------------------------ menu */
#menu { background: #8fd0ff; }
.menu-bg { position: fixed; inset: 0; pointer-events: none; }
.menu-bg svg { width: 100%; height: 100%; display: block; }
.menu-inner { position: relative; width: min(470px, 100%); display: flex; flex-direction: column; gap: 14px; margin: auto; padding: 8px 0 24px; }
.logo { text-align: center; margin-bottom: -4px; }
.logo canvas { width: 160px; height: 145px; display: block; margin: 0 auto -22px; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .18)); }
.logo h1 {
  font-family: var(--font-display); font-weight: 400; font-size: clamp(64px, 18vw, 104px); margin: 0; line-height: .9; letter-spacing: 3px;
  background: linear-gradient(#fff3a8 10%, #f4c64e 45%, #d48a1a 80%); -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  filter: drop-shadow(0 5px 0 var(--ink)) drop-shadow(0 10px 12px rgba(0, 0, 0, .25));
}
.logo h1 span:last-child { background: linear-gradient(#ffd4e4 10%, #ff8fb5 50%, #d8487a 85%); -webkit-background-clip: text; background-clip: text; }
.tag { margin: 10px 0 0; }
.tag span {
  display: inline-block; font-family: var(--font-display); font-size: 19px; color: var(--gold); padding: 5px 32px 7px;
  background: linear-gradient(#d4492f, #a5301c);
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 50%, 100% 100%, 0 100%, 14px 50%);
  text-shadow: 0 2px 0 var(--red-dark);
}
.menu-buttons { display: flex; flex-direction: column; gap: 10px; }
.conn-status { text-align: center; color: #fff; margin: 0; text-shadow: 0 2px 0 rgba(0, 0, 0, .45); font-size: 14px; }
.conn-status:empty { display: none; }

.who { display: flex; flex-direction: column; gap: 12px; }
.profile { display: flex; align-items: center; gap: 10px; }
.profile img, .profile .avatar { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--gold-2); box-shadow: 0 0 0 2px var(--ink-soft); background: var(--parch-2); object-fit: cover; }
.profile .pinfo { flex: 1; min-width: 0; }
.profile .pinfo b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-display); font-weight: 400; font-size: 19px; }
.profile .pinfo small { color: var(--muted); }
.fur-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.fur-picker button { width: 46px; height: 46px; padding: 0; border: 3px solid var(--parch-3); border-radius: 50%; background: #fffaf0; cursor: pointer; box-shadow: 0 2px 0 var(--parch-3); }
.fur-picker button.sel { border-color: var(--gold-2); background: #fff2c2; box-shadow: 0 0 0 2px var(--ink-soft), 0 0 10px var(--gold); }
.fur-picker canvas { width: 38px; height: 38px; display: block; margin: auto; }

/* ------------------------------------------------ lobby */
.lobby-list { display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.lobby-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 3px solid var(--ink-soft); border-radius: 8px; background: #fffaf0; cursor: pointer; box-shadow: 0 3px 0 var(--parch-3); }
.lobby-item:hover { background: #fff2c2; }
.lobby-item .ln { flex: 1; min-width: 0; }
.lobby-item .ln b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-display); font-weight: 400; font-size: 19px; }
.lobby-item small { color: var(--muted); }
.pill { border-radius: 999px; padding: 2px 10px; font-size: 12px; border: 2px solid var(--ink-soft); background: var(--parch-2); }
.pill.playing { background: var(--green); color: #fff; text-shadow: 0 1px 0 #2a5a1a; }
.code-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; font-family: var(--font-display); font-size: 18px; }
.code { font-family: var(--font-num); font-weight: 400; font-size: 26px; letter-spacing: .2em; background: var(--wood-dark); color: var(--gold); padding: 2px 12px 0; border-radius: 6px; border: 2px solid var(--gold-2); }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.team { border: 3px solid var(--ink-soft); border-radius: 8px; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 8px; background: rgba(255, 250, 235, .7); overflow: hidden; }
.team h3 {
  margin: 0 -10px; padding: 8px 10px 14px; text-align: center; color: var(--gold); text-shadow: 0 2px 0 rgba(0, 0, 0, .4);
  clip-path: polygon(0 0, 100% 0, 100% 72%, 50% 100%, 0 72%);
}
.team.t0 h3 { background: linear-gradient(var(--red-2), var(--red)); }
.team.t1 h3 { background: linear-gradient(var(--blue-2), var(--blue)); }
.team ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; min-height: 60px; flex: 1; }
.team li { display: flex; align-items: center; gap: 6px; background: #fffaf0; border: 2px solid var(--parch-3); border-radius: 8px; padding: 4px 8px; }
.team li canvas { width: 26px; height: 26px; }
.team li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team li .tagx { font-size: 12px; color: var(--muted); }
.team li .kick { border: 0; background: none; cursor: pointer; color: var(--red-dark); font-weight: 900; }
.lobby-bottom { display: grid; grid-template-columns: 1fr 1.3fr; gap: 14px; }
.settings { display: flex; flex-direction: column; gap: 8px; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
.settings select { padding: 4px 8px; border-width: 2px; }
.settings label.check { justify-content: flex-start; }
.settings.locked { opacity: .65; pointer-events: none; }
.chat { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.chat-log { flex: 1; min-height: 110px; max-height: 160px; overflow-y: auto; background: #fffaf0; border: 3px solid var(--ink-soft); border-radius: 8px; padding: 6px 8px; font-size: 14px; user-select: text; box-shadow: inset 0 2px 6px rgba(90, 58, 30, .2); }
.chat-log .sys { color: var(--muted); font-style: italic; }
.chat-log .c0 { color: var(--red-dark); }
.chat-log .c1 { color: var(--blue-dark); }
.chat input { width: 100%; padding: 6px 10px; }

/* ------------------------------------------------ HUD */
.hud { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 20; color: #fff; }
.hud.active { display: block; }
.hud * { pointer-events: none; }
.hud button, .hud input, .hud form, .hud .stick, .hud .tbtns, .hud .dead .btn, .hud .scoreboard { pointer-events: auto; }

.hud-top { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: flex-start; gap: 4px; }
/* team pennants with the princess portrait and a shield for the score */
.score-side {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 16px; min-height: 62px;
  border: 3px solid var(--ink); border-top: 0;
  clip-path: polygon(0 0, 100% 0, 100% 78%, 50% 100%, 0 78%);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .18);
}
.s0 { background: linear-gradient(var(--red-2), var(--red)); }
.s1 { background: linear-gradient(var(--blue-2), var(--blue)); }
.score {
  font-family: var(--font-num); font-size: 30px; line-height: 1; min-width: 38px; height: 42px; padding-top: 5px; text-align: center; color: var(--ink);
  background: linear-gradient(#fff3c2, var(--gold) 60%, var(--gold-2));
  border: 3px solid var(--ink);
  clip-path: path('M0 0 H38 V24 Q38 36 19 44 Q0 36 0 24Z');
}
.pfat { display: flex; align-items: center; gap: 6px; }
.pface { width: 42px; height: 42px; border-radius: 50%; background: radial-gradient(#fff6dc, #ead2a0); border: 3px solid var(--gold-2); box-shadow: 0 0 0 2px var(--ink); }
.pname { font-family: var(--font-display); font-size: 14px; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .45); }
.meter { width: 74px; height: 9px; background: rgba(40, 15, 5, .45); border: 2px solid var(--ink); border-radius: 5px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, #ffd27a 0 8px, #ffb85a 8px 10px), linear-gradient(#ffe4a0, #ff9a6b); }
.pstate { font-size: 11px; font-weight: 900; color: var(--gold); text-shadow: 0 1px 0 rgba(0, 0, 0, .6); }
/* hanging wooden sign */
.timer {
  position: relative; margin-top: 14px; text-align: center; display: flex; flex-direction: column; justify-content: center; padding: 3px 14px 5px;
  border: 3px solid var(--wood-dark); border-radius: 6px;
  background: var(--wood-grain), linear-gradient(#b8783c, var(--wood-2));
  box-shadow: inset 0 2px 0 rgba(255, 230, 180, .3), 0 3px 0 var(--wood-dark);
}
.timer::before, .timer::after { content: ''; position: absolute; top: -16px; width: 3px; height: 14px; background: repeating-linear-gradient(#cfc8bb 0 4px, #6d6458 4px 6px); }
.timer::before { left: 12px; }
.timer::after { right: 12px; }
#timer { font-family: var(--font-num); font-size: 24px; color: #fff4d8; text-shadow: 0 2px 0 var(--wood-dark); }
.goal { font-size: 10px; color: var(--gold); }

#minimap {
  position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); width: 210px; height: 130px;
  border: 6px solid var(--wood-2); border-radius: 8px; outline: 2px solid var(--wood-dark); background: #30502a;
  box-shadow: inset 0 0 0 2px var(--gold-dark), 0 4px 0 var(--wood-dark);
}
.feed { position: absolute; top: 158px; right: max(10px, env(safe-area-inset-right)); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: 46vw; }
.feed div {
  color: var(--ink); text-shadow: none; font-size: 13px; padding: 3px 12px; border-radius: 3px;
  background: var(--parchment); border: 2px solid var(--ink-soft); box-shadow: 0 2px 0 rgba(0, 0, 0, .3);
  animation: feedIn .2s ease-out;
}
.feed .k0 { color: var(--red); } .feed .k1 { color: var(--blue); }
@keyframes feedIn { from { transform: translateX(20px); opacity: 0; } }

/* player medallion: portrait ringed by a health dial */
.me-box { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; gap: 6px; align-items: center; }
.medal {
  --hp: 360deg; position: relative; width: 82px; height: 82px; border-radius: 50%; flex: none; z-index: 1;
  background: conic-gradient(#6ee04a var(--hp), #5a1f14 0);
  border: 4px solid var(--ink); box-shadow: 0 0 0 3px var(--gold-2), 0 0 0 5px var(--ink), 0 4px 6px rgba(0, 0, 0, .4);
  display: flex; align-items: center; justify-content: center;
}
.medal.low { background: conic-gradient(#ff5a3a var(--hp), #5a1f14 0); animation: pulse 0.6s ease-in-out infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 0 3px var(--gold-2), 0 0 0 5px var(--ink), 0 0 16px #ff5a3a; } }
.medal canvas { width: 62px; height: 62px; border-radius: 50%; background: radial-gradient(#fff6dc, #ead2a0); border: 3px solid var(--ink); }
.me-info {
  margin-left: -26px; padding: 6px 14px 6px 32px; min-width: 190px;
  background: var(--parchment); border: 3px solid var(--ink-soft); border-radius: 0 10px 10px 0; color: var(--ink);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35);
}
.me-class { font-family: var(--font-display); font-size: 21px; line-height: 1; color: var(--red-dark); }
.hp { position: relative; width: 150px; height: 14px; margin-top: 4px; background: #5a1f14; border: 2px solid var(--ink); border-radius: 7px; overflow: hidden; }
.hp i { position: absolute; inset: 0; width: 100%; background: linear-gradient(#9ef07a, #4bb52d); transition: width .1s; }
.hp span { position: absolute; inset: 0; text-align: center; font-size: 10px; line-height: 11px; color: #fff; text-shadow: 0 1px 0 #000; }
.me-extra { font-size: 12px; min-height: 15px; margin-top: 2px; color: var(--ink-soft); }
.charge { width: 150px; height: 7px; margin-top: 3px; border-radius: 4px; background: rgba(90, 58, 30, .25); border: 1px solid var(--ink-soft); overflow: hidden; visibility: hidden; }
.charge.show { visibility: visible; }
.charge i { display: block; height: 100%; width: 0; background: var(--gold-2); }
.charge i.full { background: #ff6b3d; box-shadow: 0 0 8px #ffb03a; }

/* scroll-shaped hints */
.hint {
  position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%); display: none; white-space: nowrap;
  color: var(--ink); font-size: 15px; padding: 7px 22px;
  background: var(--parchment); border: 3px solid var(--ink-soft); border-radius: 4px;
  box-shadow: -6px 0 0 -2px var(--parch-3), 6px 0 0 -2px var(--parch-3), 0 3px 0 rgba(0, 0, 0, .35);
}
.hint.show { display: block; }
.banner {
  position: absolute; left: 50%; top: 22%; transform: translate(-50%, -50%) scale(.9); text-align: center; white-space: nowrap; opacity: 0; transition: opacity .25s, transform .25s;
  font-family: var(--font-display); font-size: clamp(26px, 5vw, 46px); color: var(--gold); padding: 8px 54px 12px;
  background: linear-gradient(#e0553a, #a8301c);
  clip-path: polygon(0 0, 100% 0, calc(100% - 26px) 50%, 100% 100%, 0 100%, 26px 50%);
  text-shadow: 0 3px 0 var(--red-dark);
  filter: drop-shadow(0 4px 0 var(--red-dark));
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.hud-buttons { position: absolute; top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); display: flex; gap: 6px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer; font-size: 18px; padding: 0;
  border: 3px solid var(--wood-dark);
  background: var(--wood-grain), radial-gradient(circle at 35% 30%, #d08c4c, var(--wood-2));
  box-shadow: inset 0 0 0 2px var(--gold-2), 0 3px 0 var(--wood-dark);
}
.game-chat { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: 110px; width: min(360px, 60vw); display: flex; flex-direction: column; gap: 4px; }
.game-chat .chat-log { background: transparent; border: 0; box-shadow: none; max-height: 140px; min-height: 0; padding: 0; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; font-size: 13px; overflow: hidden; }
.game-chat .chat-log .c0 { color: #ffb199; } .game-chat .chat-log .c1 { color: #a9c8ff; } .game-chat .chat-log .sys { color: #ffe6a8; }
.game-chat input { width: 100%; }

.dead { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: radial-gradient(transparent 30%, rgba(40, 10, 20, .6)); text-align: center; }
.dead.show { display: flex; }
.dead h2 { font-size: 36px; }
.dead p {
  margin: 0; color: var(--ink); font-size: 18px; padding: 8px 26px;
  background: var(--parchment); border: 3px solid var(--ink-soft); border-radius: 4px;
  box-shadow: -7px 0 0 -2px var(--parch-3), 7px 0 0 -2px var(--parch-3);
}
.dead .row { gap: 8px; }
.dead .btn.sel { background: var(--wood-grain), linear-gradient(#f4c64e, #c98f1e); color: var(--ink); text-shadow: none; }

.scoreboard {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none; width: min(780px, 94vw); max-height: 80vh; overflow-y: auto;
  color: var(--ink); background: var(--parchment); border: 4px solid var(--ink-soft); border-radius: var(--radius);
  outline: 2px solid var(--gold-2); outline-offset: -10px; padding: 18px;
  box-shadow: 0 8px 0 var(--wood-dark), inset 0 0 40px rgba(150, 95, 30, .35);
}
.scoreboard.show { display: block; }
table.stats { width: 100%; border-collapse: collapse; font-size: 14px; }
table.stats th { text-align: right; font-family: var(--font-display); font-weight: 400; font-size: 15px; color: var(--ink-soft); padding: 4px 6px; border-bottom: 2px solid var(--ink-soft); }
table.stats td { text-align: right; padding: 5px 6px; border-top: 1px dashed var(--parch-3); }
table.stats th:first-child, table.stats td:first-child { text-align: left; }
table.stats tr.t0 td:first-child { color: var(--red); font-weight: 900; }
table.stats tr.t1 td:first-child { color: var(--blue); font-weight: 900; }
table.stats tr.me { background: rgba(244, 198, 78, .35); }

/* touch: wooden shields with gold rims */
.touch { position: absolute; inset: 0; display: none; }
.touch.show { display: block; }
.stick {
  position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: max(96px, calc(env(safe-area-inset-bottom) + 86px)); width: 140px; height: 140px; border-radius: 50%; touch-action: none;
  background: radial-gradient(rgba(60, 30, 10, .15), rgba(60, 30, 10, .35)); border: 4px solid rgba(244, 198, 78, .55);
}
.stick .knob {
  position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px 0 0 -31px; border-radius: 50%;
  border: 3px solid var(--wood-dark); background: var(--wood-grain), radial-gradient(circle at 35% 30%, #d08c4c, var(--wood-2));
  box-shadow: inset 0 0 0 3px var(--gold-2);
}
.tbtns { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); width: 210px; height: 210px; }
.tb {
  position: absolute; border-radius: 50%; font-size: 26px; padding: 0; touch-action: none;
  border: 3px solid var(--wood-dark);
  background: var(--wood-grain), radial-gradient(circle at 35% 30%, #d89552, var(--wood-2));
  box-shadow: inset 0 0 0 3px var(--gold-2), inset 0 0 0 5px var(--wood-dark), 0 4px 0 var(--wood-dark);
}
.tb.down { transform: translateY(3px) scale(.95); filter: brightness(1.2); }
.tb.atk { width: 92px; height: 92px; right: 0; bottom: 0; font-size: 38px; background: var(--wood-grain), radial-gradient(circle at 35% 30%, #e86a4c, #a5301c); }
.tb.sp { width: 64px; height: 64px; right: 100px; bottom: 6px; }
.tb.act { width: 64px; height: 64px; right: 14px; bottom: 102px; }
.tb.eat { width: 52px; height: 52px; right: 96px; bottom: 82px; font-size: 22px; }
.tb.locked { opacity: .35; }
.tb .cd { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; color: #fff; text-shadow: 0 1px 0 #000; }

/* ------------------------------------------------ modals & results */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(35, 18, 8, .6); z-index: 60; }
.modal.show { display: flex; }
.howto p, .howto li { line-height: 1.45; font-weight: 700; }
.howto ul { padding-left: 20px; margin: 0; }
.howto b { color: var(--red-dark); }
.controls div { background: rgba(255, 250, 235, .7); border: 2px solid var(--parch-3); border-radius: 8px; padding: 10px; font-size: 14px; }
.big-title { display: block; margin: 0 auto; text-align: center; font-size: 52px; padding: 8px 60px 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-grid div { background: rgba(255, 250, 235, .75); border: 2px solid var(--parch-3); border-radius: 8px; padding: 8px; text-align: center; }
.stat-grid b { display: block; font-family: var(--font-num); font-size: 26px; font-weight: 400; color: var(--red-dark); }
.stat-grid small { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.leader { display: flex; flex-direction: column; gap: 4px; }
.leader div { display: flex; gap: 8px; align-items: center; background: #fffaf0; border: 2px solid var(--parch-3); border-radius: 8px; padding: 4px 8px; }
.leader img { width: 24px; height: 24px; border-radius: 50%; }
.leader span { flex: 1; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; font-weight: 900; padding: 10px 22px;
  color: var(--ink); background: var(--parchment); border: 3px solid var(--ink-soft); border-radius: 4px; box-shadow: 0 4px 0 var(--wood-dark);
}

/* touch layout: medallion top-left, chat under it, joystick bottom-left */
body.touch-ui .me-box { bottom: auto; top: max(56px, env(safe-area-inset-top)); transform: scale(.78); transform-origin: top left; }
body.touch-ui .game-chat { bottom: auto; top: 140px; width: min(300px, 40vw); }
body.touch-ui .game-chat .chat-log { max-height: 84px; }
body.touch-ui .hint { bottom: auto; top: 88px; font-size: 13px; }

@media (max-width: 700px) {
  .teams, .lobby-bottom { grid-template-columns: 1fr; }
  .lobby-bottom .chat-log { max-height: 110px; }
  #minimap { width: 132px; height: 82px; border-width: 4px; }
  .feed { top: 100px; font-size: 12px; }
  .pfat .pname { display: none; }
  .meter { width: 46px; }
  .pface { width: 32px; height: 32px; }
  .score { font-size: 24px; }
  #timer { font-size: 18px; }
  .hud-top { top: max(54px, env(safe-area-inset-top)); }
  body.touch-ui .me-box { top: 118px; }
  body.touch-ui .game-chat { top: 196px; }
  body.touch-ui .hint { top: 150px; }
  .hp, .charge { width: 110px; }
  .me-info { min-width: 150px; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-height: 500px) {
  .hud-top { top: 4px; }
  .score-side { padding: 3px 8px 12px; min-height: 50px; }
  .pfat .pname { display: none; }
  .meter { width: 46px; height: 7px; }
  .pface { width: 30px; height: 30px; }
  .pstate { font-size: 10px; }
  .score { transform: scale(.85); }
  #timer { font-size: 17px; }
  .timer { margin-top: 8px; }
  .icon-btn { width: 34px; height: 34px; font-size: 15px; }
  #minimap { width: 132px; height: 82px; border-width: 4px; }
  .feed { top: 96px; font-size: 11px; }
  body.touch-ui .me-box { top: 46px; transform: scale(.62); }
  body.touch-ui .game-chat { top: 112px; }
  body.touch-ui .hint { top: 64px; }
  .stick { bottom: max(18px, env(safe-area-inset-bottom)); width: 124px; height: 124px; }
  .tbtns { transform: scale(.85); transform-origin: bottom right; }
  .logo canvas { width: 100px; height: 90px; margin-bottom: -14px; }
  .logo h1 { font-size: 54px; }
  .menu-inner { gap: 10px; }
  .dead h2 { font-size: 26px; }
}
@media (max-width: 500px) {
  #minimap { width: 104px; height: 64px; }
  .hud-top { top: max(80px, env(safe-area-inset-top)); left: 8px; right: 8px; transform: none; justify-content: center; }
  .pstate, .goal { display: none; }
  .meter { width: 34px; }
  .pface { width: 28px; height: 28px; }
  .feed { top: 150px; max-width: 60vw; }
  body.touch-ui .me-box { top: 150px; transform: scale(.66); }
  body.touch-ui .hint { top: 210px; white-space: normal; width: max-content; max-width: 92vw; text-align: center; }
  body.touch-ui .game-chat { top: 250px; width: 60vw; }
}
