/* Giao diện kiểu game: cảnh 3D toàn màn hình, HUD nổi, bảng kính mờ. */
:root {
  --panel: rgba(9, 30, 48, 0.82);
  --panel-solid: #0f2c44;
  --panel-2: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f2f8fc;
  --muted: #a9c3d3;
  --gold: #ffc531;
  --gold-dark: #c47f00;
  --sea: #1fb6e0;
  --sea-dark: #0b6f93;
  --good: #3ddc84;
  --bad: #ff5a5a;
  --radius: 16px;
  --font: "Baloo 2", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden;
  font-family: var(--font); color: var(--text); background: #0b2233;
  line-height: 1.35; user-select: none; -webkit-user-select: none;
}
a { color: var(--gold); }
h2 { margin: 0; font-size: 1.35rem; font-weight: 800; }
h3 { margin: 16px 0 8px; font-size: 1.05rem; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.spacer { flex: 1; }
code, kbd { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; font-size: 0.85em; }

/* ---------- Cảnh ---------- */
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
.vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 10, 20, 0.45) 100%);
}

/* ---------- Khung kính ---------- */
.glass {
  background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ---------- HUD trên ---------- */
.top-hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  pointer-events: none;
}
.top-hud > * { pointer-events: auto; }
.profile {
  display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 999px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.avatar {
  position: relative; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.5rem;
  background: radial-gradient(circle at 35% 30%, #5fd4f5, #0b6f93);
  border: 3px solid var(--gold);
}
.avatar .lv {
  position: absolute; bottom: -6px; right: -8px; min-width: 24px; height: 24px; padding: 0 5px;
  border-radius: 12px; background: var(--gold); color: #3b2500; font-weight: 800; font-size: 0.85rem;
  display: grid; place-items: center; border: 2px solid #fff6d6;
}
.pname { font-weight: 800; font-size: 0.95rem; white-space: nowrap; }
.ptitle { color: var(--gold); font-size: 0.8rem; }
.xpbar {
  position: relative; width: 140px; height: 14px; border-radius: 99px; margin-top: 2px;
  background: rgba(0, 0, 0, 0.45); overflow: hidden; border: 1px solid var(--line);
}
.xpbar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd65a, #ff9f1c); transition: width .5s; }
.xpbar em { position: absolute; inset: 0; font-style: normal; font-size: 0.68rem; font-weight: 700; text-align: center; line-height: 14px; text-shadow: 0 1px 2px #000; }

.zone-pill {
  margin: 0 auto; padding: 8px 18px; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 800; font-size: 1rem; color: var(--text);
  background: linear-gradient(180deg, rgba(31, 182, 224, 0.9), rgba(11, 111, 147, 0.9));
  border: 2px solid rgba(255, 255, 255, 0.35); box-shadow: 0 4px 0 #064a63, 0 6px 16px rgba(0, 0, 0, 0.3);
}
.zone-pill:active { transform: translateY(2px); box-shadow: 0 2px 0 #064a63; }
.resources { display: flex; gap: 6px; }
.res {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 999px; font-size: 0.95rem; white-space: nowrap;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.res b { font-weight: 800; }

/* ---------- Menu trái ---------- */
.side-menu {
  position: fixed; left: calc(12px + env(safe-area-inset-left)); top: 50%; transform: translateY(-50%); z-index: 5;
  display: flex; flex-direction: column; gap: 10px;
}
.side-menu button {
  position: relative; width: 64px; padding: 6px 2px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  font: inherit; color: var(--text); background: var(--panel); border: 2px solid var(--line); border-radius: 16px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
.side-menu button:hover { border-color: var(--gold); }
.side-menu button:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.side-menu .ico { font-size: 1.55rem; line-height: 1.1; }
.side-menu .lbl { font-size: 0.68rem; font-weight: 700; white-space: nowrap; }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--bad); color: #fff; font-size: 0.75rem; font-weight: 800; font-style: normal;
  display: grid; place-items: center; border: 2px solid #fff; animation: bob 1.2s ease-in-out infinite;
}
.badge.blue { background: var(--sea-dark); animation: none; }
.badge.gray { background: #64748b; animation: none; }
.badge[hidden] { display: none; }
@keyframes bob { 50% { transform: translateY(-3px); } }

/* ---------- Thông báo giữa ---------- */
.banner {
  position: fixed; left: 50%; top: 32%; z-index: 6; transform: translate(-50%, -50%) scale(0.6);
  font-size: clamp(1.8rem, 6vw, 3.4rem); font-weight: 800; letter-spacing: 1px; text-align: center; white-space: nowrap;
  color: #fff; -webkit-text-stroke: 2px rgba(0, 0, 0, 0.35);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 0 24px rgba(255, 200, 60, 0.6);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.banner.gold { color: var(--gold); }
.banner.red { color: #ff7070; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 0 24px rgba(255, 60, 60, 0.6); }
.banner.green { color: #7dffb0; }
.banner small { display: block; font-size: 0.42em; letter-spacing: 0; -webkit-text-stroke: 0; color: #fff; }
.hint-line {
  position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 4;
  max-width: min(560px, calc(100vw - 32px)); padding: 6px 16px; border-radius: 999px; text-align: center;
  background: rgba(0, 0, 0, 0.45); font-weight: 600; pointer-events: none;
}
.hint-line:empty { display: none; }

/* ---------- Bảng kéo cá ---------- */
.fight-hud {
  position: fixed; top: calc(76px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 5;
  width: min(440px, calc(100vw - 110px)); padding: 10px 14px;
  background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.fight-hud[hidden] { display: none; }
.fh-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.fh-dist { margin-left: auto; font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.fh-lives { font-size: 1rem; letter-spacing: 1px; }
.meter-row { display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 700; margin-top: 4px; }
.meter-row em { font-style: normal; color: var(--gold); font-size: 0.78rem; }
.meter { position: relative; height: 16px; border-radius: 99px; background: rgba(0, 0, 0, 0.5); overflow: hidden; border: 1px solid var(--line); }
.meter span { display: block; height: 100%; width: 0; border-radius: 99px; }
.meter.stamina span { background: linear-gradient(90deg, #ff7a45, #ffb547); transition: width .3s; }
.meter.tension { background: linear-gradient(90deg, rgba(61, 220, 132, 0.25) 0 60%, rgba(255, 197, 49, 0.25) 60% 85%, rgba(255, 90, 90, 0.35) 85%); }
.meter.tension span { background: linear-gradient(90deg, #3ddc84, #ffc531 70%, #ff5a5a); }
.fight-hud.danger { animation: danger .25s linear infinite alternate; border-color: var(--bad); }
@keyframes danger { to { box-shadow: 0 0 22px rgba(255, 70, 70, 0.8); } }

/* ---------- Thanh lực ---------- */
.power {
  position: fixed; right: calc(150px + env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom)); z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.power[hidden] { display: none; }
.power-track {
  position: relative; width: 30px; height: 190px; border-radius: 16px; overflow: hidden;
  background: rgba(0, 0, 0, 0.55); border: 3px solid rgba(255, 255, 255, 0.7);
}
.power-perfect { position: absolute; left: 0; right: 0; bottom: 82%; height: 13%; background: rgba(61, 220, 132, 0.55); border-block: 2px solid #7dffb0; }
#power-fill { position: absolute; left: 3px; right: 3px; bottom: 3px; border-radius: 10px; background: linear-gradient(0deg, #1fb6e0, #ffc531 70%, #ff5a5a); }
.power-label { font-weight: 800; font-size: 0.8rem; text-shadow: 0 1px 3px #000; }

/* ---------- HUD dưới ---------- */
.bottom-hud {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: flex-end; gap: 12px;
  padding: 0 calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  pointer-events: none;
}
.bottom-hud > * { pointer-events: auto; }
.gear { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 70%; }
.gear-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--text); background: var(--panel); border: 2px solid var(--line); border-radius: 999px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.gear-chip:hover { border-color: var(--gold); }
.gear-chip.on { border-color: var(--good); background: rgba(31, 120, 70, 0.75); }
.gear-chip:disabled { opacity: 0.5; cursor: default; }
.odds { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.odds span { padding: 1px 8px; border-radius: 99px; font-size: 0.72rem; font-weight: 700; background: rgba(0, 0, 0, 0.5); border: 1px solid; }

.action {
  margin-left: auto; width: 128px; height: 128px; border-radius: 50%; cursor: pointer; touch-action: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font: inherit; color: #3b2500; border: 4px solid #fff6d6;
  background: radial-gradient(circle at 40% 30%, #ffe27a, #ffb21e 60%, #e48a00);
  box-shadow: 0 7px 0 var(--gold-dark), 0 12px 28px rgba(0, 0, 0, 0.45);
  transition: transform .08s, box-shadow .08s, filter .2s;
}
.action .action-ico { font-size: 2.6rem; line-height: 1; }
.action .action-lbl { font-size: 0.8rem; font-weight: 800; line-height: 1.1; text-align: center; padding: 0 10px; }
.action.pressed { transform: translateY(5px); box-shadow: 0 2px 0 var(--gold-dark), 0 6px 14px rgba(0, 0, 0, 0.45); }
.action.hook { background: radial-gradient(circle at 40% 30%, #ff9a9a, #ff3b3b 60%, #b31212); color: #fff; box-shadow: 0 7px 0 #7a0b0b, 0 0 30px rgba(255, 60, 60, 0.8); animation: pulse .35s ease-in-out infinite alternate; }
.action.reel { background: radial-gradient(circle at 40% 30%, #8ff0ff, #1fb6e0 60%, #0b6f93); color: #fff; box-shadow: 0 7px 0 #064a63, 0 12px 28px rgba(0, 0, 0, 0.45); }
.action.reel.pressed { box-shadow: 0 2px 0 #064a63; }
.action.wait, .action:disabled { filter: grayscale(0.7) brightness(0.8); cursor: default; }
@keyframes pulse { to { transform: scale(1.08); } }

/* ---------- Bảng (sheet) ---------- */
.sheet, .dlg {
  border: 2px solid var(--line); color: var(--text); padding: 0;
  background: linear-gradient(180deg, rgba(18, 52, 78, 0.97), rgba(9, 30, 48, 0.97));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
.sheet { width: min(860px, calc(100vw - 20px)); max-height: min(86vh, 900px); border-radius: 22px; overflow: hidden; display: none; flex-direction: column; }
.sheet[open] { display: flex; animation: rise .25s cubic-bezier(.3, 1.4, .5, 1); }
.sheet::backdrop, .dlg::backdrop { background: rgba(2, 12, 22, 0.55); backdrop-filter: blur(2px); }
@keyframes rise { from { transform: translateY(30px) scale(.96); opacity: 0; } }
.sheet > header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px;
  background: linear-gradient(180deg, #1fb6e0, #0b6f93); border-bottom: 3px solid #064a63;
}
.sheet > header h2 { text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.close {
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font: inherit; font-weight: 800; font-size: 1.1rem;
  color: #fff; background: #e23b3b; border: 2px solid #fff; box-shadow: 0 3px 0 #8a1010;
}
.sheet-body { overflow: auto; padding: 14px 16px 20px; user-select: text; -webkit-user-select: text; }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  padding: 8px 16px; border-radius: 12px; font: inherit; font-weight: 700; color: var(--text);
  background: rgba(255, 255, 255, 0.1); border: 2px solid var(--line); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}
.btn:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.4); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.gold { color: #3b2500; background: linear-gradient(180deg, #ffe27a, #ffb21e); border-color: #fff1bf; box-shadow: 0 4px 0 var(--gold-dark); }
.btn.sea { color: #fff; background: linear-gradient(180deg, #45cdf0, #0b8fb8); border-color: #a9ecff; box-shadow: 0 4px 0 #064a63; }
.btn.danger { color: #ffb4b4; }
.btn.small { padding: 5px 10px; font-size: 0.9rem; }
.btn.big { padding: 12px 24px; font-size: 1.1rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.row.center { justify-content: center; }
select, textarea {
  font: inherit; color: var(--text); background: rgba(0, 0, 0, 0.35);
  border: 2px solid var(--line); border-radius: 10px; padding: 7px 10px;
}
textarea { width: 100%; resize: vertical; font-family: ui-monospace, monospace; font-size: 0.88rem; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin-top: 12px; }
.howto { padding-left: 20px; margin: 0; }
.howto li { margin-bottom: 4px; }

/* ---------- Thẻ ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.card { background: var(--panel-2); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.cards .card { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.card .title { font-weight: 800; font-size: 1.02rem; }
.card.done { border-color: var(--good); box-shadow: 0 0 16px rgba(61, 220, 132, 0.25); }
.card.owned { border-style: dashed; }
.card .actions { margin-top: auto; display: flex; gap: 6px; align-items: center; }
.progress { height: 12px; border-radius: 99px; background: rgba(0, 0, 0, 0.45); overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, #45cdf0, #1fb6e0); }
.card.done .progress span { background: linear-gradient(90deg, #7dffb0, #3ddc84); }

.zone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.zone-card {
  position: relative; overflow: hidden; border-radius: 18px; padding: 14px; min-height: 160px;
  display: flex; flex-direction: column; gap: 4px; border: 3px solid rgba(255, 255, 255, 0.25); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.zone-card.current { border-color: var(--gold); box-shadow: 0 0 20px rgba(255, 197, 49, 0.5); }
.zone-card .zi { font-size: 2.2rem; line-height: 1; }
.zone-card .zn { font-size: 1.2rem; font-weight: 800; }
.zone-card .zd { font-size: 0.85rem; }
.zone-card .actions { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.zone-card.locked::after { content: "🔒"; position: absolute; right: 12px; top: 10px; font-size: 1.6rem; }

.fish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.fish-card {
  position: relative; border: 3px solid var(--line); border-radius: 16px; padding: 10px; text-align: center;
  background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.15));
}
.fish-card .emoji { font-size: 2.4rem; line-height: 1.2; }
.fish-card .name { font-weight: 800; font-size: 0.95rem; }
.fish-card .meta { font-size: 0.78rem; color: var(--muted); }
.fish-card.unknown .emoji { filter: grayscale(1) brightness(0); opacity: 0.35; }
.fish-card button { margin-top: 6px; }
.rarity-tag {
  display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: 0.75rem; font-weight: 800; color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); white-space: nowrap;
}
.dex-zone { margin-bottom: 18px; }
.dex-zone h3 { display: flex; gap: 8px; align-items: center; }
.inventory { display: flex; flex-wrap: wrap; gap: 8px; }
.inventory .chip { display: inline-flex; gap: 6px; padding: 5px 12px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); }

.review-list { display: flex; flex-direction: column; gap: 8px; }
.review-item { background: var(--panel-2); border: 1px solid var(--line); border-left: 5px solid var(--bad); border-radius: 12px; padding: 10px 14px; }
.review-item .ans { color: var(--good); font-weight: 800; }
.subject-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; border: 2px solid var(--line); cursor: pointer; }
.pill:has(input:checked) { background: rgba(31, 182, 224, 0.3); border-color: var(--sea); font-weight: 800; }

/* ---------- Câu hỏi ---------- */
.dlg { width: min(600px, calc(100vw - 20px)); border-radius: 22px; padding: 18px; }
.dlg[open] { animation: rise .22s cubic-bezier(.3, 1.4, .5, 1); }
.qcard { border: 3px solid var(--gold); }
.q-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-step { font-weight: 800; color: var(--gold); }
.timer {
  min-width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; background: rgba(0, 0, 0, 0.35); border: 3px solid var(--sea);
}
.timer.low { border-color: var(--bad); color: #ff9a9a; animation: pulse .4s ease-in-out infinite alternate; }
.timebar { height: 8px; border-radius: 99px; background: rgba(0, 0, 0, 0.45); overflow: hidden; margin: 10px 0 12px; }
.timebar span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #45cdf0, #ffc531); transition: width .25s linear; }
.q-lead { margin: 0; color: var(--gold); font-weight: 700; }
.q-text { font-size: 1.45rem; margin: 6px 0 14px; user-select: text; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .choices { grid-template-columns: 1fr; } }
.choice {
  text-align: left; padding: 12px 14px; border-radius: 14px; font: inherit; font-size: 1.08rem; font-weight: 700; cursor: pointer;
  color: var(--text); background: rgba(255, 255, 255, 0.08); border: 2px solid var(--line); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
.choice:hover:not(:disabled) { border-color: var(--sea); background: rgba(31, 182, 224, 0.2); }
.choice .k {
  display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 8px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.35); color: var(--gold); font-size: 0.85rem;
}
.choice.hidden-choice { visibility: hidden; }
.choice.right { border-color: var(--good); background: rgba(61, 220, 132, 0.28); }
.choice.wrong { border-color: var(--bad); background: rgba(255, 90, 90, 0.28); }
.q-tools { display: flex; gap: 8px; margin-top: 14px; }
.explain { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 12px 0 0; text-align: left; user-select: text; }
.explain[hidden], [hidden] { display: none !important; }

/* ---------- Thẻ kết quả ---------- */
.result { text-align: center; overflow: hidden; }
.catch-stage { position: relative; height: 170px; display: grid; place-items: center; margin: -6px 0 4px; }
.catch-stage .rays {
  position: absolute; width: 300px; height: 300px; border-radius: 50%; opacity: 0.55;
  background: repeating-conic-gradient(var(--ray, #ffc531) 0 10deg, transparent 10deg 24deg);
  mask-image: radial-gradient(circle, #000 20%, transparent 68%); -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 68%);
  animation: spin 9s linear infinite;
}
.catch-stage .big-emoji { position: relative; font-size: 5.2rem; line-height: 1; animation: pop .55s ease-out; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.5)); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { 0% { transform: scale(.2) rotate(-25deg); opacity: 0; } 70% { transform: scale(1.18); } 100% { transform: scale(1); opacity: 1; } }
.result h2 { font-size: 1.7rem; }
.result .stats { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.result .stat { min-width: 90px; padding: 6px 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); }
.result .stat b { display: block; font-size: 1.2rem; }
.result .gains { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0; }
.result .gains span { padding: 3px 10px; border-radius: 99px; background: rgba(255, 197, 49, 0.18); border: 1px solid rgba(255, 197, 49, 0.5); font-weight: 700; font-size: 0.9rem; }
.levelup { margin-top: 10px; padding: 10px; border-radius: 14px; background: linear-gradient(90deg, rgba(255, 197, 49, 0.3), rgba(255, 120, 30, 0.3)); font-weight: 800; }

.toast {
  position: fixed; left: 50%; top: calc(80px + env(safe-area-inset-top)); z-index: 50; transform: translate(-50%, -20px);
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 14px; text-align: center; font-weight: 700;
  background: rgba(9, 30, 48, 0.95); border: 2px solid var(--gold); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Điện thoại ---------- */
@media (max-width: 700px) {
  .top-hud { flex-wrap: wrap; gap: 6px; padding-inline: 10px; }
  .profile { padding: 4px 10px 4px 4px; }
  .avatar { width: 38px; height: 38px; font-size: 1.2rem; }
  .xpbar { width: 96px; }
  .pname { font-size: 0.82rem; }
  .ptitle, .hide-sm { display: none; }
  .resources { margin-left: auto; }
  .res { padding: 3px 9px; font-size: 0.85rem; }
  .zone-pill { order: 3; margin: 0 auto; padding: 5px 14px; font-size: 0.9rem; }
  .pills { order: 3; margin: 0 auto; }
  .side-menu { gap: 6px; top: auto; bottom: calc(150px + env(safe-area-inset-bottom)); transform: none; left: calc(8px + env(safe-area-inset-left)); }
  .side-menu button { width: 52px; padding: 4px 2px 2px; border-radius: 13px; }
  .side-menu .ico { font-size: 1.25rem; }
  .side-menu .lbl { font-size: 0.58rem; }
  .fight-hud { top: calc(118px + env(safe-area-inset-top)); width: calc(100vw - 20px); }
  .gear { max-width: calc(100% - 120px); }
  .gear-chip { padding: 4px 10px; font-size: 0.85rem; }
  .odds { display: none; }
  .action { width: 106px; height: 106px; }
  .action .action-ico { font-size: 2.1rem; }
  .action .action-lbl { font-size: 0.7rem; }
  .power { right: calc(126px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); }
  .power-track { height: 150px; }
  .hint-line { bottom: calc(132px + env(safe-area-inset-bottom)); font-size: 0.85rem; left: calc(50% + 28px); max-width: calc(100vw - 90px); }
  .catch-stage { height: 140px; }
  .catch-stage .big-emoji { font-size: 4.2rem; }
}
@media (max-height: 520px) {
  .side-menu { gap: 4px; }
  .side-menu button { width: 50px; padding: 2px; }
  .side-menu .lbl { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Hình cá & bảng xếp hạng ---------- */
.fish-art { display: block; margin: 0 auto; overflow: visible; }
.fish-card .art { height: 78px; display: grid; place-items: center; }
.fish-card.unknown .fish-art { filter: brightness(0) opacity(.35); }
.catch-stage .fish-art { position: relative; width: 240px; height: auto; animation: pop .55s ease-out, swim 2.4s ease-in-out .6s infinite; filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.5)); }
@keyframes swim { 50% { transform: translateY(-6px) rotate(-3deg); } }
.rank-pill { cursor: pointer; font: inherit; color: var(--text); background: linear-gradient(180deg, rgba(255, 197, 49, 0.35), rgba(196, 127, 0, 0.45)); border-color: rgba(255, 220, 120, 0.6); }
.side-menu .rank-btn { border-color: rgba(255, 197, 49, 0.7); background: linear-gradient(180deg, rgba(255, 197, 49, 0.35), rgba(9, 30, 48, 0.85)); }
.join-card { border-color: var(--gold); }
.nick-input { flex: 1; min-width: 180px; font: inherit; font-size: 1.05rem; font-weight: 700; color: var(--text); background: rgba(0, 0, 0, 0.35); border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; user-select: text; }
.nick-input:focus { outline: none; border-color: var(--gold); }
#nick-error { color: #ff9a9a; min-height: 1em; margin: 0; }
.rank-me { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 16px; background: linear-gradient(90deg, rgba(255, 197, 49, 0.28), rgba(31, 182, 224, 0.2)); border: 2px solid rgba(255, 197, 49, 0.6); }
.rank-me .big { font-size: 2rem; font-weight: 800; color: var(--gold); line-height: 1; }
.rank-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.rank-list li { display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: var(--panel-2); border: 2px solid transparent; }
.rank-list li.me { border-color: var(--gold); background: rgba(255, 197, 49, 0.16); }
.rank-list li.top1 { background: linear-gradient(90deg, rgba(255, 215, 0, 0.35), rgba(255, 255, 255, 0.05)); }
.rank-list li.top2 { background: linear-gradient(90deg, rgba(200, 210, 225, 0.32), rgba(255, 255, 255, 0.05)); }
.rank-list li.top3 { background: linear-gradient(90deg, rgba(205, 127, 50, 0.35), rgba(255, 255, 255, 0.05)); }
.rank-list .pos { font-size: 1.4rem; font-weight: 800; text-align: center; }
.rank-list .who b { display: block; font-size: 1.05rem; }
.rank-list .who span { font-size: 0.8rem; color: var(--muted); }
.rank-list .pts { text-align: right; font-weight: 800; color: var(--gold); font-size: 1.1rem; }
.rank-list .pts small { display: block; color: var(--muted); font-weight: 600; font-size: 0.72rem; }
@media (max-width: 700px) { .rank-pill { display: none; } }

/* ---------- Thanh trang bị & vật phẩm hỗ trợ ---------- */
.ico-art { display: block; flex: none; }
.gear-chip { padding: 3px 12px 3px 4px; }
.gear-chip .ico-art { margin: -2px 0; }
.boosts { display: flex; gap: 6px; }
.boost {
  position: relative; width: 50px; height: 50px; padding: 4px; cursor: pointer; border-radius: 14px;
  background: var(--panel); border: 2px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.boost .ico-art { width: 100%; height: 100%; }
.boost i {
  position: absolute; right: -5px; bottom: -5px; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px;
  background: #0b2233; border: 2px solid var(--line); font-style: normal; font-size: .72rem; font-weight: 800; display: grid; place-items: center;
}
.boost.on { border-color: var(--good); box-shadow: 0 0 0 3px rgba(61, 220, 132, .35), 0 0 18px rgba(61, 220, 132, .6); animation: bob 1s ease-in-out infinite; }
.boost.on::after { content: "✓"; position: absolute; left: -6px; top: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--good); color: #062; font-weight: 900; font-size: .8rem; display: grid; place-items: center; }
.boost:disabled { opacity: .4; cursor: default; }

/* ---------- Bản đồ thế giới ---------- */
.map-wrap { border-radius: 18px; overflow: hidden; border: 3px solid rgba(255, 255, 255, .25); box-shadow: inset 0 0 40px rgba(0, 0, 0, .35); }
.world-map { display: block; width: 100%; height: auto; font-family: var(--font); }
.map-node { cursor: pointer; transition: transform .15s; }
.map-node:focus { outline: none; }
.map-node .halo { fill: #ffc531; opacity: 0; }
.map-node.sel .halo { opacity: .45; animation: halo 1.4s ease-in-out infinite; }
.map-node.here .halo { fill: #4ade80; opacity: .4; }
.map-node.locked { filter: saturate(.3); }
.map-node:hover > circle:nth-of-type(2) { stroke: #ffc531; }
.map-node .boat { animation: bob 1.6s ease-in-out infinite; }
@keyframes halo { 50% { opacity: .15; } }
.world-map .swirl { animation: spin 14s linear infinite; transform-box: fill-box; transform-origin: center; }
.zone-info {
  display: flex; gap: 14px; align-items: flex-start; margin-top: 12px; padding: 14px; border-radius: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--sky) 35%, transparent), color-mix(in srgb, var(--water) 60%, transparent));
  border: 2px solid var(--line);
}
.zone-info .zi { font-size: 3rem; line-height: 1; }
.zone-info .zbody { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.zone-info .zn { font-size: 1.3rem; font-weight: 800; }
.zone-info .zfish { display: flex; flex-wrap: wrap; gap: 4px; }
.zone-info .zfish span { padding: 2px 4px; border-radius: 10px; background: rgba(0, 0, 0, .25); }
.zone-info .zfish .unknown .fish-art { filter: brightness(0) opacity(.4); }
.zone-info .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; }

/* ---------- Cửa hàng ---------- */
.tabs-row { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.tabs-row button {
  flex: 1; min-width: 120px; padding: 10px; border-radius: 14px; cursor: pointer; font: inherit; font-weight: 800; color: var(--text);
  background: rgba(255, 255, 255, .06); border: 2px solid var(--line);
}
.tabs-row button.active { background: linear-gradient(180deg, #45cdf0, #0b8fb8); border-color: #a9ecff; box-shadow: 0 4px 0 #064a63; }
.shop-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.shop-card {
  display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 18px;
  background: var(--panel-2); border: 2px solid var(--line);
}
.shop-card.owned { border-style: dashed; }
.shop-card.using { border-color: var(--good); box-shadow: 0 0 14px rgba(61, 220, 132, .25); }
.shop-icon { width: 76px; height: 76px; border-radius: 16px; display: grid; place-items: center; background: radial-gradient(circle at 40% 30%, rgba(255, 255, 255, .22), rgba(0, 0, 0, .25)); }
.shop-main { display: flex; flex-direction: column; gap: 4px; }
.shop-main .title { font-weight: 800; font-size: 1.05rem; }
.shop-act { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.stat-bar { display: grid; grid-template-columns: 92px 1fr; gap: 6px; align-items: center; font-size: .78rem; font-weight: 700; }
.stat-bar div { height: 8px; border-radius: 99px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.stat-bar i { display: block; height: 100%; border-radius: 99px; }
.inventory { gap: 10px; }
.inv-slot { position: relative; width: 62px; height: 62px; padding: 8px; border-radius: 14px; background: var(--panel-2); border: 2px solid var(--line); }
.inv-slot .ico-art { width: 100%; height: 100%; }
.inv-slot b { position: absolute; right: -4px; bottom: -4px; min-width: 22px; padding: 0 5px; border-radius: 11px; background: #0b2233; border: 2px solid var(--line); font-size: .75rem; text-align: center; }

/* ---------- Cá 4D ---------- */
.viewer-box { position: relative; width: 300px; height: 190px; display: grid; place-items: center; }
.viewer-box.big { width: min(520px, 86vw); height: 300px; }
.viewer-box .fish-viewer { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
.viewer-box .fish-viewer:active { cursor: grabbing; }
.viewer-box.live > .fish-art { visibility: hidden; }
.catch-stage .viewer-box .fish-art { width: 240px; }
.f4d-stage { position: relative; height: 300px; display: grid; place-items: center; }
.f4d-stage .rays {
  position: absolute; width: 380px; height: 380px; border-radius: 50%; opacity: .5;
  background: repeating-conic-gradient(var(--ray, #ffc531) 0 10deg, transparent 10deg 24deg);
  mask-image: radial-gradient(circle, #000 20%, transparent 68%); -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 68%);
  animation: spin 12s linear infinite;
}
.f4d { width: min(640px, calc(100vw - 20px)); }
.fish-card { position: relative; }
.view4d {
  position: absolute; right: 6px; top: 6px; z-index: 1; padding: 2px 8px; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 800; font-size: .75rem; color: #3b2500; background: linear-gradient(180deg, #ffe27a, #ffb21e);
  border: 2px solid #fff1bf; box-shadow: 0 3px 0 var(--gold-dark);
}
@media (max-width: 700px) {
  .boost { width: 42px; height: 42px; }
  .gear-chip span { display: none; }
  .gear-chip { padding: 3px; }
  .shop-list { grid-template-columns: 1fr; }
  .shop-card { grid-template-columns: 60px 1fr; }
  .shop-icon { width: 60px; height: 60px; }
  .shop-act { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
  .viewer-box { width: 260px; height: 170px; }
  .zone-info { flex-direction: column; }
}

/* ---------- Kỹ năng câu cá ---------- */
.skill-btn {
  --fx: #ffc531;
  position: relative; align-self: flex-end; margin-left: auto; margin-bottom: 10px;
  width: 92px; height: 92px; border-radius: 50%; cursor: pointer; touch-action: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font: inherit; color: #fff; border: 4px solid #fff;
  background: radial-gradient(circle at 40% 30%, color-mix(in srgb, var(--fx) 55%, #fff), var(--fx) 60%, color-mix(in srgb, var(--fx) 60%, #000));
  box-shadow: 0 6px 0 color-mix(in srgb, var(--fx) 45%, #000), 0 0 26px color-mix(in srgb, var(--fx) 80%, transparent);
  animation: skillPulse 1.2s ease-in-out infinite;
}
.skill-btn:not([hidden]) + .action { margin-left: 12px; }
.skill-btn[hidden] { display: none; }
.skill-btn .skill-ico { font-size: 2rem; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .4)); }
.skill-btn .skill-name { font-size: .66rem; font-weight: 800; text-shadow: 0 1px 2px #000; line-height: 1.1; text-align: center; padding: 0 6px; }
.skill-charges { position: absolute; bottom: -10px; display: flex; gap: 4px; }
.skill-charges i { width: 14px; height: 14px; border-radius: 50%; background: rgba(0, 0, 0, .6); border: 2px solid #fff; }
.skill-charges i.on { background: var(--fx); box-shadow: 0 0 8px var(--fx); }
.skill-btn.empty { filter: grayscale(.85) brightness(.75); animation: none; }
.skill-btn:disabled { filter: grayscale(.6) brightness(.7); animation: none; }
.skill-btn:active:not(:disabled) { transform: translateY(4px) scale(.96); }
@keyframes skillPulse { 50% { box-shadow: 0 6px 0 color-mix(in srgb, var(--fx) 45%, #000), 0 0 40px var(--fx); } }
.screen-flash { position: fixed; inset: 0; z-index: 4; pointer-events: none; opacity: 0; background: radial-gradient(circle at 60% 55%, color-mix(in srgb, var(--fx, #fff) 70%, transparent), transparent 65%); }
.screen-flash.go { animation: sflash .7s ease-out; }
@keyframes sflash { 0% { opacity: .95; } 100% { opacity: 0; } }
.skill-tag { display: inline-block; padding: 0 8px; border-radius: 99px; font-weight: 800; color: #0b2233; background: var(--fx); margin-right: 4px; }
@media (max-width: 700px) {
  .skill-btn { width: 76px; height: 76px; margin-bottom: 14px; }
  .skill-btn .skill-ico { font-size: 1.6rem; }
  .skill-btn .skill-name { font-size: .56rem; }
}

.skill-btn, .action { flex: none; }
@media (max-width: 700px) { .gear { max-width: calc(100% - 200px); } .boosts { flex-wrap: wrap; } }

/* ---------- Bộ đề ---------- */
.sheet.wide { width: min(1000px, calc(100vw - 20px)); }
.sheet-body input:not([type=checkbox]):not([type=radio]), .sheet-body select, .sheet-body textarea { user-select: text; }
.sheet-body input:not([type=checkbox]):not([type=radio]):not([type=file]) {
  font: inherit; color: var(--text); background: rgba(0, 0, 0, .35); border: 2px solid var(--line); border-radius: 10px; padding: 7px 10px; width: 100%;
}
.sheet-body input:focus, .sheet-body textarea:focus, .sheet-body select:focus { outline: none; border-color: var(--gold); }
.set-list { display: flex; flex-direction: column; gap: 8px; }
.set-card { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 16px; background: var(--panel-2); border: 2px solid var(--line); }
.set-card.off { opacity: .55; }
.set-card .title { font-weight: 800; font-size: 1.05rem; }
.set-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.code-pill { display: inline-block; padding: 0 8px; border-radius: 8px; background: rgba(255, 197, 49, .2); border: 1px solid var(--gold); color: var(--gold); font-weight: 800; letter-spacing: 1px; }
.toggle { position: relative; width: 50px; height: 28px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle i { position: absolute; inset: 0; border-radius: 99px; background: #475569; transition: background .2s; }
.toggle i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + i { background: var(--good); }
.toggle input:checked + i::after { transform: translateX(22px); }
.empty-sets ul { padding-left: 18px; margin: 6px 0 0; }
.fld { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 700; margin: 6px 0; }
.fld.grow { flex: 1; }
.fld.ok input { border-color: rgba(61, 220, 132, .6) !important; }
.fld.bad input { border-color: rgba(255, 90, 90, .45) !important; }
.fld-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.fld-row .fld { min-width: 140px; flex: 1; }
.q-form h3 { margin-top: 0; }
#q-form-err { color: #ff9a9a; }
details.card summary { cursor: pointer; }
.q-list { padding-left: 26px; display: flex; flex-direction: column; gap: 6px; }
.q-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--panel-2); }
.q-list li.editing { outline: 2px solid var(--gold); }
.ans-ok { color: var(--good); font-weight: 700; margin-right: 6px; }
.ans-bad { color: #ffb4b4; margin-right: 6px; }
.diff { padding: 1px 8px; border-radius: 99px; font-size: .75rem; font-weight: 800; }
.diff.d1 { background: rgba(61, 220, 132, .25); } .diff.d2 { background: rgba(59, 130, 246, .35); } .diff.d3 { background: rgba(245, 158, 11, .4); }
.q-acts { display: flex; gap: 4px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; border-radius: 16px; cursor: pointer; text-align: center; border: 3px dashed rgba(255, 255, 255, .3); background: rgba(0, 0, 0, .2); }
.drop.over, .drop:hover { border-color: var(--gold); background: rgba(255, 197, 49, .08); }
.drop-ico { font-size: 2.4rem; }
.warn { color: #fde68a; }
.gen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.gen { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; background: rgba(0, 0, 0, .2); border: 2px solid var(--line); }
.gen .title { font-weight: 800; }
.gen .btn { margin-top: auto; }
.gen.ai { grid-column: 1 / -1; border-color: rgba(255, 197, 49, .5); }
.review-gen { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.rv { padding: 10px; border-radius: 14px; background: var(--panel-2); border: 2px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.rv.off { opacity: .45; }
.rv.need { border-color: #f59e0b; }
.rv-head { display: flex; align-items: center; gap: 8px; }
.rv-head .src { margin-left: auto; font-size: .75rem; color: var(--muted); }
.rv-head .check { margin: 0; }
.rv-head select { padding: 2px 6px; }
.rv textarea { min-height: 54px; font-family: var(--font); font-size: .95rem; }
.rv-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.rv-opt { display: flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: 10px; border: 2px solid transparent; }
.rv-opt.right { border-color: var(--good); background: rgba(61, 220, 132, .15); }
.rv-opt input[type=radio] { accent-color: #3ddc84; width: 18px; height: 18px; flex: none; }
.rv-opt input:not([type=radio]) { padding: 4px 6px !important; }
.save-row { position: sticky; bottom: -20px; padding: 10px 0; background: linear-gradient(180deg, transparent, rgba(9, 30, 48, .97) 30%); align-items: flex-end; }
.code-input { text-transform: uppercase; letter-spacing: 4px; font-size: 1.4rem !important; max-width: 240px; text-align: center; }
.fetched { margin-top: 10px; border-color: var(--gold); }
@media (max-width: 700px) {
  .set-card { grid-template-columns: auto 1fr; }
  .set-acts { grid-column: 1 / -1; justify-content: flex-start; }
  .q-list li { grid-template-columns: 1fr auto; }
  .q-acts { grid-column: 1 / -1; }
  .rv-opts { grid-template-columns: 1fr; }
}

/* ---------- Thi đấu ---------- */
.side-menu .match-btn { border-color: rgba(239, 68, 68, .7); background: linear-gradient(180deg, rgba(239, 68, 68, .35), rgba(9, 30, 48, .85)); }
.match-hud {
  position: fixed; left: calc(90px + env(safe-area-inset-left)); top: calc(84px + env(safe-area-inset-top)); z-index: 5; width: 230px;
  padding: 8px 10px; border-radius: 14px; text-align: left; cursor: pointer; font: inherit; color: var(--text);
  background: var(--panel); border: 2px solid rgba(239, 68, 68, .6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.match-hud[hidden] { display: none; }
.match-hud.urgent { animation: danger .4s linear infinite alternate; }
.mh-top { display: flex; justify-content: space-between; font-size: .85rem; }
.mh-me { font-size: .78rem; color: var(--gold); font-weight: 700; margin: 2px 0 4px; }
.mh-team { display: grid; grid-template-columns: 1fr 60px auto; gap: 6px; align-items: center; font-size: .74rem; margin-top: 2px; }
.mh-team span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mh-team i { display: block; height: 7px; border-radius: 99px; min-width: 3px; }
.mh-team.mine span { font-weight: 800; color: var(--gold); }
.mode-pick, .team-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 10px; }
.mode-opt, .team-opt {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px; border-radius: 16px; cursor: pointer; text-align: center;
  font: inherit; color: var(--text); background: var(--panel-2); border: 3px solid var(--line);
}
.mode-opt span, .team-opt .ti { font-size: 2rem; }
.mode-opt small, .team-opt small { color: var(--muted); font-size: .75rem; }
.mode-opt.sel { border-color: var(--gold); background: rgba(255, 197, 49, .15); }
.team-opt { --tc: #fff; border-color: color-mix(in srgb, var(--tc) 50%, transparent); }
.team-opt.sel { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 22%, transparent); box-shadow: 0 0 16px color-mix(in srgb, var(--tc) 50%, transparent); }
.team-opt:disabled { opacity: .4; cursor: not-allowed; }
.team-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.team-names .fld { color: var(--tc); }
.match-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.match-head .title { font-size: 1.2rem; font-weight: 800; }
.big-code { font-size: 2rem; font-weight: 800; letter-spacing: 6px; color: var(--gold); padding: 4px 14px; border-radius: 14px; background: rgba(0, 0, 0, .35); border: 2px dashed var(--gold); }
.lobby { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 10px 0; }
.lobby-team { padding: 10px; border-radius: 14px; background: var(--panel-2); border: 3px solid var(--tc); }
.lt-head { font-weight: 800; color: var(--tc); margin-bottom: 6px; }
.lt-head small { color: var(--muted); }
.lt-p { padding: 4px 8px; border-radius: 8px; background: rgba(0, 0, 0, .25); margin-top: 4px; animation: rise .3s; }
.phase-pill { padding: 4px 12px; border-radius: 99px; font-weight: 800; background: rgba(0, 0, 0, .35); }
.phase-pill.running { color: #7dffb0; } .phase-pill.countdown { color: var(--gold); } .phase-pill.done { color: #ff9a9a; }
.team-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.tb { padding: 10px; border-radius: 14px; background: var(--panel-2); border-left: 6px solid var(--tc); }
.tb-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.tb-head .rank { font-weight: 800; color: var(--tc); font-size: 1.2rem; }
.tb-p { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; padding: 4px 8px; border-radius: 8px; font-size: .9rem; }
.tb-p.me { background: rgba(255, 197, 49, .18); }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 14px 0 6px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 150px; text-align: center; }
.pod-ico { font-size: 2.2rem; animation: pop .6s; }
.pod-bar { width: 100%; border-radius: 12px 12px 0 0; background: linear-gradient(180deg, var(--tc), color-mix(in srgb, var(--tc) 40%, #000)); }
.pod.p1 .pod-bar { height: 110px; } .pod.p2 .pod-bar { height: 75px; } .pod.p3 .pod-bar { height: 50px; }
.mvp { text-align: center; padding: 8px; border-radius: 12px; background: rgba(255, 197, 49, .15); border: 1px solid var(--gold); margin-bottom: 10px; }
.rep-q { display: flex; flex-direction: column; gap: 6px; }
.rq { display: grid; grid-template-columns: 30px 1fr 140px 48px 50px; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 10px; background: var(--panel-2); }
.rq-n { font-weight: 800; color: var(--gold); text-align: center; }
.rq-bar { height: 10px; border-radius: 99px; background: rgba(0, 0, 0, .4); overflow: hidden; }
.rq-bar i { display: block; height: 100%; }
.rep-t { width: 100%; border-collapse: collapse; font-size: .9rem; }
.rep-t th, .rep-t td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.rep-t th { color: var(--gold); }
.save-code { font-size: 1.8rem; font-weight: 800; letter-spacing: 4px; text-align: center; padding: 10px; border-radius: 14px; background: rgba(0, 0, 0, .35); border: 2px dashed var(--good); color: #7dffb0; user-select: all; }
@media (max-width: 700px) {
  .match-hud { left: auto; right: 8px; top: calc(118px + env(safe-area-inset-top)); width: 180px; }
  .rq { grid-template-columns: 26px 1fr 60px 40px; } .rq > span.muted { display: none; }
  .big-code { font-size: 1.4rem; letter-spacing: 3px; }
  .pod { width: 100px; }
}

/* Menu trái: không bao giờ đè lên thanh trang bị phía dưới – thu gọn và cuộn khi màn hình thấp. */
.side-menu {
  top: calc(80px + env(safe-area-inset-top)); transform: none;
  max-height: calc(100dvh - 80px - 170px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto; overflow-x: visible; scrollbar-width: none; padding: 6px 6px 6px 0;
}
.side-menu::-webkit-scrollbar { display: none; }
@media (max-height: 900px) {
  .side-menu { gap: 6px; }
  .side-menu button { width: 56px; padding: 3px 2px 2px; border-radius: 13px; }
  .side-menu .ico { font-size: 1.25rem; }
  .side-menu .lbl { font-size: .58rem; }
}
@media (max-height: 640px) { .side-menu .lbl { display: none; } .side-menu button { width: 46px; } }
@media (max-width: 700px) {
  .side-menu { top: calc(118px + env(safe-area-inset-top)); bottom: auto; max-height: calc(100dvh - 118px - 150px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}

/* ---------- Thế giới chung ---------- */
.world-pill { cursor: pointer; font: inherit; color: var(--text); background: linear-gradient(180deg, rgba(61, 220, 132, .3), rgba(9, 30, 48, .85)); border-color: rgba(61, 220, 132, .6); }
.emote-chip { font-size: 1.3rem; padding: 2px 10px; }
.emote-pop {
  position: absolute; bottom: 64px; left: 0; z-index: 8; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px;
  background: var(--panel); border: 2px solid var(--gold); border-radius: 18px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.emote-pop[hidden] { display: none; }
.emote-pop button {
  display: flex; flex-direction: column; align-items: center; gap: 0; width: 82px; padding: 6px 2px; border-radius: 12px; cursor: pointer;
  font: inherit; color: var(--text); background: rgba(255, 255, 255, .08); border: 2px solid transparent;
}
.emote-pop button:hover { border-color: var(--gold); }
.emote-pop span { font-size: 1.7rem; line-height: 1.1; }
.emote-pop small { font-size: .66rem; font-weight: 700; }
.gear { position: relative; }
.world-feed {
  position: fixed; right: calc(14px + env(safe-area-inset-right)); top: calc(70px + env(safe-area-inset-top)); z-index: 5;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: none; max-width: min(340px, 60vw);
}
.feed-item {
  padding: 6px 12px; border-radius: 14px; font-size: .88rem; background: var(--panel); border: 2px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: rise .3s; transition: opacity .7s, transform .7s;
}
.feed-item.out { opacity: 0; transform: translateX(30px); }
@media (max-width: 700px) {
  .world-feed { top: calc(170px + env(safe-area-inset-top)); max-width: 70vw; }
  .feed-item { font-size: .78rem; }
  .emote-pop { grid-template-columns: repeat(4, 1fr); left: -4px; }
  .emote-pop button { width: 70px; }
}

/* ---------- Trò chuyện ---------- */
.chat-panel {
  position: fixed; z-index: 7; right: calc(12px + env(safe-area-inset-right)); top: calc(70px + env(safe-area-inset-top));
  bottom: calc(110px + env(safe-area-inset-bottom)); width: min(360px, calc(100vw - 24px));
  display: flex; flex-direction: column; background: rgba(9, 30, 48, .95); border: 2px solid var(--line); border-radius: 18px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  user-select: text; -webkit-user-select: text; animation: rise .2s;
}
.chat-panel[hidden] { display: none; }
body.chat-open .world-feed { right: calc(384px + env(safe-area-inset-right)); }
.chat-top { display: flex; align-items: center; gap: 4px; padding: 8px 8px 4px; }
.chat-tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.chat-tabs button {
  position: relative; flex: 0 0 auto; font: inherit; font-weight: 700; font-size: .88rem; color: var(--muted); cursor: pointer;
  background: var(--panel-2); border: 2px solid transparent; border-radius: 12px; padding: 4px 10px;
}
.chat-tabs button.on { color: var(--text); border-color: var(--gold); background: rgba(255, 197, 49, .16); }
.chat-tabs button[hidden] { display: none; }
.chat-tabs .badge { top: -6px; right: -6px; }
.chat-top .close { background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }
.chat-sub { padding: 2px 12px 6px; font-size: .86rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.chat-sub b { color: var(--text); }
.chat-sub .ok { color: var(--good); }
.link { background: none; border: 0; color: var(--gold); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.chat-sub .link { float: right; }
.chat-list { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.chat-note { font-size: .74rem; color: var(--muted); text-align: center; padding: 2px 6px 6px; }
.chat-empty { margin: auto 0; text-align: center; color: var(--muted); font-size: .92rem; padding: 12px; display: grid; gap: 10px; justify-items: center; }
.msg { max-width: 86%; align-self: flex-start; background: rgba(255, 255, 255, .1); border-radius: 4px 14px 14px 14px; padding: 5px 10px 3px; }
.msg.mine { align-self: flex-end; background: rgba(31, 182, 224, .3); border-radius: 14px 4px 14px 14px; }
.msg .who { display: block; font-size: .78rem; color: var(--gold); }
.msg .txt { font-size: .95rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg .meta { font-size: .68rem; color: var(--muted); text-align: right; }
.msg .report { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .8rem; padding: 0 0 0 4px; opacity: .6; }
.msg .report:hover { color: var(--bad); opacity: 1; }
.chat-status { margin: 0 10px 4px; padding: 6px 10px; border-radius: 10px; font-size: .84rem; background: rgba(255, 90, 90, .18); border: 1px solid rgba(255, 90, 90, .5); }
.chat-status[hidden], #chat-compose[hidden] { display: none; }
.chat-quick { display: flex; gap: 4px; overflow-x: auto; padding: 4px 10px; scrollbar-width: none; }
.chat-quick button {
  flex: 0 0 auto; font: inherit; font-size: .78rem; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 9px; cursor: pointer;
}
.chat-form { display: flex; gap: 6px; align-items: center; padding: 4px 10px 10px; position: relative; }
.chat-form input {
  flex: 1; min-width: 0; font: inherit; font-size: .95rem; color: var(--text); background: rgba(0, 0, 0, .3); border: 2px solid var(--line);
  border-radius: 12px; padding: 7px 44px 7px 10px;
}
.chat-form input:focus { outline: none; border-color: var(--gold); }
.chat-form .count { position: absolute; right: 62px; font-size: .66rem; color: var(--muted); pointer-events: none; }
.join-row { display: flex; gap: 6px; }
.join-row input {
  width: 150px; font: inherit; text-transform: uppercase; letter-spacing: 2px; text-align: center; color: var(--text);
  background: rgba(0, 0, 0, .3); border: 2px solid var(--line); border-radius: 12px; padding: 6px 8px;
}
.mate-list { display: grid; gap: 6px; }
.mate {
  position: relative; display: flex; align-items: center; gap: 8px; font: inherit; color: var(--text); text-align: left; cursor: pointer;
  background: var(--panel-2); border: 2px solid transparent; border-radius: 12px; padding: 7px 10px;
}
.mate:hover { border-color: var(--gold); }
.mate small { margin-left: auto; color: var(--muted); }
.mate .badge { position: static; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #64748b; flex: 0 0 auto; }
.dot.on { background: var(--good); box-shadow: 0 0 6px var(--good); }
@media (max-width: 700px) {
  .chat-panel { left: 8px; right: 8px; width: auto; top: calc(60px + env(safe-area-inset-top)); bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.chat-open .side-menu, body.chat-open .world-feed { display: none; }
}

/* ---------- Ôn tập nhận thưởng & Cứu cá ---------- */
.practice-card { display: grid; gap: 10px; border: 2px solid rgba(255, 197, 49, .5); }
.practice-hero { display: flex; gap: 12px; align-items: center; }
.practice-hero .big { font-size: 2.6rem; }
.practice-hero .grow { flex: 1; }
.practice-stats, .pr-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; gap: 4px; align-items: center; padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); font-size: .85rem; }
.chip i { display: inline-block; width: 10px; height: 14px; border-radius: 3px; background: rgba(255, 255, 255, .15); }
.chip i.on { background: linear-gradient(180deg, #fff27a, #ffb300); box-shadow: 0 0 6px #ffc531; }
.pr-bar { margin: 8px 0 10px; }
.pr-bar .dot { width: 16px; height: 16px; border-radius: 50%; background: rgba(255, 255, 255, .15); border: 2px solid var(--line); }
.pr-bar .dot.ok { background: var(--good); }
.pr-bar .dot.no { background: var(--bad); }
.practice-dlg.rescue { border-color: var(--sea); }
.pr-reward { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; font-weight: 700; }
.pr-reward span { padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .08); animation: rise .3s; }
.pr-reward.ok span:first-child { background: rgba(61, 220, 132, .25); }
.pr-reward.no span:first-child { background: rgba(255, 90, 90, .25); }
.mastery { color: var(--gold); letter-spacing: 2px; font-size: .9rem; margin-left: 4px; }
.skill-energy { position: absolute; top: -8px; left: -8px; font-size: .72rem; font-weight: 800; padding: 1px 6px; border-radius: 999px; background: #ffc531; color: #3a2600; border: 2px solid #fff; }

/* ---------- Server lớp học ---------- */
.pills { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.server-pill {
  font: inherit; font-size: .78rem; font-weight: 700; color: var(--text); cursor: pointer; padding: 1px 12px; border-radius: 999px;
  background: rgba(9, 30, 48, .75); border: 1px solid var(--line); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.server-pill.in-server { background: linear-gradient(180deg, rgba(31, 182, 224, .45), rgba(9, 30, 48, .85)); border-color: rgba(127, 220, 246, .7); }
.server-pill.unsynced::after { content: " ⏳"; }
.server-list { display: grid; gap: 6px; }
.server-item {
  display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, .06);
  border: 2px solid transparent; font: inherit; color: var(--text); text-align: left; cursor: default;
}
button.server-item { cursor: pointer; }
.server-item > div, button.server-item { flex: 1; }
.server-item small { display: block; color: var(--muted); font-size: .78rem; }
.server-item.on { border-color: var(--gold); }
.server-found { border-top: 1px solid var(--line); margin-top: 10px; }
.enter-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.enter-grid label { display: grid; gap: 2px; font-size: .82rem; color: var(--muted); }
.enter-grid input, #srv-code {
  font: inherit; color: var(--text); background: rgba(0, 0, 0, .3); border: 2px solid var(--line); border-radius: 12px; padding: 6px 10px;
}
@media (max-width: 560px) { .enter-grid { grid-template-columns: 1fr; } }
.server-top { margin: 0; padding-left: 26px; display: grid; gap: 4px; }
.server-top li { padding: 3px 6px; border-radius: 8px; }
.server-top li.me { background: rgba(255, 197, 49, .16); }
.server-top .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #64748b; margin-right: 6px; }
.server-top .dot.on { background: var(--good); }
.world-now { border: 2px solid rgba(127, 220, 246, .5); }
.account-card { border: 2px solid rgba(255, 197, 49, .45); }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.auth-tabs button { font: inherit; font-weight: 700; color: var(--muted); background: rgba(255, 255, 255, .06); border: 2px solid transparent; border-radius: 10px; padding: 3px 12px; cursor: pointer; }
.auth-tabs button.on { color: var(--text); border-color: var(--gold); }
.enter-grid.four { grid-template-columns: 1fr 1fr 1fr 1fr auto; }
@media (max-width: 760px) { .enter-grid.four { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .enter-grid.four { grid-template-columns: 1fr; } }
