:root {
  --font-pixel: 'Press Start 2P', monospace;
  --font-text: 'VT323', monospace;
  --stone: #737373;
  --stone-hi: #a9a9a9;
  --stone-lo: #3b3b3b;
  --hover: #7d8fd6;
  --panel: rgba(14, 14, 22, .82);
  --grass: #6fbf3b;
  --gold: #ffd34d;
  --white-piece: #f1ead8;
  --black-piece: #2d2838;
  --accent-w: #f2c14e;
  --accent-b: #b061ff;
  --danger: #c0392b;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #87b8e8;
  color: #fff;
  font-family: var(--font-text);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .45) 100%);
}
.hidden { display: none !important; }

/* ---------- Écrans ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20; }
#loading { background: #2b1d10 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' shape-rendering='crispEdges'%3E%3Crect width='64' height='64' fill='%23553b22'/%3E%3Crect x='0' y='0' width='16' height='16' fill='%235e4127'/%3E%3Crect x='32' y='16' width='16' height='16' fill='%234a331d'/%3E%3Crect x='16' y='40' width='16' height='16' fill='%23614429'/%3E%3Crect x='48' y='48' width='16' height='16' fill='%234d351f'/%3E%3C/svg%3E"); image-rendering: pixelated; z-index: 50; transition: opacity .6s; }
#loading.fade { opacity: 0; pointer-events: none; }
.loading-box { text-align: center; width: min(420px, 86vw); }
.loading-title { font-family: var(--font-pixel); font-size: 14px; margin-bottom: 18px; text-shadow: 2px 2px #000; }
.mc-bar { height: 14px; border: 2px solid #000; background: #3a3a3a; box-shadow: inset 0 0 0 2px #1d1d1d; }
#loading-fill { height: 100%; width: 0; background: linear-gradient(#8ee34b, #4fa521); transition: width .2s; }
.tip { margin-top: 14px; font-size: 22px; color: #ddd; }

/* ---------- Menu ---------- */
#menu { background: radial-gradient(ellipse at center, rgba(0,0,0,.05), rgba(0,0,0,.45)); overflow-y: auto; align-items: flex-start; padding: 16px; }
.menu-wrap { width: min(640px, 100%); margin: auto; display: flex; flex-direction: column; align-items: center; padding: 10px 0 20px; }
.logo { margin: 8px 0 0; display: flex; flex-direction: column; align-items: center; line-height: 1; animation: logoIn 1s cubic-bezier(.2, 1.6, .4, 1) both; }
.logo-main {
  font-family: var(--font-pixel); font-size: clamp(36px, 9vw, 72px); letter-spacing: 4px;
  color: #e8e8e8;
  background: linear-gradient(#ffffff 0 40%, #b9b9b9 40% 60%, #8c8c8c 60%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(4px 4px 0 #2a2a2a) drop-shadow(2px 2px 0 #000) drop-shadow(0 0 18px rgba(0,0,0,.4));
}
.logo-sub {
  font-family: var(--font-pixel); font-size: clamp(18px, 4.6vw, 34px); letter-spacing: 10px; margin-top: 10px;
  color: var(--grass);
  text-shadow: 3px 3px 0 #2d5a12, 5px 5px 0 #000;
}
.splash {
  font-family: var(--font-pixel); color: #ffff55; font-size: clamp(10px, 2.4vw, 15px);
  text-shadow: 2px 2px #3f3f00; transform: rotate(-12deg); margin: -6px 0 18px 46%;
  animation: splash .55s ease-in-out infinite alternate;
  white-space: nowrap;
}
@keyframes splash { from { transform: rotate(-12deg) scale(1); } to { transform: rotate(-12deg) scale(1.1); } }
@keyframes logoIn { from { transform: translateY(-60px) scale(.6); opacity: 0; } }

.panel {
  background: var(--panel);
  border: 3px solid #000;
  box-shadow: inset 0 0 0 2px #555, inset 0 0 0 4px #1b1b1b, 0 10px 30px rgba(0,0,0,.45);
  padding: 18px;
}
.menu-panel { width: 100%; animation: panelIn .6s .2s both; }
@keyframes panelIn { from { transform: translateY(30px); opacity: 0; } }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.tab small { display: block; font-family: var(--font-text); font-size: 18px; opacity: .8; margin-top: 6px; letter-spacing: 0; }

.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 22px; margin-bottom: 6px; color: #e0e0e0; text-shadow: 2px 2px #000; }
.mc-input {
  width: 100%; font-family: var(--font-text); font-size: 26px; color: #fff;
  background: #000; border: 2px solid #a0a0a0; padding: 6px 10px; outline: none;
  -webkit-user-select: text; user-select: text;
}
.mc-input:focus { border-color: #fff; box-shadow: 0 0 0 2px var(--hover); }
.mc-input::placeholder { color: #666; }
.check { display: flex; align-items: center; gap: 10px; font-size: 22px; margin: 12px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--grass); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg .mc-btn { flex: 1 1 0; min-width: 0; }
.levels .mc-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 20px; padding: 8px 2px; }
.levels em { font-style: normal; font-family: var(--font-text); font-size: 17px; }

/* ---------- Boutons façon Minecraft ---------- */
.mc-btn {
  position: relative; cursor: pointer;
  font-family: var(--font-pixel); font-size: 12px; color: #e6e6e6; letter-spacing: .5px;
  text-shadow: 2px 2px #3a3a3a;
  padding: 12px 14px;
  background:
    linear-gradient(rgba(255,255,255,.06) 50%, transparent 50%) 0 0 / 4px 4px,
    linear-gradient(90deg, rgba(0,0,0,.05) 50%, transparent 50%) 0 0 / 6px 6px,
    var(--stone);
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 var(--stone-hi), inset -2px -3px 0 var(--stone-lo);
  transition: transform .08s, filter .15s;
}
.mc-btn:hover { background-color: var(--hover); box-shadow: inset 2px 2px 0 #bcc8f5, inset -2px -3px 0 #3d4d8c; color: #ffffa0; }
.mc-btn:active { transform: translateY(2px); box-shadow: inset 2px 2px 0 var(--stone-lo), inset -2px -2px 0 var(--stone-hi); }
.mc-btn.active { background-color: #4f8a2a; box-shadow: inset 2px 2px 0 #8fd35a, inset -2px -3px 0 #2c5214; color: #fff; }
.mc-btn:disabled { filter: grayscale(1) brightness(.6); cursor: not-allowed; }
.mc-btn.sm { font-size: 10px; padding: 9px 10px; }
.mc-btn.big { font-size: 18px; padding: 18px; width: 100%; margin-top: 14px; }
.mc-btn.danger:hover { background-color: var(--danger); box-shadow: inset 2px 2px 0 #f08070, inset -2px -3px 0 #6b1e15; }
.mc-btn.play { background-color: #3f8f2a; box-shadow: inset 2px 2px 0 #8fe35a, inset -2px -3px 0 #22520f; animation: pulse 1.6s ease-in-out infinite; }
.mc-btn.play:hover { background-color: #52b236; }
@keyframes pulse { 50% { filter: brightness(1.15); } }

.credits { margin-top: 14px; font-size: 19px; color: #f0f0f0; text-align: center; text-shadow: 2px 2px #000; opacity: .9; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.players { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; gap: 10px; width: min(760px, calc(100% - 24px)); }
.player-card {
  flex: 1; min-width: 0; padding: 10px 12px; background: var(--panel); border: 3px solid #000;
  box-shadow: inset 0 0 0 2px #444; transition: box-shadow .3s, transform .3s;
}
.player-card.active { box-shadow: inset 0 0 0 2px var(--gold), 0 0 24px rgba(255, 211, 77, .55); transform: translateY(2px) scale(1.03); }
#card-b.active { box-shadow: inset 0 0 0 2px var(--accent-b), 0 0 24px rgba(176, 97, 255, .6); }
.pc-head { display: flex; align-items: center; gap: 8px; font-size: 26px; white-space: nowrap; }
.pc-name { overflow: hidden; text-overflow: ellipsis; text-shadow: 2px 2px #000; }
.pc-swatch { width: 18px; height: 18px; border: 2px solid #000; flex: none; box-shadow: inset -3px -3px rgba(0,0,0,.3); }
.pc-swatch.white { background: var(--white-piece); }
.pc-swatch.black { background: var(--black-piece); box-shadow: inset -3px -3px rgba(0,0,0,.4), 0 0 0 1px #777; }
.pc-think { display: none; font-size: 18px; color: var(--gold); margin-left: auto; }
.pc-think i { font-style: normal; animation: dots 1.2s infinite; }
.pc-think i:nth-child(2) { animation-delay: .2s; } .pc-think i:nth-child(3) { animation-delay: .4s; }
@keyframes dots { 0%, 60%, 100% { opacity: .2; } 30% { opacity: 1; } }
.player-card.thinking .pc-think { display: inline; }
.pc-captured { min-height: 24px; display: flex; align-items: center; gap: 6px; font-size: 24px; line-height: 1; margin-top: 4px; }
.cap-list { letter-spacing: -2px; overflow: hidden; white-space: nowrap; }
.cap-list span { display: inline-block; animation: capIn .5s cubic-bezier(.2, 1.8, .4, 1); }
.cap-list .pw { color: var(--white-piece); text-shadow: 1px 1px #000, -1px -1px #000; }
.cap-list .pb { color: #6b5a87; text-shadow: 1px 1px #000; }
@keyframes capIn { from { transform: scale(2.4) rotate(-30deg); opacity: 0; } }
.cap-adv { color: #8ee34b; font-size: 20px; }
.turn-badge {
  align-self: center; font-family: var(--font-pixel); font-size: 10px; padding: 8px; background: #000; border: 2px solid #555; white-space: nowrap;
}

.history { position: absolute; right: 12px; top: 110px; width: 220px; max-height: calc(100% - 200px); display: flex; flex-direction: column; padding: 12px; }
.history-title { font-family: var(--font-pixel); font-size: 10px; margin-bottom: 8px; color: var(--gold); }
#history-list { margin: 0; padding: 0 0 0 34px; overflow-y: auto; font-size: 22px; flex: 1; scrollbar-width: thin; scrollbar-color: #666 transparent; }
#history-list li { padding: 1px 0; color: #aaa; }
#history-list li span { display: inline-block; min-width: 64px; color: #fff; }
#history-list li span.last { color: var(--gold); text-shadow: 0 0 8px rgba(255,211,77,.7); }

.toolbar { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; width: max-content; max-width: calc(100% - 24px); }
.toolbar .mc-btn.off { filter: grayscale(1) brightness(.7); }

/* ---------- Bannière ---------- */
.banner { position: fixed; left: 0; right: 0; top: 38%; text-align: center; pointer-events: none; z-index: 15; opacity: 0; }
.banner.show { animation: bannerIn 2.2s ease-out forwards; }
.banner-text {
  font-family: var(--font-pixel); font-size: clamp(26px, 7vw, 60px); color: #fff;
  text-shadow: 4px 4px 0 #3a3a3a, 6px 6px 0 #000, 0 0 30px rgba(0,0,0,.5);
}
.banner.check .banner-text { color: #ff5555; text-shadow: 4px 4px 0 #5a0000, 6px 6px 0 #000, 0 0 40px rgba(255,0,0,.6); }
.banner.gold .banner-text { color: var(--gold); text-shadow: 4px 4px 0 #6b4a00, 6px 6px 0 #000, 0 0 40px rgba(255,200,0,.6); }
.banner-sub { font-size: clamp(22px, 4vw, 34px); margin-top: 14px; text-shadow: 2px 2px #000; }
@keyframes bannerIn {
  0% { opacity: 0; transform: scale(2.6); }
  12% { opacity: 1; transform: scale(.94); }
  18% { transform: scale(1.03); }
  24%, 78% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1) translateY(-30px); }
}

/* ---------- Modales ---------- */
.modal { background: rgba(0, 0, 0, .45); z-index: 30; padding: 16px; animation: fadeIn .3s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal-box { width: min(480px, 100%); text-align: center; animation: popIn .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } }
.modal-box h2 { font-family: var(--font-pixel); font-size: 18px; margin: 6px 0 14px; color: var(--gold); text-shadow: 3px 3px #000; line-height: 1.4; }
.modal-box p { font-size: 24px; margin: 8px 0; }
.go-trophy { font-size: 64px; animation: trophy 1.2s ease-in-out infinite alternate; }
@keyframes trophy { to { transform: translateY(-8px) rotate(6deg) scale(1.08); } }
.go-stats { color: #bbb; font-size: 20px !important; }
.modal-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.promo-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.promo-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 4px; font-size: 9px; }
.promo-btn b { font-size: 40px; font-family: serif; font-weight: normal; text-shadow: 2px 2px #000; }

.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.85); border: 2px solid #555; padding: 8px 16px; font-size: 24px; z-index: 40;
  opacity: 0; transition: .3s; pointer-events: none; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .history { top: auto; bottom: 64px; right: 8px; left: 8px; width: auto; max-height: 34vh; display: none; }
  .history.open { display: flex; }
  .toolbar .mc-btn span { display: none; }
  .toolbar .mc-btn { font-size: 16px; padding: 8px 10px; }
  .players { top: 8px; gap: 6px; }
  .player-card { padding: 6px 8px; }
  .pc-head { font-size: 21px; }
  .pc-captured { font-size: 19px; min-height: 20px; }
  .turn-badge { display: none; }
  .levels em { font-size: 14px; }
  .panel { padding: 14px; }
  .splash { margin-left: 30%; }
}
@media (min-width: 761px) { #btn-hist { display: none; } }

/* ---------- Fiche des pièces ---------- */
.fiche-panel { width: 100%; margin-top: 16px; animation: panelIn .6s .35s both; }
.fiche-title { font-family: var(--font-pixel); font-size: 13px; color: var(--gold); text-shadow: 2px 2px #000; margin: 0 0 14px; line-height: 1.5; }
.fiche { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.fiche-card { display: grid; grid-template-columns: 132px 1fr; grid-template-rows: auto 1fr; gap: 4px 10px; background: rgba(0,0,0,.35); border: 2px solid #000; box-shadow: inset 0 0 0 2px #3a3a3a; padding: 8px; text-align: left; }
.fiche-card .thumbs { grid-row: 1 / 3; display: flex; gap: 4px; align-items: flex-end; }
.fiche-card figure { margin: 0; width: 64px; text-align: center; }
.fiche-card figure img { width: 64px; height: 64px; display: block; filter: drop-shadow(2px 3px 0 rgba(0,0,0,.5)); }
.fiche-card figcaption { font-size: 14px; line-height: 1; color: #bbb; margin-top: 2px; }
.fiche-card .glyph.big { font-size: 44px; display: block; height: 64px; line-height: 64px; }
.fiche-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.fiche-head b { font-family: var(--font-pixel); font-size: 11px; color: #fff; text-shadow: 2px 2px #000; }
.fiche-head .glyph { font-size: 22px; color: var(--gold); font-family: "Segoe UI Symbol", "DejaVu Sans", serif; }
.fiche-head .val { margin-left: auto; font-size: 18px; color: #8ee34b; white-space: nowrap; }
.fiche-body { display: flex; gap: 8px; align-items: flex-start; }
.fiche-body p { margin: 0; font-size: 19px; line-height: 1.1; color: #ddd; flex: 1; }
.fiche-body p em { color: #ffff7a; font-style: normal; }
.mini-board { flex: none; display: grid; grid-template-columns: repeat(7, 9px); grid-template-rows: repeat(7, 9px); border: 2px solid #000; }
.mini-board i { display: block; background: #d9c48f; position: relative; }
.mini-board i.dk { background: #6b4527; }
.mini-board i.pc { background: var(--gold); box-shadow: inset 0 0 0 1px #000; }
.mini-board i.mv::after, .mini-board i.op::after, .mini-board i.cp::after { content: ''; position: absolute; inset: 2px; background: #58e05a; box-shadow: 0 0 4px #58e05a; }
.mini-board i.op::after { opacity: .45; }
.mini-board i.cp::after { background: #ff4848; box-shadow: 0 0 4px #ff4848; }
.fiche-note { font-size: 20px; margin: 12px 0 0; color: #ddd; }
.fiche-box { width: min(760px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.fiche-box .fiche-card { animation: none; }

.piece-tip {
  position: fixed; z-index: 25; pointer-events: none; background: rgba(10, 10, 18, .92); border: 2px solid #000;
  box-shadow: inset 0 0 0 2px #555; padding: 6px 10px; font-size: 20px; max-width: 280px; opacity: 0; transition: opacity .15s;
  transform: translate(16px, 16px);
}
.piece-tip.show { opacity: 1; }
.piece-tip b { font-family: var(--font-pixel); font-size: 10px; display: block; margin-bottom: 4px; color: var(--gold); }

@media (max-width: 760px) {
  .fiche { grid-template-columns: 1fr; }
  .fiche-card { grid-template-columns: 112px 1fr; }
  .fiche-card figure, .fiche-card figure img { width: 54px; }
  .fiche-card figure img { height: 54px; }
  .piece-tip { display: none; }
}

.piece-tip i { font-style: normal; color: #8ee34b; }

/* ---------- Archipel : choix de l'île ---------- */
.islands { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.island-btn { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; gap: 2px 10px; text-align: left; padding: 10px; align-items: center; }
.island-btn .isl-emoji { grid-row: 1 / 3; font-size: 30px; text-shadow: none; }
.island-btn .isl-label { font-size: 11px; color: var(--isl); text-shadow: 2px 2px #000; }
.island-btn .isl-name { font-family: var(--font-text); font-size: 19px; color: #fff; letter-spacing: 0; text-shadow: 1px 1px #000; }
.island-btn .isl-desc { grid-column: 1 / 3; font-family: var(--font-text); font-size: 16px; line-height: 1.05; color: #ddd; letter-spacing: 0; text-shadow: 1px 1px #000; }
.island-btn.active { background-color: #34303f; box-shadow: inset 0 0 0 3px var(--isl), inset 2px 2px 0 5px rgba(255,255,255,.08), 0 0 16px color-mix(in srgb, var(--isl) 60%, transparent); transform: translateY(-1px); }
.island-btn.active .isl-emoji { animation: islBounce .9s ease-in-out infinite alternate; }
@keyframes islBounce { to { transform: translateY(-3px) scale(1.1); } }
.mc-btn.play small { display: block; font-family: var(--font-text); font-size: 20px; letter-spacing: 0; margin-top: 6px; color: #e8ffe0; }

/* Grand écran : menu à gauche, l'île reste visible à droite */
@media (min-width: 900px) {
  #menu { pointer-events: none; justify-content: flex-start; align-items: stretch; padding: 0; overflow: hidden;
    background: linear-gradient(90deg, rgba(0,0,0,.5), rgba(0,0,0,.15) 42%, transparent 60%); }
  #menu .menu-wrap { pointer-events: auto; width: min(560px, 46vw); margin: 0 0 0 2.5vw; max-height: 100vh; overflow-y: auto; padding: 16px 8px 24px; scrollbar-width: thin; scrollbar-color: #666 transparent; }
  #menu .fiche { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .islands { grid-template-columns: 1fr; }
}

/* ---------- Multijoueur en ligne ---------- */
.menu-note { font-size: 19px; line-height: 1.15; color: #cfe8ff; margin: 6px 0 0; }
.invite-card { display: flex; gap: 12px; align-items: center; background: rgba(255, 156, 207, .15); border: 2px solid #ff9ccf; padding: 12px; font-size: 22px; line-height: 1.15; }
.invite-card b { color: #ff9ccf; }
.invite-emoji { font-size: 36px; animation: islBounce .8s ease-in-out infinite alternate; }
.link-btn { background: none; border: 0; color: #aaa; font-family: var(--font-text); font-size: 18px; text-decoration: underline; cursor: pointer; padding: 0; }
.link-btn:hover { color: #fff; }
.invite-row { display: flex; gap: 8px; margin-top: 10px; }
.invite-row .mc-input { font-size: 18px; min-width: 0; -webkit-user-select: all; user-select: all; }
.invite-code { font-size: 22px !important; }
.invite-code b { font-family: var(--font-pixel); font-size: 18px; color: var(--gold); letter-spacing: 4px; }
.wait-dots { color: #8ee34b; }
.wait-dots i { font-style: normal; animation: dots 1.2s infinite; }
.wait-dots i:nth-child(2) { animation-delay: .2s; } .wait-dots i:nth-child(3) { animation-delay: .4s; }
.online-only { display: none; }
#hud.online .online-only { display: inline-block; }
#hud.online #btn-undo, #hud.online #btn-hint { display: none; }
.pc-net { display: none; font-size: 16px; }
.pc-net.on { display: inline; color: #8ee34b; }
.pc-net.off { display: inline; color: #888; }
.emote-bar { position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 6px; background: var(--panel); border: 3px solid #000; box-shadow: inset 0 0 0 2px #555; }
.emote-bar button { font-size: 26px; background: none; border: 0; cursor: pointer; padding: 4px 6px; transition: transform .1s; }
.emote-bar button:hover { transform: scale(1.3); }
.emote-pop { position: fixed; z-index: 16; font-size: 54px; pointer-events: none; animation: emotePop 2.6s ease-out forwards; filter: drop-shadow(2px 3px 0 rgba(0,0,0,.5)); }
@keyframes emotePop {
  0% { transform: translate(-50%, 0) scale(.2); opacity: 0; }
  12% { transform: translate(-50%, 10px) scale(1.3); opacity: 1; }
  20% { transform: translate(-50%, 10px) scale(1); }
  75% { opacity: 1; }
  100% { transform: translate(-50%, 90px) scale(1); opacity: 0; }
}
@media (max-width: 760px) { .emote-bar { bottom: 58px; } .emote-bar button { font-size: 22px; } }

/* ---------- Chat en ligne ---------- */
.chat { position: absolute; left: 12px; top: 110px; width: 270px; max-height: calc(100% - 200px); display: flex; flex-direction: column; padding: 10px; }
.chat-head { display: flex; justify-content: space-between; align-items: center; font-family: var(--font-pixel); font-size: 10px; color: var(--gold); margin-bottom: 6px; }
.chat-close { background: none; border: 0; color: #ccc; font-size: 20px; cursor: pointer; line-height: 1; padding: 0 4px; }
.chat-close:hover { color: #fff; }
.chat-list { list-style: none; margin: 0; padding: 0 2px 0 0; overflow-y: auto; flex: 1; min-height: 60px; max-height: 40vh; scrollbar-width: thin; scrollbar-color: #666 transparent; display: flex; flex-direction: column; gap: 6px; }
.chat-list li { max-width: 88%; padding: 4px 8px 5px; border: 2px solid #000; font-size: 20px; line-height: 1.1; word-wrap: break-word; overflow-wrap: anywhere; animation: chatIn .25s ease-out; -webkit-user-select: text; user-select: text; }
.chat-list li.them { align-self: flex-start; background: #3a2f4d; box-shadow: inset 0 0 0 2px #6b4f96; }
.chat-list li.me { align-self: flex-end; background: #2f4d2a; box-shadow: inset 0 0 0 2px #4f8a2a; }
.chat-list li.pending { opacity: .6; }
.chat-list li .who { display: block; font-size: 15px; color: #bbb; margin-bottom: 1px; }
.chat-list li .who time { float: right; margin-left: 8px; color: #888; }
.chat-list li.chat-empty { align-self: center; background: none; border: 0; box-shadow: none; color: #888; font-size: 18px; }
@keyframes chatIn { from { transform: translateY(8px); opacity: 0; } }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form .mc-input { font-size: 20px; padding: 4px 8px; min-width: 0; }
.chat-btn { position: relative; }
.chat-badge { position: absolute; top: -8px; right: -8px; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px; background: #e03c3c; border: 2px solid #000;
  font-family: var(--font-text); font-size: 16px; line-height: 16px; color: #fff; text-shadow: none; animation: pulse 1s infinite; }
@media (max-width: 760px) {
  .chat { top: auto; bottom: 64px; left: 8px; right: 8px; width: auto; max-height: 45vh; z-index: 2; }
  .chat-list { max-height: 28vh; }
}
