/* Math Adventure World — RO-inspired window UI (original art & styling) */

:root {
  --win-top: #e9f3ff;
  --win-bot: #c9def6;
  --win-border: #5d7ea8;
  --title-top: #7fa8de;
  --title-bot: #4f7cbc;
  --ink: #2a3446;
  --muted: #66758c;
  --gold: #e8a400;
  --green: #2f9e4f;
  --red: #d24a3c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Kanit", system-ui, sans-serif;
  color: var(--ink);
  background: #a8dcff;
  -webkit-user-select: none;
  user-select: none;
}

#world, #world canvas { position: fixed; inset: 0; display: block; }

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }

/* ---------- RO window ---------- */

.ro-win {
  background: linear-gradient(180deg, var(--win-top), var(--win-bot));
  border: 1px solid var(--win-border);
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7) inset, 0 3px 10px rgba(20, 40, 80, 0.35);
  overflow: hidden;
}

.ro-title, .win-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 8px;
  min-height: 22px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
  background: linear-gradient(180deg, var(--title-top), var(--title-bot));
  border-bottom: 1px solid #3d6299;
}

.ro-body { padding: 6px 8px; font-size: 13px; }

.ro-mini, .win-x {
  border: 1px solid #355a8d;
  background: linear-gradient(180deg, #ffffff, #cfe0f5);
  color: #355a8d;
  border-radius: 3px;
  width: 20px;
  height: 18px;
  padding: 0;
  font-size: 14px;
  line-height: 14px;
  font-weight: 800;
}
.ro-mini:hover, .win-x:hover { background: #fff; }

/* ---------- HUD ---------- */

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud .ro-win { position: absolute; pointer-events: auto; }

.basic-info { top: 10px; left: 10px; width: 220px; }
.bi-name { font-weight: 800; font-size: 15px; }
.bi-row { display: flex; justify-content: space-between; color: var(--muted); }
.bi-row b { color: var(--ink); }
.bi-bar {
  position: relative;
  margin-top: 4px;
  height: 13px;
  border: 1px solid #5d7ea8;
  background: #fff;
  border-radius: 2px;
  overflow: hidden;
}
#hudXpFill { height: 100%; width: 0; background: linear-gradient(180deg, #7ad0ff, #2c8de0); transition: width 0.5s; }
#hudXpText { position: absolute; inset: 0; font-size: 10px; line-height: 12px; text-align: center; font-weight: 600; }

.minimap-win { top: 10px; right: 10px; width: 170px; }
#minimap { display: block; width: 168px; height: 168px; image-rendering: pixelated; }

.quest-win { top: 214px; right: 10px; width: 170px; }
#objective { font-size: 12px; line-height: 1.45; }
#objective b { color: #b5420f; }

.chat-win { left: 10px; bottom: 10px; width: 380px; }
#chatLog {
  height: 112px;
  overflow-y: auto;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.55);
}
.chat-line { color: #2a3446; }
.chat-line.system { color: #2a6ab0; }
.chat-line.exp { color: #3d8a2b; }
.chat-line.gold { color: #c27c00; font-weight: 600; }
.chat-line.battle { color: #c0392b; }

.controls-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-30%);
  padding: 3px 12px;
  border-radius: 12px;
  background: rgba(20, 30, 50, 0.5);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- prompt & announce ---------- */

#prompt {
  position: fixed;
  transform: translate(-50%, -100%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border: 1px solid var(--win-border);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #d9e8fa);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  color: var(--ink);
  font-size: 13px;
  z-index: 5;
}
#prompt .key {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--title-bot);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}
.prompt-text { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.prompt-action { font-weight: 800; }
.prompt-object { font-size: 11px; color: var(--muted); }

#announce {
  position: fixed;
  top: 28%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: 54px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ffe36b;
  -webkit-text-stroke: 2px #8a4b00;
  text-shadow: 0 4px 0 #8a4b00, 0 0 24px rgba(255, 220, 90, 0.8);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
}
#announce.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#announce.world { color: #ffffff; -webkit-text-stroke: 2px #2c4f86; text-shadow: 0 4px 0 #2c4f86, 0 0 20px rgba(120, 180, 255, 0.8); }
#announce.small { font-size: 36px; }

/* ---------- touch ---------- */

#touch { position: fixed; inset: 0; pointer-events: none; }
#joystick {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.6);
  pointer-events: auto;
  touch-action: none;
}
#joyKnob {
  position: absolute;
  left: 35px;
  top: 35px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #cfe0f5);
  border: 2px solid var(--win-border);
}
#touch { z-index: 4; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#joystick { width: 140px; height: 140px; left: 28px; bottom: 28px; }
#joyKnob { left: 43px; top: 43px; width: 54px; height: 54px; }
.touch-btn {
  display: grid; place-items: center; align-content: center;
  border-radius: 50%;
  border: 2px solid var(--win-border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(207, 224, 245, 0.95));
  color: var(--title-bot);
  box-shadow: 0 3px 8px rgba(20, 40, 80, 0.3);
  pointer-events: auto;
  touch-action: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.touch-btn:active { transform: scale(0.92); filter: brightness(0.95); }
.touch-btn .ico { font-size: 28px; line-height: 1; }
.touch-btn .lbl { font-size: 11px; font-weight: 700; margin-top: 2px; }
.touch-pad { position: absolute; right: 24px; bottom: 28px; display: flex; align-items: flex-end; gap: 14px; }
.touch-btn.jump { width: 84px; height: 84px; }
.touch-btn.act { width: 76px; height: 76px; margin-bottom: 46px; }
.touch-btn.act.ready { background: linear-gradient(180deg, #fff7c2, #ffd23f); border-color: #b5420f; color: #7a3200; animation: actPulse 1s ease-in-out infinite; }
@keyframes actPulse { 50% { box-shadow: 0 0 0 8px rgba(255, 210, 63, 0.35), 0 3px 8px rgba(20, 40, 80, 0.3); } }
.touch-side { position: absolute; right: 24px; bottom: 190px; display: flex; flex-direction: column; gap: 10px; }
.touch-btn.small { width: 48px; height: 48px; font-size: 22px; font-weight: 800; }

/* on-screen controls mode (tablet / phone) */
body.touch .chat-win { display: none; }
body.touch .controls-hint { display: none; }
body.touch.chat-open .chat-win { display: block; left: 50%; transform: translateX(-50%); top: 10px; bottom: auto; width: min(420px, calc(100vw - 360px)); min-width: 260px; z-index: 5; }
body.touch #world canvas { touch-action: none; }
body.touch #prompt { font-size: 15px; padding: 6px 14px 6px 6px; }

/* ---------- panel (modal window) ---------- */

#panel {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 30, 60, 0.25);
  z-index: 20;
}
#panel.open { display: flex; }
#panel.lobby-mode { background: linear-gradient(180deg, rgba(160, 210, 255, 0.35), rgba(20, 40, 80, 0.35)); }
#panel.battle-mode { align-items: flex-end; background: transparent; pointer-events: none; padding-bottom: 102px; }
#panel.dialogue-mode { padding-bottom: 92px; }
#panel.battle-mode .panel-window { pointer-events: auto; width: min(640px, 100%); }

.panel-window {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  animation: pop 0.18s ease-out;
}
.win-title { font-size: 14px; min-height: 26px; padding: 3px 10px; }
.win-body { padding: 14px 16px; overflow-y: auto; font-size: 15px; }

@keyframes pop {
  from { transform: scale(0.94); }
  to { transform: scale(1); }
}

/* ---------- buttons ---------- */

.btn-ro {
  padding: 6px 16px;
  border: 1px solid #4a6c9c;
  border-radius: 4px;
  background: linear-gradient(180deg, #ffffff 0%, #dbe8f8 55%, #c3d6ef 100%);
  color: #23406b;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 1px 2px rgba(0, 0, 0, 0.2);
}
.btn-ro:hover:not(:disabled) { filter: brightness(1.06); }
.btn-ro:active:not(:disabled) { transform: translateY(1px); }
.btn-ro:disabled { opacity: 0.5; cursor: default; }
.btn-ro.primary { background: linear-gradient(180deg, #8cc4ff, #3f86d8); color: #fff; border-color: #2c5f9e; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
.btn-ro.danger { background: linear-gradient(180deg, #ff9e93, #d24a3c); color: #fff; border-color: #9c2f24; }
.btn-ro.ghost { background: rgba(255, 255, 255, 0.6); }
.btn-ro.big { padding: 9px 28px; font-size: 17px; }
.btn-ro.small { padding: 3px 10px; font-size: 13px; }

.action-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---------- lobby ---------- */

.lobby { padding: 18px 20px; overflow-y: auto; position: relative; }
.lobby-x {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid #355a8d; background: linear-gradient(180deg, #ffffff, #cfe0f5);
  color: #355a8d; font-size: 18px; font-weight: 900; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 6px rgba(20, 40, 80, 0.25);
}
.lobby-x:hover { background: #fff; color: #d23b3b; border-color: #d23b3b; transform: scale(1.08); }
.lobby-mode .panel-window { width: min(640px, 100%); }
.logo { text-align: center; line-height: 1; }
.logo span { display: block; font-weight: 800; }
.logo .l1 { font-size: 30px; color: #2c5f9e; letter-spacing: 1px; }
.logo .l2 { font-size: 44px; color: #ffcc33; -webkit-text-stroke: 1.5px #8a5a00; text-shadow: 0 3px 0 #8a5a00; letter-spacing: 6px; }
.subtitle { text-align: center; color: var(--muted); margin: 6px 0 14px; }

.creator { display: flex; gap: 18px; align-items: flex-start; }
.preview-box {
  flex: 0 0 200px;
  padding: 8px 4px;
  text-align: center;
  border: 1px solid var(--win-border);
  border-radius: 6px;
  background: radial-gradient(circle at 50% 75%, #b9e39b, #7cc456 60%, #5ea43e);
}
#chibiPreview { width: 192px; height: 264px; }
.preview-name { font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }
.rotate-row { display: flex; justify-content: center; gap: 8px; margin-top: 4px; }
.creator-fields { flex: 1; min-width: 0; }

.field-label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.text-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--win-border);
  border-radius: 4px;
  background: #fff;
  font-size: 15px;
  color: var(--ink);
}
.picker { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--win-border);
}
.swatch.selected { box-shadow: 0 0 0 3px #ff9f1a; }
.pick-text {
  padding: 3px 12px;
  border: 1px solid var(--win-border);
  border-radius: 12px;
  background: #fff;
  font-size: 13px;
  color: var(--ink);
}
.pick-text.selected { background: var(--title-bot); color: #fff; }

.lobby-stats { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; }
.lobby-stats .bar { flex: 1; }

/* ---------- shared content ---------- */

.bar { height: 10px; background: #fff; border: 1px solid #9db3d3; border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(180deg, #8de06b, #3aa55a); }
.bar-fill.warn { background: linear-gradient(180deg, #ffc46b, #e8862a); }

.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

h3 { margin: 14px 0 6px; font-size: 15px; color: #2c5f9e; }
.toggle-row { display: flex; gap: 8px; align-items: center; margin: 6px 0; font-size: 14px; }
.world-group { margin: 8px 0 2px; font-size: 13px; font-weight: 600; color: #b5420f; }
.mastery-list { display: grid; gap: 4px; }
.mastery-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }

.dialogue { display: flex; gap: 12px; align-items: flex-end; }
.npc-portrait {
  flex: 0 0 96px;
  width: 96px;
  height: 132px;
  object-fit: contain;
  border: 1px solid var(--win-border);
  border-radius: 6px;
  background: linear-gradient(180deg, #fdf6e3, #e7d7b0);
}
.bubble {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #b8c9e2;
  border-radius: 6px;
  background: #fff;
  font-size: 15px;
  line-height: 1.55;
}
.bubble p { margin: 4px 0 0; }
.npc-name { font-weight: 800; color: #2c5f9e; }

.objective-box, .locked-note, .example, .hint-box {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
}
.objective-box { background: #fff7d6; border: 1px solid #e8c766; }
.locked-note { background: #eef1f5; border: 1px solid #c3cbd6; text-align: center; }
.example { background: #eef6ff; border: 1px dashed #7fa8de; font-size: 17px; font-weight: 600; text-align: center; }
.hint-box { background: #fffbe8; border: 1px solid #f0d27a; }
.lesson-text { line-height: 1.6; margin-top: 0; }
.guided-try { margin-top: 12px; padding: 10px; background: rgba(255, 255, 255, 0.6); border-radius: 6px; }
.guided-prompt { margin: 0 0 8px; font-weight: 600; }
.input-row { display: flex; gap: 8px; margin-top: 10px; }
.answer-input { max-width: 180px; font-size: 18px; text-align: center; }

.feedback { min-height: 1.4em; margin-top: 8px; font-size: 14px; font-weight: 600; }
.feedback.correct { color: var(--green); }
.feedback.incorrect { color: var(--red); }

.round-indicator { font-size: 13px; color: var(--muted); }
.progress-dots { display: flex; gap: 4px; margin: 4px 0 8px; }
.progress-dots span { width: 18px; height: 6px; border-radius: 3px; background: #c7d5e8; }
.progress-dots span.done { background: #3aa55a; }
.progress-dots span.now { background: #3f86d8; }
.question-prompt { font-size: 20px; font-weight: 600; margin: 8px 0 12px; text-align: center; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.option-btn {
  padding: 10px;
  border: 1px solid #7fa0cc;
  border-radius: 5px;
  background: linear-gradient(180deg, #ffffff, #e3eefb);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
}
.option-btn:hover:not(:disabled) { background: #fff; border-color: #3f86d8; }
.option-btn:disabled { cursor: default; }
.option-btn.correct { background: linear-gradient(180deg, #d8f7d4, #9fe39a); border-color: var(--green); }
.option-btn.incorrect { background: linear-gradient(180deg, #ffe0dc, #f6a59b); border-color: var(--red); }

.result { text-align: center; }
.result h2 { margin: 4px 0 8px; font-size: 21px; color: #2c5f9e; }
.big-emoji { font-size: 52px; }
.xp-pill {
  display: inline-block;
  margin: 6px 0;
  padding: 4px 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffe58a, #f2b500);
  border: 1px solid #b07f00;
  font-weight: 800;
  color: #5b3a00;
}
.score-text { font-size: 32px; font-weight: 800; }
.breakdown { display: grid; gap: 4px; margin: 10px 0; text-align: left; }
.remediation { margin-top: 8px; }
.remediation .action-row { justify-content: center; }
.timer { text-align: right; font-weight: 800; color: var(--red); }

/* ---------- battle ---------- */

.battle { display: flex; gap: 14px; align-items: center; }
.battle-foe { flex: 0 0 110px; text-align: center; }
.battle-foe img { width: 100px; height: 100px; animation: wobble 1.2s ease-in-out infinite; }
.battle-foe img.defeated { animation: none; opacity: 0.3; filter: grayscale(1); }
.hp { font-size: 20px; color: #e8433f; letter-spacing: 2px; }
.hp span.lost { color: #c9cfd8; }
.battle-main { flex: 1; min-width: 0; }
.battle-main .question-prompt { margin: 4px 0 10px; }
.battle-main .action-row { margin-top: 8px; }
.battle-tip { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.battle-mode .win-body { padding: 10px 14px; }
.battle-mode .option-btn { padding: 7px; font-size: 17px; }

@keyframes wobble {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.06, 0.94) translateY(3px); }
}

/* ---------- load error ---------- */

#loadError { position: fixed; inset: 0; display: grid; place-items: center; z-index: 40; background: rgba(15, 30, 60, 0.4); }

/* ---------- responsive ---------- */

@media (max-width: 720px), (pointer: coarse) {
  .chat-win { display: none; }
  .controls-hint { display: none; }
  .basic-info { width: 170px; }
  .minimap-win { width: 122px; }
  #minimap { width: 120px; height: 120px; }
  .quest-win { top: 166px; width: 122px; }
  .creator { flex-direction: column; align-items: center; }
  .creator-fields { width: 100%; }
  .mastery-row { grid-template-columns: 100px 1fr auto; }
  .battle { flex-direction: column; }
  .battle-foe { display: flex; align-items: center; gap: 10px; flex: none; }
  .battle-foe img { width: 56px; height: 56px; }
  #panel.battle-mode { padding-bottom: 234px; }
}

/* ---------- bilingual text: English first, Thai translation beside it ---------- */
.th { font-size: calc(0.82em + 2pt); font-weight: 400; opacity: 0.78; margin-left: 0.4em; }
.th::before { content: "("; }
.th::after { content: ")"; }
/* In sentences and messages the Thai translation sits on its own line underneath. */
.bubble .th, .lesson-text .th, .example .th, .guided-prompt .th, .question-prompt .th,
.feedback .th, .hint-box .th, .objective-box .th, .locked-note .th, .chat-line .th,
#objective .th, .result p .th, .result h2 .th, .subtitle .th, .battle-tip .th, .remediation .th,
.muted .th, #announce .th, .toggle-row .th {
  display: block;
  margin-left: 0;
}
.bubble .th::before, .lesson-text .th::before, .example .th::before, .guided-prompt .th::before,
.question-prompt .th::before, .feedback .th::before, .hint-box .th::before, .objective-box .th::before,
.locked-note .th::before, .chat-line .th::before, #objective .th::before, .result p .th::before,
.result h2 .th::before, .subtitle .th::before, .battle-tip .th::before, .remediation .th::before,
.muted .th::before, #announce .th::before, .toggle-row .th::before,
.bubble .th::after, .lesson-text .th::after, .example .th::after, .guided-prompt .th::after,
.question-prompt .th::after, .feedback .th::after, .hint-box .th::after, .objective-box .th::after,
.locked-note .th::after, .chat-line .th::after, #objective .th::after, .result p .th::after,
.result h2 .th::after, .subtitle .th::after, .battle-tip .th::after, .remediation .th::after,
.muted .th::after, #announce .th::after, .toggle-row .th::after { content: none; }
.toggle-row .th { margin-left: 1.6em; }
.question-prompt .th { font-size: calc(0.7em + 2pt); margin-top: 2px; }
.bubble .th, .lesson-text .th, .example .th { margin-top: 3px; color: #4a5568; opacity: 1; }
.chat-line .th { font-size: calc(0.85em + 2pt); color: #6b7685; opacity: 1; }
#objective b .th { color: #b5420f; }
#announce .th { font-size: calc(0.42em + 2pt); -webkit-text-stroke: 0; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); opacity: 0.95; }
.ro-title .th, .win-title .th { opacity: 0.85; }
#announce { text-align: center; }
.controls-hint .hint-th { font-size: calc(0.88em + 2pt); opacity: 0.8; }
.bubble .npc-name .th { display: inline; margin-left: 0.4em; margin-top: 0; }

/* ---------- read-aloud buttons ---------- */
.speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-right: 6px;
  padding: 0;
  vertical-align: middle;
  font-size: 14px;
  line-height: 1;
  border: 1px solid #9fb6d8;
  border-radius: 50%;
  background: linear-gradient(#ffffff, #e3ecf9);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.speak-btn:hover { background: linear-gradient(#ffffff, #cfe0f7); border-color: #5b86c4; }
.speak-btn:active { transform: translateY(1px); }
.question-prompt .speak-btn { width: 30px; height: 30px; font-size: 16px; }
.feedback .speak-btn, .hint-box .speak-btn { width: 22px; height: 22px; font-size: 12px; }
.action-row.left { justify-content: flex-start; }

/* ---------- grade & subject cards ---------- */
.card-grid { display: grid; gap: 10px; margin: 10px 0; }
.card-grid.grades { grid-template-columns: repeat(4, 1fr); }
.card-grid.subjects { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pick-card {
  --accent: #3f86d8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 2px solid #b8c9e2;
  border-top: 5px solid var(--accent);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #eef4fc);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}
.pick-card:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(30, 60, 110, 0.18); }
.pick-card.selected { box-shadow: 0 0 0 3px #ff9f1a; }
.pick-card.locked { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.7); }
.pick-card .bar { width: 100%; margin-top: 4px; }
.card-big { font-size: 30px; font-weight: 800; color: #2c5f9e; line-height: 1.1; }
.card-icon { font-size: 30px; line-height: 1.2; font-weight: 800; color: var(--accent); }
.card-name { font-size: 15px; font-weight: 700; }
.card-world { font-size: 12px; color: var(--muted); }
.card-note { font-size: 12px; color: var(--muted); }
.card-name .th, .card-world .th, .card-note .th { display: block; margin-left: 0; }
.card-name .th::before, .card-name .th::after, .card-world .th::before, .card-world .th::after,
.card-note .th::before, .card-note .th::after { content: none; }
.course-tag { margin-left: 6px; padding: 0 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.25); font-size: 11px; font-weight: 600; }

/* ---------- answer explanation / worked solution ---------- */
.solution {
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid #b8d4a8;
  border-left: 4px solid #3aa55a;
  border-radius: 6px;
  background: #f4fbef;
  color: var(--ink);
  font-weight: 400;
  text-align: left;
}
.feedback.incorrect .solution { border-color: #f0c2bb; border-left-color: #e8862a; background: #fff8ef; }
.sol-head { font-weight: 800; color: #2c5f9e; margin-bottom: 4px; }
.sol-steps { margin: 0; padding-left: 22px; line-height: 1.55; }
.sol-steps li { margin: 2px 0; }
.sol-answer { margin-top: 6px; font-weight: 800; color: #1f7a3a; }
.sol-text { margin: 0; line-height: 1.55; }
.solution .th { display: block; margin-left: 0; font-size: calc(0.9em + 2pt); color: #4a5568; opacity: 1; }
.solution .th::before, .solution .th::after { content: none; }
.sol-head .th, .sol-answer .th { display: inline; margin-left: 0.4em; }
.solution .speak-btn { width: 22px; height: 22px; font-size: 12px; }

/* Long answer choices (subject questions) */
.options.long .option-btn { font-size: 15px; line-height: 1.35; }
.options.wide { grid-template-columns: 1fr; }
.options.long .option-btn .th { display: block; margin-left: 0; font-size: calc(0.85em + 2pt); }
.options.long .option-btn .th::before, .options.long .option-btn .th::after { content: none; }
.quest-options { margin-top: 12px; }

@media (max-width: 720px), (pointer: coarse) {
  .card-grid.grades { grid-template-columns: repeat(2, 1fr); }
  .options.long { grid-template-columns: 1fr; }
}

/* ---------- difficulty, points, items, keys ---------- */
.bi-wallet { align-items: center; margin-top: 4px; }
.bi-wallet b { color: #b5420f; }
.bag-btn { font-size: 13px; width: 24px; height: 20px; line-height: 18px; padding: 0; }
.bi-diff { font-size: 10px; color: var(--muted); text-align: right; margin-top: 2px; }
.card-grid.diffs { grid-template-columns: repeat(3, 1fr); }
.pick-card .mult { font-weight: 800; font-size: 18px; color: #b5420f; }
.pick-card.diff-easy { --accent: #3aa55a; }
.pick-card.diff-medium { --accent: #e8a13a; }
.pick-card.diff-hard { --accent: #d84a3a; }
.pts-pill, .drop-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.pts-pill { background: #fff3c4; color: #8a5a00; border: 1px solid #f2c14e; }
.drop-pill { background: #e9f3ff; color: #1f4f8a; border: 1px solid #9cc4f2; }
.loot { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; margin: 6px 0; }
.battle-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.my-hp { color: #e8433f; font-size: 15px; letter-spacing: 1px; }
.my-hp span.lost { color: #c9cfd8; }
.items { display: flex; gap: 4px; }
.item-btn { border: 1px solid #b9c4d6; background: linear-gradient(180deg, #fff, #e8eef8); border-radius: 6px; padding: 1px 6px; font-size: 15px; cursor: pointer; font-family: inherit; }
.item-btn b { font-size: 11px; margin-left: 2px; color: #3a3f4a; }
.item-btn:disabled { opacity: 0.4; cursor: default; }
.option-btn.removed { opacity: 0.25; text-decoration: line-through; }
.power-on { color: #e8a13a; }
.tier-label { font-size: 11px; font-weight: 700; color: var(--muted); }
.tier-label.tier-strong { color: #d0701a; }
.tier-label.tier-boss { color: #b58a00; }
.battle-foe img.tier-strong { filter: drop-shadow(0 0 6px #ff9a3a); transform: scale(1.08); }
.battle-foe img.tier-boss { filter: drop-shadow(0 0 10px #ffd23f); transform: scale(1.18); }
.key-shop { text-align: center; margin: 8px 0; }
.key-big { font-size: 44px; line-height: 1.1; }
.key-wallet { font-weight: 600; margin: 4px 0; }
.key-bar { max-width: 260px; margin: 6px auto; }
.key-note { color: #3a7a2a; font-size: 13px; }
.bag-top { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.bag-stat { flex: 1; text-align: center; background: #f4f7fc; border: 1px solid #d6deeb; border-radius: 8px; padding: 6px; display: flex; flex-direction: column; font-size: 12px; }
.bag-stat .big { font-size: 20px; font-weight: 800; }
.item-list { display: flex; flex-direction: column; gap: 6px; }
.item-row { display: flex; align-items: center; gap: 10px; border: 1px solid #d6deeb; border-radius: 8px; padding: 6px 10px; background: #fff; }
.item-row.empty { opacity: 0.5; }
.item-icon { font-size: 26px; }
.item-text { flex: 1; display: flex; flex-direction: column; }
.item-text small { color: var(--muted); }
.item-count { font-weight: 800; font-size: 16px; }
@media (max-width: 640px) {
  .card-grid.diffs { grid-template-columns: 1fr; }
}
.challenge-tag { display: block; width: fit-content; margin: 2px auto 0; padding: 1px 10px; border-radius: 999px; background: #ffe6dc; color: #b5420f; border: 1px solid #f2a07a; font-size: 12px; font-weight: 700; }
.type-label { font-size: 11px; font-weight: 700; color: #5a4a8a; }
.type-desc { margin: 0 0 4px; font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.35; }
.type-desc .en, .type-desc .th { display: inline; }
.type-desc .th::before { content: " · "; }
.battle-foe img.type-ghost { opacity: 0.88; }
.battle-foe img.fled { animation: none; opacity: 0; transform: translateY(-30px); transition: all 0.8s; }
.item-btn.blocked { text-decoration: line-through; }
.item-img { width: 40px; height: 40px; }

/* ---------- accounts, multiplayer, admin, dungeon ---------- */
.bi-tools { justify-content: flex-start; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.bi-tools .tool-btn { flex: none; }
.tool-btn { font-size: 15px; width: 30px; height: 26px; }
.tool-btn.admin { background: linear-gradient(#ffe48a, #f2b33d); }
.chat-online { font-size: 12px; font-weight: 600; color: #e9fff0; margin-left: auto; padding-right: 6px; }
.title-btns { display: inline-flex; gap: 3px; align-items: center; flex: none; }
.ro-title { cursor: default; user-select: none; }
#hud .ro-win[data-collapse] > .ro-title { cursor: pointer; }
/* Minimized HUD windows keep only their title bar. */
#hud .ro-win.minimized > :not(.ro-title) { display: none !important; }
#hud .ro-win.minimized > .ro-title { border-bottom: 0; }
#hud .basic-info.minimized { width: auto; }
#hud .ro-win.minimized > .ro-title > span:first-child { white-space: nowrap; }
#hud .chat-win.minimized { width: 200px; }
#hud .chat-win.minimized .chat-size, #hud .chat-win.minimized .chat-online { display: none; }
#hud .chat-win.minimized ~ .controls-hint { display: none; }
.chat-unread { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: #e5483b; color: #fff; font-size: 11px; line-height: 16px; text-align: center; text-shadow: none; }
.chat-unread[hidden] { display: none; }
.chat-size { width: 24px; height: 20px; font-size: 14px; line-height: 16px; margin-left: 2px; }
.chat-win.big { width: min(620px, calc(100vw - 20px)); z-index: 3; }
.chat-win.big #chatLog { height: min(48vh, 420px); font-size: 14px; }
.chat-win.big ~ .controls-hint { display: none; }
.chat-win.big .chat-form input { font-size: 15px; padding: 8px 10px; }
.chat-win.big .chat-form button { padding: 0 16px; font-size: 16px; }
body.touch.chat-open .chat-win.big { width: min(620px, calc(100vw - 300px)); }
.tool-btn.exit { background: linear-gradient(#e9ecf2, #b9c0cc); font-weight: 700; }
.tool-btn.guide { background: linear-gradient(#e3f0ff, #9cc4f5); }
.guide-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(20, 24, 40, 0.55); padding: 16px; }
.guide-overlay[hidden] { display: none; }
.guide-frame { width: min(1000px, 100%); height: min(860px, 100%); display: flex; flex-direction: column; overflow: hidden; }
.guide-frame iframe { flex: 1; width: 100%; border: 0; background: #eef3fb; }
.guide-frame .win-title { display: flex; align-items: center; gap: 10px; }
.guide-frame .win-title > span:first-child { flex: 1; }
.guide-newtab { font-size: 12px; color: inherit; opacity: 0.85; text-decoration: none; white-space: nowrap; }
.guide-newtab:hover { text-decoration: underline; opacity: 1; }
.login-guide { display: block; margin: 8px auto 0; }
.pw-result { border: 2px solid #f2c14e; background: #fff8e1; border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.pw-result p { margin: 4px 0; }
.pw-code code { font-size: 20px; letter-spacing: 2px; padding: 3px 10px; background: #fff; border: 1px dashed #c9a227; border-radius: 6px; user-select: all; }
.admin-guide-row { display: flex; justify-content: flex-end; margin: -4px 0 8px; }
@media (max-width: 600px) { .guide-overlay { padding: 0; } .guide-frame { height: 100%; border-radius: 0; } .guide-newtab span { display: none; } }
.tool-btn.help { background: linear-gradient(#ffd9d4, #f59a8f); }
.tool-btn.help.waiting { animation: actPulse 1s ease-in-out infinite; }
.help-head { color: #c0392b; margin: 4px 0 6px; }
.help-text { color: #6a3b00; }
.admin-table tr.needs-help td { background: #fff1ef; }
.help-waiting { color: #b5420f; font-weight: 700; }
.chat-form { display: flex; gap: 4px; padding: 4px 6px 6px; }
.chat-form input { flex: 1; min-width: 0; border: 1px solid #9fb3cf; border-radius: 6px; padding: 4px 8px; font: inherit; font-size: 13px; }
.chat-form input:disabled { background: #eef1f6; }
.chat-form button { border: 0; border-radius: 6px; background: #4b8fe0; color: #fff; padding: 0 10px; cursor: pointer; }
.chat-form button:disabled { background: #a9b6c8; cursor: default; }
.chat-line.player b { color: #1f5fa8; }
.chat-line.player.mine b { color: #b5420f; }
.chat-line.player small { color: #8a95a5; font-size: 0.75em; }
.chat-line.history { opacity: 0.6; }

.account-line { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; font-size: 14px; }
.btn-ro.small { padding: 3px 10px; font-size: 13px; }
.login-box { max-width: 360px; margin: 0 auto; }
.login-tabs, .admin-tabs { display: flex; gap: 4px; border-bottom: 2px solid #c9d6e8; margin-bottom: 10px; flex-wrap: wrap; }
.tab { border: 1px solid #c9d6e8; border-bottom: 0; background: #eef3fa; border-radius: 8px 8px 0 0; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; color: #3b4a60; }
.tab.active { background: #fff; color: #1f5fa8; font-weight: 600; box-shadow: 0 2px 0 #fff; }
.login-box .text-input { width: 100%; box-sizing: border-box; }
.login-error, .login-ok { margin: 8px 0; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.login-error { background: #fdecea; color: #a8321f; }
.login-ok { background: #e7f6ea; color: #23793a; }
.admin-note { background: #fff6d6; border: 1px solid #f0cf6a; border-radius: 8px; padding: 6px 10px; font-size: 13px; margin: 6px 0; }
.btn-ro.gold { background: linear-gradient(#ffe48a, #f2b33d); color: #6a4300; }

.admin-body { max-height: 60vh; overflow: auto; }
.admin-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.admin-row select { max-width: 100%; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; background: #eef3fa; padding: 6px; position: sticky; top: 0; }
.admin-table td { border-top: 1px solid #e1e8f2; padding: 6px; vertical-align: top; }
.admin-table tr.banned td { opacity: 0.5; text-decoration: line-through; }
.admin-actions { min-width: 150px; }
.admin-actions .btn-ro { margin: 1px; }
.status { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: #e1e8f2; }
.status.s-COMPLETED { background: #d8f2dc; color: #23793a; }
.status.s-UNLOCKED { background: #fff1cc; color: #8a5a00; }
.q-review { border: 1px solid #dbe4f0; border-radius: 10px; padding: 8px 10px; margin: 8px 0; background: #fbfdff; }
.q-prompt { font-weight: 600; }
.q-choices { margin: 6px 0; padding-left: 22px; }
.q-choices li.right { color: #23793a; font-weight: 700; }
.q-expl { font-size: 13px; color: #4a5768; margin-top: 4px; }
.quest-review { background: #fffaf0; border-color: #f0d9a8; }
.lvl { font-size: 11px; padding: 1px 6px; border-radius: 6px; margin-right: 4px; }
.lvl-easy { background: #d8f2dc; color: #23793a; }
.lvl-hard { background: #fde1dc; color: #a8321f; }

.card-grid.servers { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.quest-bar { display: block; width: 100%; height: 8px; margin-top: 4px; }
.quest-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 13px; }
.ok { color: #23793a; }
.quest-bar .bar-fill { display: block; }
.panel-window:has(.admin-tabs) { width: min(980px, 96vw); max-width: 96vw; }
.speak-btn.playing { background: linear-gradient(#ffe1dc, #ffb8a8); border-color: #d84a3a; animation: speakPulse 1s ease-in-out infinite; }
@keyframes speakPulse { 50% { box-shadow: 0 0 0 4px rgba(216, 74, 58, 0.25); } }

/* ---------- pets, pet battles, shop ---------- */
.el-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; color: #fff; background: var(--el); vertical-align: middle; }
.pet-img { width: 84px; height: 116px; object-fit: contain; }
.pet-img.small { width: 56px; height: 76px; }
.pet-img.flip { transform: scaleX(-1); }
.pet-card { display: flex; gap: 10px; align-items: center; border: 1px solid #d6deeb; border-radius: 10px; padding: 6px 10px; margin: 8px 0; background: #fff; }
.pet-card.active { border-color: #ff9f1a; box-shadow: 0 0 0 2px rgba(255, 159, 26, 0.35); }
.pet-info { flex: 1; min-width: 0; }
.pet-title { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pet-xp { margin: 4px 0; height: 7px; }
.pet-stats { font-size: 13px; }
.pet-skills { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.skill-chip { font-size: 12px; background: #eef3fa; border-radius: 8px; padding: 2px 7px; }
.skill-chip.locked { opacity: 0.45; }
.partner-tag { font-weight: 700; color: #b5420f; }
.empty-note { text-align: center; padding: 12px; background: #fffaf0; border: 1px dashed #f0d9a8; border-radius: 10px; margin: 8px 0; }
.trainer-list { display: flex; flex-direction: column; gap: 6px; }
.trainer-row { display: flex; align-items: center; gap: 10px; border: 1px solid #d6deeb; border-radius: 10px; padding: 4px 10px; background: #fff; }
.trainer-row.locked { opacity: 0.55; filter: grayscale(0.6); }
.trainer-img { width: 52px; height: 52px; border-radius: 50%; background: #e3ecf9; object-fit: cover; }
.trainer-info { flex: 1; }
.small { font-size: 12px; }
.gold { color: #c27c00; font-weight: 600; }

.pb-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: linear-gradient(#cfe8ff, #e8f7d8 60%, #bfe39a); border-radius: 12px; padding: 6px 10px; }
.pb-side { display: flex; align-items: center; gap: 8px; flex: 1; }
.pb-side.me { flex-direction: row-reverse; text-align: right; }
.pb-meta { flex: 1; min-width: 0; }
.pb-hp { height: 10px; margin-top: 4px; }
.pb-vs { font-weight: 800; font-size: 22px; color: #b5420f; }
.pb-side.hit .pet-img { animation: pbHit 0.5s; }
@keyframes pbHit { 20%, 60% { transform: translateX(-8px); filter: brightness(1.8) sepia(1) hue-rotate(-40deg); } 40%, 80% { transform: translateX(8px); } }
.pb-side.me.hit .pet-img { animation-name: pbHitMe; }
@keyframes pbHitMe { 20%, 60% { transform: scaleX(-1) translateX(-8px); filter: brightness(1.8) sepia(1) hue-rotate(-40deg); } 40%, 80% { transform: scaleX(-1) translateX(8px); } }
.pb-log { background: #1f2a3a; color: #e8eef8; border-radius: 8px; padding: 6px 10px; margin: 8px 0; font-size: 13px; min-height: 54px; max-height: 120px; overflow: auto; }
.pb-log .good { color: #9be89b; }
.pb-log .bad { color: #ffb0a0; }
.skill-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.skill-btn { border: 2px solid var(--el); border-left-width: 8px; border-radius: 10px; background: #fff; padding: 6px 10px; text-align: left; cursor: pointer; font: inherit; display: flex; flex-direction: column; }
.skill-btn:hover:not(:disabled) { background: #f4f8ff; transform: translateY(-1px); }
.skill-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.sk-name { font-weight: 600; }
.sk-meta { font-size: 12px; color: #5a6678; }
.pb-result { text-align: center; }
.pb-result.won h3 { color: #23793a; }

.shop-wallet { margin-left: auto; align-self: center; font-weight: 700; color: #b5420f; padding-right: 6px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.shop-grid.small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.shop-card { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; border: 1px solid #d6deeb; border-radius: 10px; padding: 8px; background: #fff; }
.shop-card .stars { color: #e8a13a; font-size: 12px; }
.shop-card.rarity-3 { background: linear-gradient(#fff, #f3eeff); }
.shop-card.rarity-4 { background: linear-gradient(#fff, #fff1d6); border-color: #f0c35a; }
.shop-card.costume { cursor: pointer; }
.shop-card.trying { box-shadow: 0 0 0 3px #4b8fe0; }
.shop-card.worn { border-color: #3aa55a; background: #f1fbf3; }
.costume-icon { font-size: 30px; }
.costume-layout { display: flex; gap: 12px; }
.costume-preview { display: flex; flex-direction: column; align-items: center; background: #eef3fa; border-radius: 12px; padding: 6px; }
.costume-list { flex: 1; min-width: 0; }
.panel-window:has(.shop-grid), .panel-window:has(.pb-field), .panel-window:has(.trainer-list), .panel-window:has(.pet-card) { width: min(820px, 96vw); max-width: 96vw; }
@media (max-width: 640px) {
  .costume-layout { flex-direction: column; align-items: center; }
  .skill-grid { grid-template-columns: 1fr; }
  .pet-img { width: 64px; height: 88px; }
}
.hint-good { color: #23793a; font-weight: 600; }
.hint-bad { color: #c0392b; font-weight: 600; }

/* ---------- admin question bank ---------- */
.small-select { width: auto; min-width: 120px; }
.src-badge { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: #e1e8f2; color: #3b4a60; margin-left: 4px; }
.src-badge.off { background: #fde1dc; color: #a8321f; }
.q-id { float: right; font-size: 11px; color: #8a95a5; }
.q-review.hidden-q { opacity: 0.55; }
.q-actions { margin-top: 6px; }
.q-editor h3 { margin: 4px 0 8px; }
.qe-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 4px; }
.qe-pair .field-label { grid-column: 1 / -1; margin-bottom: 0; }
.qe-pair .text-input { width: 100%; box-sizing: border-box; font: inherit; font-size: 14px; }
.upload-box ol { padding-left: 20px; }
.upload-report { border: 1px solid #d6deeb; border-radius: 10px; padding: 8px 10px; background: #fbfdff; margin-top: 8px; }
@media (max-width: 640px) { .qe-pair { grid-template-columns: 1fr; } }

/* ---------- gate bosses ---------- */
.boss-dialogue .npc-portrait { background: radial-gradient(circle, #5a1f2b, #1d1020); border-color: #ffd23f; }
.boss-dialogue .npc-name { color: #b8860b; }
.boss-battle .boss-foe img { width: 132px; height: 132px; border-radius: 14px; background: radial-gradient(circle, #5a1f2b, #1d1020); border: 3px solid #ffd23f; animation: bossIdle 2.4s ease-in-out infinite; }
.boss-battle .boss-foe img.boss-hurt { animation: bossHurt 0.5s ease; }
.boss-hp { position: relative; width: 132px; height: 16px; margin: 6px auto 0; background: #3a1a1a; border: 2px solid #1d1d1d; border-radius: 8px; overflow: hidden; }
.boss-hp-fill { height: 100%; background: linear-gradient(90deg, #ff3b3b, #ff9a3a); transition: width 0.5s ease; }
.boss-hp span { position: absolute; inset: 0; font-size: 11px; font-weight: 700; color: #fff; text-align: center; line-height: 12px; text-shadow: 0 1px 2px #000; }
.boss-line { font-weight: 700; margin: 0 0 6px; }
.boss-battle.shake { animation: shake 0.4s ease; }
.result-boss { width: 120px; height: 120px; border-radius: 14px; background: radial-gradient(circle, #5a1f2b, #1d1020); border: 3px solid #ffd23f; }
.result-boss.beaten { filter: grayscale(0.7) brightness(0.8); transform: rotate(-8deg); }
@keyframes bossIdle { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-4px) scale(1.03); } }
@keyframes bossHurt { 0% { transform: translateX(0); filter: brightness(1); } 20% { transform: translateX(-10px); filter: brightness(2.2) saturate(0); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 100% { transform: translateX(0); filter: brightness(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
@media (max-width: 700px) { .boss-battle .boss-foe img { width: 72px; height: 72px; } .boss-hp { width: 80px; } }

/* ---------- big world map ---------- */
.minimap-win canvas { cursor: zoom-in; }
.mini-hint { float: right; font-size: 11px; opacity: 0.75; margin-left: 6px; }
.worldmap { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(220px, 1fr); gap: 12px; align-items: start; }
.worldmap-canvas-wrap canvas { width: 100%; height: auto; aspect-ratio: 1; border: 3px solid #1d1d1d; border-radius: 10px; background: #1f2a1f; cursor: crosshair; display: block; }
.map-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; margin-top: 6px; }
.map-legend .lg { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid #1d1d1d; margin-right: 4px; vertical-align: -1px; }
.lg.me { background: #fff; border-color: #d0002a; border-radius: 2px; transform: rotate(45deg); }
.lg.quest { background: #ffd400; } .lg.done { background: #2fbf5a; } .lg.locked { background: #9aa0a6; }
.lg.portal { background: #c37bff; border-color: #fff; } .lg.mon { background: #ff4d4d; } .lg.other { background: #4fe3ff; }
.worldmap-list { max-height: 560px; overflow-y: auto; }
.worldmap-list h3 { margin: 0 0 6px; font-size: 15px; }
.map-npc { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 6px; border: 2px solid #d5d9e0; border-radius: 10px; background: #fff; }
.map-npc.st-boss { border-color: #ffd23f; background: #fff8dd; }
.map-npc.st-done { opacity: 0.8; }
.map-npc.st-locked { opacity: 0.6; }
.map-npc.objective { box-shadow: 0 0 0 3px #ff5050 inset; }
.map-npc-icon { font-size: 20px; width: 26px; text-align: center; }
.map-npc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.map-npc-text b { font-size: 13px; }
.map-npc-text small { font-size: 11px; color: #667; }
.map-npc-text .th { display: block; }
.small { font-size: 12px; }
@media (max-width: 700px) { .worldmap { grid-template-columns: 1fr; } .worldmap-list { max-height: none; } }

/* ---------- pet evolution ---------- */
.pet-card.evolved { border-color: #c37bff; background: linear-gradient(135deg, #fff, #f4ecff); }
.evo-tag { font-size: 11px; background: #c37bff; color: #fff; border-radius: 8px; padding: 1px 6px; }
.evo-hint { font-size: 11px; color: #7a5bb0; align-self: center; }

/* ---------- weapons & armour ---------- */
.gear-list { display: flex; flex-direction: column; gap: 8px; }
.gear-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 2px solid #d5d9e0; border-radius: 10px; background: #fff; }
.gear-row.worn { border-color: #3a6fd8; background: #eef4ff; }
.gear-icon { font-size: 30px; width: 40px; text-align: center; }
.gear-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gear-text small { font-size: 11px; color: #556; }
.gear-text .gear-stats { color: #2c5f9e; font-weight: 600; }
.gear-actions { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.plus { color: #d08a00; font-weight: 800; }
.btn-ro.gold { background: linear-gradient(#ffe07a, #f2b632); border-color: #a87400; color: #4a3000; }
.btn-ro.gold:disabled { opacity: 0.5; }

/* ---------- helpers ---------- */
.friend-note { margin: 6px 0; padding: 6px 10px; border-radius: 10px; background: #e9f7ff; border: 2px dashed #4fb3e8; font-weight: 600; }
.option-btn.friend-pick { box-shadow: 0 0 0 3px #4fb3e8, 0 0 12px #4fb3e8; }
.option-btn.friend-pick::after { content: " 📞"; }
.buy-btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.mini-bar { display: block; height: 6px; margin-top: 3px; }
.tutor-tip { display: block; }
.boss-loot { font-weight: 700; color: #7a4a00; }

/* ---------- players, bots & trading ---------- */
.tool-btn { position: relative; }
.tool-badge { position: absolute; top: -5px; right: -5px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; background: #e8323c; color: #fff; font-size: 10px; font-weight: 800; line-height: 15px; }
.count-pill { background: #e8323c; color: #fff; border-radius: 8px; padding: 0 6px; font-size: 11px; }
.chat-line.bot b { color: #2e9e4a; }
.chat-line.bot .th { display: inline; margin-left: 4px; opacity: 0.75; font-size: calc(0.92em + 2pt); }
.trade-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.trade-head > div { flex: 1; }
.trade-deals { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.trade-deal { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 2px solid #d5d9e0; border-radius: 10px; background: #fff; margin-bottom: 6px; }
.trade-deal.mine { background: #f4f8ff; }
.deal-side { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.deal-side small { color: #667; font-size: 11px; }
.deal-arrow { font-size: 20px; color: #3a6fd8; }
.deal-btns { display: flex; flex-direction: column; gap: 4px; }
.trade-chip { display: inline-block; padding: 1px 6px; margin: 1px; border-radius: 8px; background: #fff6d8; border: 1px solid #e8c45a; font-weight: 700; }
.trade-compose { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trade-col { max-height: 300px; overflow-y: auto; border: 2px solid #d5d9e0; border-radius: 10px; padding: 6px; background: #fff; }
.trade-col h4 { margin: 0 0 4px; }
.trade-pick { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 6px; }
.trade-pick.on { background: #eef4ff; }
.tp-icon { font-size: 18px; width: 24px; text-align: center; }
.tp-name { flex: 1; font-size: 11px; line-height: 1.15; }
.tp-ctrl { display: flex; align-items: center; gap: 4px; }
.tp-ctrl b { min-width: 16px; text-align: center; }
.btn-ro.tiny { padding: 0 7px; min-width: 0; height: 22px; font-size: 14px; line-height: 20px; }
.trade-summary { text-align: center; margin: 8px 0; font-weight: 600; }
@media (max-width: 700px) { .trade-compose { grid-template-columns: 1fr; } }

/* ---------- admin: edit a player ---------- */
.admin-edit { border: 2px solid #ffd23f; border-radius: 12px; padding: 12px; margin-bottom: 14px; background: rgba(255, 210, 63, 0.08); }
.admin-edit-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-edit-head #aeClose { margin-left: auto; }
.admin-edit-stats { font-size: 13px; background: rgba(0, 0, 0, 0.25); padding: 2px 8px; border-radius: 8px; }
.admin-edit h4 { margin: 10px 0 4px; font-size: 13px; }
.admin-edit-grid { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin: 6px 0; }
.admin-edit-grid label, .admin-note { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.admin-edit-grid label.check { flex-direction: row; align-items: center; }
.admin-edit-grid input[type="number"] { width: 90px; }
.admin-note { margin: 6px 0; }
.admin-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.admin-items label { display: flex; align-items: center; gap: 4px; font-size: 16px; }
.admin-items input { width: 52px; padding: 3px 4px; }
.admin-grants { margin: 0; padding-left: 4px; list-style: none; font-size: 12px; max-height: 140px; overflow: auto; }

/* ---------- missions ---------- */
.mission-list { display: flex; flex-direction: column; gap: 8px; }
.mission-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); }
.mission-row.weekly { border-color: rgba(180, 130, 255, 0.45); }
.mission-row.ready { border-color: #ffd23f; box-shadow: 0 0 10px rgba(255, 210, 63, 0.35); }
.mission-row.claimed { opacity: 0.55; }
.mission-icon, .town-icon { font-size: 26px; width: 36px; text-align: center; }
.mission-main, .town-main { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mission-bar, .exped-hp { position: relative; height: 14px; border-radius: 7px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.mission-bar span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #4fd36a, #b6f05a); border-radius: 7px; }
.mission-bar em, .exped-hp em { position: absolute; inset: 0; text-align: center; font-size: 10px; font-style: normal; line-height: 14px; color: #fff; text-shadow: 0 1px 2px #000; }

/* ---------- town & army ---------- */
.town-canvas { display: block; width: 100%; max-width: 440px; aspect-ratio: 56 / 30; margin: 0 auto 8px; border-radius: 12px; background: linear-gradient(#9ed8ff, #d9f2ff); cursor: grab; touch-action: none; }
.town-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.town-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); }
.town-row.unbuilt { opacity: 0.7; }
.town-row .btn-ro small { font-size: 10px; opacity: 0.85; }
.exped-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.exped-top .exped-hp { flex: 1; height: 18px; }
.exped-hp span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #ff4a4a, #ff9a3a); border-radius: 7px; transition: width 0.4s; }
.exped-hp em { line-height: 18px; font-size: 11px; }
.result .exped-hp { max-width: 320px; margin: 8px auto; }
.exped-foe { font-size: 36px; }
.exped-army { font-size: 13px; white-space: nowrap; }
.admin-edit-grid label > span, .admin-note > span { display: flex; gap: 4px; align-items: baseline; flex-wrap: wrap; min-height: 30px; }
.admin-edit-grid label > span small, .admin-note > span small { display: inline; }

/* ---------- learning report & analytics ---------- */
.focus-box { border: 2px solid #ff8a5a; border-radius: 12px; padding: 8px 12px; margin: 8px 0 12px; background: rgba(255, 138, 90, 0.08); }
.focus-box h3 { margin: 2px 0 6px; }
.focus-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.focus-row .deal-btns { margin-left: auto; }
.skill-list { display: flex; flex-direction: column; gap: 6px; }
.skill-row { display: grid; grid-template-columns: minmax(140px, 1.2fr) 1.4fr 1.2fr; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); border-left: 4px solid #999; }
.skill-row.s-weak { border-left-color: #ff4a4a; }
.skill-row.s-growing { border-left-color: #ff9a3a; }
.skill-row.s-strong { border-left-color: #4fd36a; }
.skill-name { display: flex; flex-direction: column; }
.skill-nums { display: flex; flex-direction: column; gap: 3px; }
.trend { display: inline-flex; gap: 2px; }
.trend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.trend i.ok { background: #4fd36a; }
.trend i.no { background: #ff4a4a; }
.mistake-list { display: flex; flex-direction: column; gap: 6px; }
.mistake-row { padding: 6px 10px; border-radius: 8px; background: rgba(255, 74, 74, 0.07); font-size: 13px; }
.mistake-q { margin: 2px 0; }
.bad { color: #e0453a; font-weight: 700; }
.good { color: #2f9e4a; font-weight: 700; }
.acc-bar { position: relative; height: 14px; min-width: 70px; border-radius: 7px; background: rgba(0, 0, 0, 0.15); overflow: hidden; }
.acc-bar span { position: absolute; inset: 0 auto 0 0; border-radius: 7px; }
.acc-bar.low span { background: #ff5a4a; }
.acc-bar.mid span { background: #ffb23a; }
.acc-bar.high span { background: #4fd36a; }
.acc-bar em { position: absolute; inset: 0; text-align: center; font-size: 10px; font-style: normal; line-height: 14px; font-weight: 700; }
.an-table td { vertical-align: top; }
.an-q { max-width: 340px; font-size: 12px; }
.weak-chip { display: inline-block; font-size: 11px; padding: 1px 6px; margin: 1px; border-radius: 8px; background: rgba(255, 74, 74, 0.15); }
.small-select { width: auto; display: inline-block; font-size: 12px; padding: 2px 6px; margin-left: 8px; }
.an-player { padding: 6px; background: rgba(0, 0, 0, 0.04); border-radius: 8px; }
.an-days { display: flex; gap: 4px; align-items: flex-end; height: 50px; margin-bottom: 8px; }
.an-day { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.an-day span { width: 100%; background: #ff8a7a; border-radius: 3px 3px 0 0; display: flex; align-items: flex-end; overflow: hidden; }
.an-day i { width: 100%; background: #4fd36a; }
@media (max-width: 700px) { .skill-row { grid-template-columns: 1fr; } }
#anCourse, #anDays { width: auto; flex: 0 1 auto; }
.an-day { max-width: 28px; } .an-days { justify-content: flex-start; } .an-q code { font-size: 12px; background: rgba(0,0,0,0.06); padding: 1px 4px; border-radius: 4px; }

/* ---------- characters & grade ---------- */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 8px; }
.char-card { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 8px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.15); text-align: center; min-height: 210px; }
.char-card.empty { justify-content: center; cursor: pointer; border-style: dashed; color: inherit; font: inherit; }
.char-card.empty:disabled { opacity: 0.35; cursor: default; }
.char-card.new { align-items: stretch; text-align: left; border-color: #ffd23f; }
.char-plus { font-size: 34px; line-height: 1; }
.char-portrait { width: 84px; height: 84px; object-fit: contain; }
.char-name { font-size: 15px; }
.char-btns { display: flex; gap: 6px; justify-content: center; margin-top: auto; }
.grade-ask { border: 2px solid #ffd23f; border-radius: 12px; padding: 10px 12px; margin: 8px 0; background: rgba(255, 210, 63, 0.1); }
.grade-ask select { width: auto; }
.grade-note { font-size: 13px; }
.grade-bonus { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 8px; margin-top: 3px; }
.grade-bonus.up { background: rgba(79, 211, 106, 0.25); color: #1f7a35; }
.grade-bonus.down { background: rgba(255, 90, 74, 0.2); color: #a8321f; }
.admin-chars { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.admin-chars .tab { font-size: 12px; }

/* Homestead Land Office */
.plot-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 6px 0 10px; }
.plot { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 8px; border: 2px solid #8fbf6a; background: #eef9e4; cursor: pointer; font: inherit; min-height: 52px; }
.plot b { font-size: 15px; }
.plot small { font-size: 10px; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plot.free:hover { background: #d6f2bf; }
.plot.taken { background: #f3e7dc; border-color: #c9a27e; cursor: default; opacity: 0.85; }
.plot.mine { background: #c9f5dc; border-color: #2fd17a; cursor: default; }
.home-row { display: flex; gap: 16px; justify-content: center; align-items: flex-start; flex-wrap: wrap; margin: 6px 0; text-align: center; }
.home-colors { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; margin-top: 4px; max-width: 220px; }
.home-color { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #9aa; cursor: pointer; }
.home-color.on { box-shadow: 0 0 0 3px #2fd17a; }

/* Thai text (.th) is 2pt larger than its em size alone: calc(… + 2pt) in the .th rules above. */

/* ---------- Game 24 (special server) ---------- */
.g24-sets { flex-wrap: wrap; }
.g24-sets .tab small { opacity: 0.7; font-weight: 600; }
.g24-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin: 8px 0; }
.g24-num { border: 2px solid #c9d6ea; background: #fff; border-radius: 8px; padding: 4px 0; font-weight: 800; cursor: pointer; color: #34415a; }
.g24-num.ok { background: #dff5e3; border-color: #3aa55a; color: #23803d; }
.g24-num.on { box-shadow: 0 0 0 3px #ff9f1a; }
.g24-board { background: #f4f8ff; border: 2px solid #c9d6ea; border-radius: 12px; padding: 10px 12px; }
.g24-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.g24-given { margin-left: auto; color: #5a6a85; font-weight: 700; letter-spacing: 1px; }
.g24-cards { display: flex; justify-content: center; gap: 10px; margin: 12px 0 8px; flex-wrap: wrap; }
.g24-card { width: 84px; height: 104px; border-radius: 12px; border: 3px solid #7b4fd6; background: linear-gradient(#fff, #efe8ff); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 3px 0 #5a35a8; transition: transform 0.1s; }
.g24-card:hover:not(:disabled) { transform: translateY(-2px); }
.g24-card.picked { background: linear-gradient(#fff4d6, #ffe08a); border-color: #e89a00; box-shadow: 0 0 0 3px #ff9f1a, 0 3px 0 #b07400; }
.g24-card.win { background: linear-gradient(#e6ffe9, #b8f0c2); border-color: #2f9e4b; box-shadow: 0 3px 0 #23803d; }
.g24-val { font-size: 34px; font-weight: 900; color: #2b2350; line-height: 1; }
.g24-from { font-size: 10px; color: #6b6290; margin-top: 4px; max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g24-ops { display: flex; justify-content: center; gap: 8px; }
.g24-op { width: 52px; height: 44px; font-size: 24px; font-weight: 900; border-radius: 10px; border: 2px solid #3d6fd9; background: #fff; color: #2b4f9e; cursor: pointer; }
.g24-op.on { background: #3d6fd9; color: #fff; }
.g24-op:disabled { opacity: 0.4; cursor: default; }
.g24-steps { margin: 10px auto 4px; max-width: 260px; font-weight: 700; color: #34415a; }
.g24-tip { margin: 10px 0 4px; }
.g24-msg { margin: 8px 0; padding: 8px; border-radius: 8px; text-align: center; font-weight: 700; background: #fff1e6; color: #a5470f; }
.g24-msg.good { background: #dff5e3; color: #1f7a38; font-size: 17px; }
.g24-hint { margin: 6px 0; padding: 8px; border-radius: 8px; background: #fffbe0; border: 1px dashed #e0b400; text-align: center; }
.g24-actions { flex-wrap: wrap; }

/* ---------- Power Tower ---------- */
.tw-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0; }
.tw-stats > div { background: #f4f8ff; border: 2px solid #c9d6ea; border-radius: 10px; padding: 6px 8px; display: flex; justify-content: space-between; gap: 6px; }
.tw-stats span { color: #5a6a85; font-size: 13px; }
.tw-floors { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.tw-floor { display: flex; flex-direction: column; align-items: center; padding: 4px 0; border-radius: 8px; border: 2px solid #c9d6ea; background: #fff; cursor: pointer; color: #34415a; }
.tw-floor small { font-size: 11px; }
.tw-floor.done { background: #dff5e3; border-color: #3aa55a; }
.tw-floor.boss { border-color: #d84a3a; }
.tw-floor.boss.done { background: #ffe9d6; }
.tw-floor.next { box-shadow: 0 0 0 3px #ff9f1a; animation: actPulse 1.6s infinite; }
.tw-floor:disabled { opacity: 0.45; cursor: not-allowed; }
.tw-rare { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.tw-rare-card { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 6px; border-radius: 10px; border: 2px dashed #c9b6f0; background: #faf7ff; filter: grayscale(0.6); }
.tw-rare-card.ok { filter: none; border-style: solid; border-color: #9a6bff; }
.tw-rare-card b { font-size: 13px; }
.tw-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: linear-gradient(#2b2350, #4a3a7a); border-radius: 12px; padding: 10px; color: #fff; }
.tw-field .muted { color: #cfc6f0; }
.tw-side { flex: 1; display: flex; align-items: center; gap: 8px; position: relative; }
.tw-side.foe { flex-direction: row-reverse; text-align: right; }
.tw-img { width: 96px; height: 96px; object-fit: contain; image-rendering: pixelated; background: rgba(255, 255, 255, 0.08); border-radius: 12px; }
.tw-side.boss .tw-img { width: 118px; height: 118px; }
.tw-meta { flex: 1; min-width: 0; }
.tw-bar { height: 10px; margin: 3px 0 1px; }
.tw-bar.energy .bar-fill { background: linear-gradient(90deg, #ffd23f, #ff9f1a); }
.tw-pet { position: absolute; left: 62px; bottom: -6px; width: 48px; height: 48px; }
.tw-pet.resting { filter: grayscale(0.8) brightness(0.8); }
.tw-intent { margin-top: 4px; font-size: 13px; font-weight: 700; color: #ffe08a; }
.tw-intent.danger { color: #fff; background: #d84a3a; border-radius: 6px; padding: 2px 6px; display: inline-block; animation: actPulse 1s infinite; }
.tw-side.hit .tw-img { animation: pbHit 0.5s; }
.tw-moves { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; }
.tw-move { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border-radius: 12px; border: 3px solid #3d6fd9; background: #fff; font-weight: 800; color: #2b4f9e; cursor: pointer; }
.tw-move small { font-weight: 700; color: #8a6b00; }
.tw-move.tw-strike { border-color: #e8862a; color: #a5470f; }
.tw-move.tw-ultimate { border-color: #9a6bff; color: #5a35a8; background: linear-gradient(#fff, #f1eaff); }
.tw-move.tw-guard { border-color: #3aa55a; color: #23803d; }
.tw-move:hover:not(:disabled) { transform: translateY(-2px); }
.tw-move:disabled { opacity: 0.4; cursor: not-allowed; }
.tw-extra { flex-wrap: wrap; }
.shop-card.rarity-5 { background: linear-gradient(#fff, #f6eeff); border-color: #9a6bff; position: relative; }
.shop-card.locked-pet img { filter: grayscale(0.7) brightness(0.9); }
.rare-tag { position: absolute; top: 4px; left: 4px; font-size: 11px; font-weight: 800; color: #fff; background: #9a6bff; border-radius: 6px; padding: 1px 6px; }
.sell-btns { display: flex; gap: 4px; flex-shrink: 0; }
.sell-btns .btn-ro.small, .sell-pet { white-space: nowrap; }

/* ---------- private messages ---------- */
.dm-threads { display: flex; flex-direction: column; gap: 6px; }
.dm-thread { display: flex; align-items: center; gap: 8px; text-align: left; border: 2px solid #c9d6ea; border-radius: 10px; background: #fff; padding: 6px 10px; cursor: pointer; font: inherit; }
.dm-thread:hover { border-color: #3d6fd9; }
.dm-thread.unread { border-color: #ff9f1a; background: #fff8ec; }
.dm-tmain { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dm-tlast { color: #6b7685; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-tmeta { display: flex; align-items: center; gap: 6px; color: #6b7685; }
.dm-people { display: flex; flex-wrap: wrap; gap: 6px; }
.dm-person { display: flex; align-items: center; gap: 6px; border: 2px solid #c9d6ea; border-radius: 10px; background: #fff; padding: 4px 10px 4px 4px; cursor: pointer; font: inherit; }
.dm-person .trainer-img { width: 36px; height: 36px; }
.dm-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dm-peer { font-size: 17px; }
.dm-head #dmBlock { margin-left: auto; }
.dm-log { height: 260px; overflow-y: auto; background: #f4f8ff; border: 2px solid #c9d6ea; border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.dm-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 78%; }
.dm-msg.mine { align-self: flex-end; align-items: flex-end; }
.dm-bubble { background: #fff; border: 1px solid #d6deeb; border-radius: 12px 12px 12px 4px; padding: 6px 10px; word-break: break-word; white-space: pre-wrap; }
.dm-msg.mine .dm-bubble { background: #3d6fd9; color: #fff; border-color: #3d6fd9; border-radius: 12px 12px 4px 12px; }
.dm-msg small { color: #8a94a6; font-size: 11px; margin: 1px 4px; }
.dm-form { display: flex; gap: 6px; margin: 8px 0 4px; }
.dm-form input { flex: 1; }
.trade-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
#fullscreenBtn.on { background: #ffe08a; }

/* ---------- Farm & Market ---------- */
.gd-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 6px; }
.gd-tab { border: 1px solid #9fb6d8; background: #eef4ff; border-radius: 8px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 14px; }
.gd-tab.on { background: linear-gradient(#8fd17a, #4fa83a); color: #fff; border-color: #3d8a2c; font-weight: 600; }
.gd-quest { display: flex; flex-direction: column; gap: 2px; background: #fff8e0; border: 1px solid #e3c766; border-radius: 8px; padding: 8px 10px; margin: 6px 0 10px; font-size: 14px; }
.gd-quest.done { background: #e9f9e4; border-color: #8fcf7a; text-align: center; }
.gd-ico { font-size: 26px; line-height: 1.1; }
.gd-ico.big { font-size: 34px; }
.gd-seeds { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.gd-seed { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 4px; border: 1px solid #c8d4e6; background: #fff; border-radius: 8px; cursor: pointer; font: inherit; font-size: 12px; }
.gd-seed.on { border: 2px solid #4fa83a; background: #eaf8e4; }
.gd-seed:disabled { opacity: 0.5; cursor: default; }
.gd-beds { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.gd-bed { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 104px; padding: 8px 4px; border-radius: 10px; border: 2px solid #8a6a44; background: linear-gradient(#a8825a, #7a5a3a); color: #fff; cursor: pointer; font: inherit; font-size: 12px; text-shadow: 0 1px 1px rgba(0,0,0,0.5); }
.gd-bed.growing { background: linear-gradient(#93a85a, #6b7d3a); }
.gd-bed.ready { background: linear-gradient(#ffe27a, #f0b53a); color: #4a3000; text-shadow: none; border-color: #c98a1a; animation: gdPulse 1.2s ease-in-out infinite; }
@keyframes gdPulse { 50% { transform: scale(1.04); } }
.gd-bar { width: 86%; height: 7px; border-radius: 4px; background: rgba(0,0,0,0.3); overflow: hidden; }
.gd-bar i { display: block; height: 100%; background: #9cf07a; transition: width 0.9s linear; }
.gd-basket { display: flex; flex-wrap: wrap; gap: 6px; }
.gd-chip { background: #f3f6fb; border: 1px solid #c8d4e6; border-radius: 14px; padding: 2px 9px; font-size: 15px; }
.gd-recipes, .gd-orders, .gd-sell, .gd-qlist { display: flex; flex-direction: column; gap: 6px; }
.gd-recipe, .gd-order, .gd-sell-row, .gd-qrow { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid #d3dceb; border-radius: 8px; background: #fff; }
.gd-recipe > div:nth-child(2), .gd-order > div, .gd-qrow > div { flex: 1; }
.gd-recipe.can { border-color: #6cbf55; background: #f2fbef; }
.gd-btns { display: flex; flex-direction: column; gap: 4px; }
.gd-recipe .ok, .gd-order .ok { color: #2f8a24; font-weight: 600; }
.gd-recipe .bad, .gd-order .bad { color: #b24a3a; }
.gd-sell-row > span:nth-child(2) { flex: 1; }
.gd-price { font-weight: 700; color: #a86a00; }
.gd-hot { background: #ff7a3a; color: #fff; border-radius: 8px; padding: 0 6px; font-size: 12px; }
.gd-hotbox { background: linear-gradient(90deg, #fff0e0, #ffe0c8); border: 1px solid #f0a060; border-radius: 8px; padding: 6px 10px; text-align: center; margin-bottom: 4px; }
.gd-order.done { opacity: 0.65; }
.gd-qrow.done { background: #eef9ea; }
.gd-qrow.cur { border: 2px solid #e3b340; background: #fff9e6; }

/* ---------- Quiz server ---------- */
.qz-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qz-mode, .qz-test-card { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 8px; border-radius: 12px; border: 2px solid var(--accent, #9fb6d8); background: #fff; cursor: pointer; font: inherit; text-align: center; }
.qz-mode:hover, .qz-test-card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.12); }
.qz-ico { font-size: 32px; line-height: 1.1; }
.qz-tests { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.qz-test-card { border-color: #9fb6d8; font-size: 14px; }
.qz-test-card.star { border-color: #e3b340; background: #fffaea; }
.qz-progress { display: flex; justify-content: space-between; font-weight: 600; color: #4a5a78; margin-bottom: 6px; }
.qz-timer.low { color: #d23a2a; animation: gdPulse 1s infinite; }
.qz-q { background: #f4f8ff; border: 2px solid #c9d6ea; border-radius: 12px; padding: 12px 14px; font-size: 17px; margin: 6px 0 10px; line-height: 1.5; }
.qz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qz-opt.correct { background: #dff5e3 !important; border-color: #3aa55a !important; color: #1f7a36; }
.qz-opt.wrong { background: #fde2df !important; border-color: #d24a3a !important; color: #a12a1c; }
.qz-feedback { margin-top: 10px; padding: 8px 12px; border-radius: 10px; }
.qz-feedback.ok { background: #e9f9e4; border: 1px solid #8fcf7a; }
.qz-feedback.bad { background: #fff0ec; border: 1px solid #f0a090; }
.qz-multi { color: #b06a00; font-weight: 600; margin: 4px 0; }
.qz-choices { display: flex; flex-direction: column; gap: 6px; }
.qz-choice { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 8px 12px; border: 2px solid #c9d6ea; background: #fff; border-radius: 10px; cursor: pointer; font: inherit; font-size: 15px; }
.qz-choice.on { border-color: #2f7fd8; background: #e6f0ff; box-shadow: 0 0 0 2px #9cc3f5; }
.qz-num { font-size: 20px; color: #2f7fd8; line-height: 1; }
.qz-numform { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.qz-numform input { width: 110px; font-size: 26px; text-align: center; padding: 6px; border: 2px solid #9fb6d8; border-radius: 10px; font-weight: 800; letter-spacing: 4px; }
.qz-result { text-align: center; }
.qz-big { font-size: 56px; }
.qz-reviews { display: flex; flex-direction: column; gap: 6px; }
.qz-review { border: 1px solid #d3dceb; border-radius: 8px; padding: 6px 10px; background: #fff; }
.qz-review.ok { border-left: 5px solid #3aa55a; }
.qz-review.bad { border-left: 5px solid #d24a3a; }
.qz-review summary { cursor: pointer; }
.qz-olist li.right { color: #1f7a36; font-weight: 700; }
.qz-x { background: #fff9e6; border-radius: 6px; padding: 4px 8px; }
@media (max-width: 560px) { .qz-modes, .qz-options { grid-template-columns: 1fr; } }

/* ---------- Dungeon picker ---------- */
.dg-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.dg-card { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 8px; border-radius: 12px; border: 2px solid #8a7ad8; background: linear-gradient(#ffffff, #eef0ff); cursor: pointer; font: inherit; text-align: center; }
.dg-card:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
.dg-card.locked { opacity: 0.55; cursor: default; border-color: #b8b8c8; }
.dg-ico { font-size: 34px; line-height: 1.1; }
.dg-lv { color: #6a5ab8; font-weight: 600; }

/* ---------- treasure chests ---------- */
.ch-stage { display: flex; justify-content: center; padding: 18px 0 8px; }
.ch-box { --body: #a0703a; --trim: #6b4220; --gem: #ffd23f; position: relative; width: 130px; height: 100px; perspective: 400px; }
.ch-silver { --body: #c8d0dc; --trim: #7a8494; --gem: #7fe0ff; }
.ch-gold { --body: #f2c230; --trim: #b8860b; --gem: #ff4d6d; }
.ch-body { position: absolute; left: 0; right: 0; bottom: 0; height: 62px; background: var(--body); border: 5px solid var(--trim); border-radius: 6px; box-shadow: 0 6px 14px rgba(0,0,0,.35); }
.ch-body i { position: absolute; left: 50%; top: -4px; width: 20px; height: 22px; margin-left: -10px; background: var(--trim); border-radius: 4px; }
.ch-body i::after { content: ""; position: absolute; left: 5px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--gem); box-shadow: 0 0 10px var(--gem); }
.ch-lid { position: absolute; left: 0; right: 0; top: 4px; height: 38px; background: var(--body); border: 5px solid var(--trim); border-radius: 30px 30px 4px 4px; transform-origin: 50% 100%; transition: transform .6s cubic-bezier(.3,1.6,.5,1); z-index: 2; }
.ch-box.open .ch-lid { transform: translateY(-14px) rotateX(70deg); }
.ch-box.open::before { content: ""; position: absolute; left: 10px; right: 10px; bottom: 50px; height: 40px; background: radial-gradient(ellipse at bottom, rgba(255,230,120,.9), transparent 70%); z-index: 1; }
.ch-box.pop { animation: chShake .45s ease; }
@keyframes chShake { 0%,100% { transform: none; } 20% { transform: rotate(-6deg); } 40% { transform: rotate(6deg); } 60% { transform: rotate(-4deg) scale(1.05); } 80% { transform: rotate(3deg); } }
.ch-msg { font-size: 1.1em; font-weight: 600; }
.ch-keys { display: flex; justify-content: center; gap: 8px; font-size: 28px; margin: 6px 0; }
.ch-keys span { filter: grayscale(1); opacity: .35; }
.ch-keys span.on { filter: none; opacity: 1; }
.ch-loot { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 10px 0; }
.ch-item { display: flex; flex-direction: column; align-items: center; min-width: 92px; padding: 8px 10px; border-radius: 10px; background: rgba(255,210,63,.14); border: 1px solid rgba(255,210,63,.5); animation: chPop .4s backwards; }
.ch-item .ch-ic { font-size: 30px; }
.ch-item b { color: #b8860b; font-size: 1.15em; }
@keyframes chPop { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
.pw-ico { display: inline-block; vertical-align: -0.12em; }
.challenge-tag.tedet { background: #e6edff; color: #2d4fb5; border-color: #8ea6f2; }
