/* tac-theme.css — ธีมทั้งแอปแบบเกมแทคติก (โหลดหลัง game.css)
   หน้าต่างกระดาษ parchment · ขอบน้ำตาลสองชั้น · แถบหัวน้ำเงินเข้ม · เส้นทอง · เงาตันไม่ฟุ้ง
   แสดงผลอย่างเดียว: ไม่ซ่อนองค์ประกอบใด ไม่เปลี่ยนขนาดเป้ากด (≥ 44px) · ตัวหนังสือ contrast ≥ 4.5:1 · ธีมสว่างเท่านั้น
   ใช้โทเคนชุดเดียวกับ tac-ui.css (--tu-*) แต่ประกาศซ้ำเป็น --tt-* เพื่อให้ไฟล์นี้ทำงานได้เองแม้ไม่โหลด tac-ui.css */
:root {
  --tt-ink: #2b1a0c;      /* ตัวหนังสือหลักบนกระดาษ (≈ 15:1) */
  --tt-ink2: #5a3d22;     /* ตัวรอง (≈ 8:1 บน #f3e6c4) */
  --tt-brown: #3a2312;    /* ขอบนอก */
  --tt-tan: #a9824c;      /* ขอบใน */
  --tt-gold: #e2b54a;
  --tt-gold2: #f7dc8a;
  --tt-goldd: #8a5f12;    /* ทองเข้มสำหรับตัวหนังสือ (≈ 5:1 บนกระดาษ) */
  --tt-blue: #0d3a78;
  --tt-blue2: #1a56a6;
  --tt-night: #0a2147;
  --tt-paper: #fbf3dd;
  --tt-paper1: #f5e9c9;
  --tt-paper2: #ecdcb3;
  --tt-red: #b8281f;      /* ขาวบนแดงนี้ ≈ 6:1 */
  --tt-red2: #d83a2f;
  --tt-redd: #6e140f;
  --tt-green: #17703d;    /* ≈ 5.6:1 บนกระดาษ */
  --tt-greend: #0b4a27;
  --tt-amber: #8a5200;
  /* เขียนทับโทเคนของ game.css ให้ทั้งแอปเป็นโทนกระดาษ (คงหน้าที่ของสี: แดง=ลงมือ น้ำเงิน=โครง เขียว=ผ่าน เหลือง=EXP) */
  --ink: #2b1a0c; --muted: #5e4527; --line: #c4a877; --paper: #fffaf0; --cream: #fbf3dd; --sky: #efe3c3;
  --deep: #0d3a78; --blue: #1a56a6; --red: #b8281f; --green: #17703d; --amber: #8a5200;
  --green-soft: #e4eed2; --red-soft: #f8dfd4; --amber-soft: #f9e8bf;
  --shadow: 0 4px 0 rgba(43,26,12,.35);
  /* ลายกระดาษ (ใช้ซ้ำหลายที่) */
  --tt-grain:
    repeating-radial-gradient(circle at 17% 23%, rgba(120,80,30,.045) 0 1px, transparent 1px 5px),
    repeating-radial-gradient(circle at 81% 67%, rgba(120,80,30,.04) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(97deg, rgba(255,255,255,.16) 0 1px, transparent 1px 9px);
  --tt-rivets:
    radial-gradient(circle at 5px 5px, var(--tt-gold) 0 1.8px, var(--tt-brown) 2.2px 2.8px, transparent 3.2px),
    radial-gradient(circle at calc(100% - 5px) 5px, var(--tt-gold) 0 1.8px, var(--tt-brown) 2.2px 2.8px, transparent 3.2px),
    radial-gradient(circle at 5px calc(100% - 5px), var(--tt-gold) 0 1.8px, var(--tt-brown) 2.2px 2.8px, transparent 3.2px),
    radial-gradient(circle at calc(100% - 5px) calc(100% - 5px), var(--tt-gold) 0 1.8px, var(--tt-brown) 2.2px 2.8px, transparent 3.2px);
  --tt-win-shadow: inset 0 0 0 1px #fffaea, inset 0 0 0 2px var(--tt-tan), inset 0 -8px 12px -8px rgba(110,70,25,.28), 0 3px 0 rgba(32,16,4,.42);
  --tt-strip: linear-gradient(180deg, #1f55a0 0%, var(--tt-blue) 48%, var(--tt-night) 100%);
}

/* ---------- พื้นหลัง: โต๊ะแผนที่ลายกระเบื้องข้าวหลามตัด (ภาพนิ่ง ไม่ขยับ) ---------- */
/* ชั้นพื้นหลังเป็น fixed layer แยก (คอมโพสิตถูก ไม่ repaint ตอนเลื่อน แทน background-attachment:fixed) */
html { background: #d8c497; }
body { color: var(--tt-ink); background: transparent; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-color: #d8c497;
  background-image:
    radial-gradient(130% 90% at 50% 0%, rgba(255,246,220,.6) 0%, rgba(255,246,220,0) 60%),
    radial-gradient(140% 100% at 50% 110%, rgba(70,40,12,.26) 0%, rgba(70,40,12,0) 60%),
    repeating-linear-gradient(26.565deg, rgba(90,58,20,.07) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(-26.565deg, rgba(90,58,20,.07) 0 1px, transparent 1px 24px),
    linear-gradient(180deg, #e6d6ae 0%, #d8c497 55%, #c9b283 100%);
}
:focus-visible { outline-color: #0d3a78; box-shadow: 0 0 0 5px rgba(247,220,138,.9); }

/* ---------- แถบบน ---------- */
.brand { color: var(--tt-blue); text-shadow: 0 1px 0 rgba(255,250,234,.8); letter-spacing: .01em; }
.brand small { color: var(--tt-ink2); text-shadow: none; }
.iconbtn, .devtoggle {
  border: 2px solid var(--tt-brown); border-radius: 6px; color: var(--tt-blue);
  background: linear-gradient(180deg, #fffaf0, var(--tt-paper1));
  box-shadow: inset 0 0 0 1px #fffaea, inset 0 0 0 2px rgba(169,130,76,.55), 0 3px 0 rgba(32,16,4,.38);
}
.iconbtn:active, .devtoggle:active { transform: translateY(2px); box-shadow: inset 0 0 0 1px #fffaea, 0 1px 0 rgba(32,16,4,.38); }
.devtoggle { color: var(--tt-ink2); min-height: 44px; }
.devtoggle[aria-pressed="true"], .iconbtn[aria-pressed="true"] { background: var(--tt-strip); color: #fff; border-color: var(--tt-brown); box-shadow: inset 0 0 0 1px var(--tt-gold), 0 3px 0 rgba(32,16,4,.38); }

/* ---------- หัวภารกิจ (HUD เกาะจอ) ---------- */
.hud {
  background: var(--tt-strip); color: #fff; border: 2px solid var(--tt-brown); border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--tt-gold), inset 0 1px 0 2px rgba(255,255,255,.14), 0 3px 0 rgba(32,16,4,.45);
  text-shadow: 0 1px 0 #041633;
}
.hud .prog { height: 8px; border-radius: 2px; background: #061a3a; box-shadow: inset 0 0 0 1px rgba(226,181,74,.6); }
.hud .prog i { background: linear-gradient(180deg, #ffe58a, #e2b54a 60%, #b9821f); border-radius: 1px; }
.hud .quit {
  border: 1.5px solid var(--tt-gold); border-radius: 4px; color: #fff;
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(0,0,0,.18));
}
.hud-pat { background: var(--tt-paper); border-radius: 3px; box-shadow: 0 0 0 1.5px var(--tt-gold); }

/* ---------- การ์ด = หน้าต่างกระดาษ ---------- */
.card {
  position: relative; color: var(--tt-ink);
  border: 2px solid var(--tt-brown); border-radius: 6px;
  background-color: var(--tt-paper);
  background-image: var(--tt-rivets), var(--tt-grain), linear-gradient(180deg, var(--tt-paper) 0%, var(--tt-paper1) 60%, var(--tt-paper2) 100%);
  box-shadow: var(--tt-win-shadow);
}
.step-kicker { color: var(--tt-ink2); font-family: var(--fh); font-weight: 500; letter-spacing: .03em; }
.step-kicker::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 7px 1px 1px; transform: rotate(45deg);
  background: linear-gradient(135deg, var(--tt-gold2), #b9821f); box-shadow: 0 0 0 1px var(--tt-brown); vertical-align: middle; }
h2.step-title { color: var(--tt-blue); text-shadow: 0 1px 0 rgba(255,250,234,.9); }
.card h1, .card h2, .card h3 { color: var(--tt-blue); }
.prompt { color: var(--tt-ink); }
.muted, .hint:not(.btn) { color: var(--muted); }
/* เส้นทองคั่นใต้หัวเรื่องการ์ด */
.card > h2.step-title::after, .sheet .step-title::after { content: ""; display: block; height: 2px; margin-top: 6px; max-width: 220px;
  background: linear-gradient(90deg, var(--tt-gold) 0%, rgba(226,181,74,.55) 60%, transparent); }

/* ---------- ปุ่ม: แผ่นโลหะน้ำเงิน/แดง ขอบทอง กดยุบเงาตัน 4px ---------- */
.btn {
  position: relative; border: 2px solid var(--tt-brown); border-radius: 6px; color: #fff; letter-spacing: .02em;
  background: linear-gradient(180deg, #2462b4 0%, #1a56a6 45%, #0d3a78 100%);
  box-shadow: inset 0 0 0 1px var(--tt-gold), inset 0 2px 0 1px rgba(255,255,255,.18), 0 4px 0 var(--tt-brown);
  text-shadow: 0 1px 0 rgba(4,22,51,.8);
}
.btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 1px var(--tt-gold), 0 1px 0 var(--tt-brown); }
.btn.red {
  background: linear-gradient(180deg, #cf3a2f 0%, #b8281f 45%, #8f1c15 100%);
  box-shadow: inset 0 0 0 1px var(--tt-gold2), inset 0 2px 0 1px rgba(255,255,255,.2), 0 4px 0 var(--tt-redd);
  border-color: var(--tt-redd); text-shadow: 0 1px 0 rgba(60,8,4,.7);
}
.btn.red:active { box-shadow: inset 0 0 0 1px var(--tt-gold2), 0 1px 0 var(--tt-redd); }
.btn.green {
  background: linear-gradient(180deg, #1e7f47 0%, #17703d 55%, #0e5530 100%);
  box-shadow: inset 0 0 0 1px var(--tt-gold), inset 0 2px 0 1px rgba(255,255,255,.18), 0 4px 0 var(--tt-greend);
  border-color: var(--tt-greend);
}
.btn.ghost {
  color: var(--tt-blue); text-shadow: none; border: 2px solid var(--tt-brown);
  background: linear-gradient(180deg, #fffaf0, var(--tt-paper1));
  box-shadow: inset 0 0 0 1px #fffaea, inset 0 0 0 2px rgba(169,130,76,.6), 0 4px 0 rgba(58,35,18,.55);
}
.btn.ghost:active { box-shadow: inset 0 0 0 1px #fffaea, 0 1px 0 rgba(58,35,18,.55); }
.btn[disabled], .btn[disabled].red, .btn[disabled].green {
  background: linear-gradient(180deg, #ddd0ae, #cbbb92); color: #4e3a22; text-shadow: none; border-color: #7d6440;
  box-shadow: inset 0 0 0 1px rgba(255,250,234,.6), 0 4px 0 #7d6440;
}
/* ปุ่มลงมือหลัก (แดง/เขียว) มีเพชรทองสองข้าง (ตกแต่งเท่านั้น ไม่กินพื้นที่) */
.btn.red:not([disabled])::before, .btn.red:not([disabled])::after, .btn.green:not([disabled])::before, .btn.green:not([disabled])::after {
  content: ""; position: absolute; top: 50%; width: 6px; height: 6px; margin-top: -3px; transform: rotate(45deg);
  background: var(--tt-gold2); box-shadow: 0 0 0 1px rgba(58,35,18,.7); pointer-events: none; }
.btn.red:not([disabled])::before, .btn.green:not([disabled])::before { left: 12px; }
.btn.red:not([disabled])::after, .btn.green:not([disabled])::after { right: 12px; }
.btn.hint, .actions .btn.hint {
  color: #5c3a00; text-shadow: none; border: 2px solid var(--tt-brown);
  background: linear-gradient(180deg, #fff1b8, #f3d272 60%, #e2b54a);
  box-shadow: inset 0 0 0 1px #fff6d0, 0 4px 0 rgba(58,35,18,.6);
}
.btn.hint:active { box-shadow: inset 0 0 0 1px #fff6d0, 0 1px 0 rgba(58,35,18,.6); }
.btn.link { background: transparent; color: var(--tt-blue); border-color: transparent; box-shadow: none; text-shadow: none; text-decoration: underline; }
.btn.sm { border-radius: 4px; }

/* ---------- ตัวเลือก ---------- */
.opt {
  position: relative; color: var(--tt-ink);
  background: linear-gradient(180deg, #fffcf3, #f7ecd0); border: 2px solid #b99a66; border-radius: 6px;
  box-shadow: inset 0 0 0 1px #fffaea, 0 2px 0 rgba(58,35,18,.25);
}
.opt .mark { border: 2px solid var(--tt-tan); background: #fffdf6; border-radius: 3px; }
.opt.single .mark { border-radius: 50%; }
.opt:hover:not([disabled]) { border-color: var(--tt-brown); }
.opt[aria-pressed="true"] {
  border-color: var(--tt-blue); background: linear-gradient(180deg, #eef3fc, #dce7f8);
  box-shadow: inset 0 0 0 1px #fff, inset 4px 0 0 var(--tt-gold), 0 2px 0 rgba(13,58,120,.35);
}
.opt[aria-pressed="true"] .mark { background: var(--tt-blue); border-color: var(--tt-night); color: #fff; }
.opt.is-right { border-color: var(--tt-green); background: linear-gradient(180deg, #eef5e0, #dfebcb); box-shadow: inset 4px 0 0 var(--tt-green), 0 2px 0 rgba(11,74,39,.3); }
.opt.is-wrong { border-color: var(--tt-red); background: linear-gradient(180deg, #fbe9e1, #f4d6ca); box-shadow: inset 4px 0 0 var(--tt-red), 0 2px 0 rgba(110,20,15,.3); }
.opt.is-missed { border-style: dashed; border-color: var(--tt-green); }

/* ---------- กล่องผลตอบ ---------- */
.fb {
  position: relative; color: var(--tt-ink); border: 2px solid var(--tt-brown); border-radius: 6px; padding: 10px 12px 10px 16px;
  background-image: var(--tt-grain); box-shadow: inset 0 0 0 1px rgba(255,250,234,.8), 0 3px 0 rgba(32,16,4,.3);
}
.fb::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; border-radius: 3px 0 0 3px; }
.fb.good { background-color: #e7f0d6; border-left: 2px solid var(--tt-brown); }
.fb.good::before { background: linear-gradient(180deg, #2a9a58, var(--tt-green)); }
.fb.bad { background-color: #f9e2d8; border-left: 2px solid var(--tt-brown); }
.fb.bad::before { background: linear-gradient(180deg, #e2483c, var(--tt-red)); }
.fb.mid { background-color: #f9eac4; border-left: 2px solid var(--tt-brown); }
.fb.mid::before { background: linear-gradient(180deg, #f0c75a, #b9821f); }
.fb > b:first-child, .fb > strong:first-child { font-family: var(--fh); color: var(--tt-blue); }
.hintbox { background: #fdf1c9; border: 2px dashed var(--tt-tan); border-radius: 6px; color: var(--tt-ink); }

/* ---------- ฉากหาจุดอันตราย ---------- */
.scene { border: 2px solid var(--tt-brown); border-radius: 6px; box-shadow: inset 0 0 0 1px var(--tt-gold), 0 3px 0 rgba(32,16,4,.4); }
.scene:focus-visible { outline: 3px solid var(--tt-blue); }
.counter i { background: #e2d2a8; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(90,61,34,.35); }
.counter i.on { background: linear-gradient(180deg, #2a9a58, var(--tt-green)); box-shadow: inset 0 0 0 1px var(--tt-greend); }
.found li { background: #e7f0d6; border: 1.5px solid rgba(23,112,61,.45); border-radius: 4px; color: var(--tt-ink); }
.found li b { color: var(--tt-green); }

/* ---------- เรียงลำดับ ---------- */
.seq li { background: linear-gradient(180deg, #fffcf3, #f7ecd0); border: 2px solid #b99a66; border-radius: 6px; box-shadow: 0 2px 0 rgba(58,35,18,.22); }
.seq .n { border-radius: 4px; font-family: var(--fh); color: #fff; text-shadow: 0 1px 0 #041633;
  background: var(--tt-strip); box-shadow: inset 0 0 0 1px var(--tt-gold), 0 0 0 2px var(--tt-brown); }
.seq .mv button { border: 2px solid var(--tt-brown); border-radius: 4px; color: var(--tt-blue);
  background: linear-gradient(180deg, #fffaf0, var(--tt-paper1)); box-shadow: 0 2px 0 rgba(32,16,4,.35); }
.seq .mv button:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(32,16,4,.35); }
.seq li.is-right { border-color: var(--tt-green); background: #e7f0d6; }
.seq li.is-wrong { border-color: var(--tt-red); background: #f9e2d8; }

/* ---------- สัญญาณชีพ ---------- */
.vrow { background: linear-gradient(180deg, #fffcf3, #f7ecd0); border: 2px solid #b99a66; border-radius: 6px; }
.vrow label { color: var(--tt-blue); font-family: var(--fh); font-weight: 600; }
.vrow select, .vrow input, .field, textarea, .namein:not(.me) {
  border: 2px solid var(--tt-tan); border-radius: 4px; background: #fffdf6; color: var(--tt-ink);
  box-shadow: inset 0 2px 0 rgba(90,61,34,.12);
}
.vrow select:focus, .vrow input:focus, .field:focus, textarea:focus { border-color: var(--tt-blue); }
.field::placeholder, textarea::placeholder, .namein::placeholder { color: #7a6243; }
.vrow .unit { color: var(--muted); }
.device { background: #10231b; color: #8ff5bf; border: 2px solid var(--tt-brown); border-radius: 4px; box-shadow: inset 0 0 0 1px #2c5a43; }
.measure { border: 2px solid var(--tt-blue); color: var(--tt-blue); background: #fffaf0; border-radius: 4px; box-shadow: 0 2px 0 rgba(13,58,120,.35); }
.vrow.is-right { border-color: var(--tt-green); background: #e7f0d6; }
.vrow.is-wrong { border-color: var(--tt-red); background: #f9e2d8; }

/* ---------- โทร 1669 ---------- */
.bubble { border-radius: 8px; border: 2px solid var(--tt-brown); box-shadow: 0 2px 0 rgba(32,16,4,.28); }
.bubble.them { background: #fffaf0; color: var(--tt-ink); border-bottom-left-radius: 2px; }
.bubble.me { background: var(--tt-strip); color: #fff; border-bottom-right-radius: 2px; }
.bubble.me.bad { background: linear-gradient(180deg, #d83a2f, #a6241c); }
.bubble .who { opacity: 1; color: var(--tt-ink2); font-family: var(--fh); }
.bubble.me .who { color: var(--tt-gold2); }
.callbar { background: #e7f0d6; border: 2px solid var(--tt-brown); border-radius: 4px; color: var(--tt-greend); box-shadow: 0 2px 0 rgba(32,16,4,.25); }
.callbar .t, .callbar b, .callbar time { color: #9e1f17; }
.alert { background: linear-gradient(180deg, #d0362b, #a6241c); border: 2px solid var(--tt-redd); border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--tt-gold2), 0 3px 0 var(--tt-redd); }
.tempo { border-radius: 6px; }

/* ---------- บรีฟ / การ์ดภารกิจ ---------- */
.meta { gap: 6px; }
.pill { background: linear-gradient(180deg, #fff8e6, #f0e1ba); color: var(--tt-blue); border: 1.5px solid #b99a66; border-radius: 4px; font-family: var(--fh); }
.pill.exp { background: linear-gradient(180deg, #ffe58a, #f2c84b); color: #4a2f00; border-color: #8a5f12; }
.pill.ok { background: #e2edcd; color: var(--tt-greend); border-color: var(--tt-green); }
.brief-img { border: 2px solid var(--tt-brown); border-radius: 6px; box-shadow: inset 0 0 0 1px var(--tt-gold), 0 3px 0 rgba(32,16,4,.35); background: var(--tt-paper1); }
.yt { background: linear-gradient(180deg, #fffaf0, var(--tt-paper1)); border: 2px solid var(--tt-brown); border-radius: 6px; color: var(--tt-ink);
  box-shadow: inset 0 0 0 1px #fffaea, 0 3px 0 rgba(32,16,4,.3); }
.yt span { border-radius: 4px; }
.situation { background: rgba(255,250,234,.6); border: 1.5px solid rgba(169,130,76,.6); border-radius: 4px; padding: 8px 10px; }
.sheet .step-kicker { color: var(--tt-ink2); }

/* ---------- แผนที่ ---------- */
.hero {
  position: relative; background: var(--tt-strip); color: #fff; border: 2px solid var(--tt-brown); border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--tt-gold), inset 0 0 0 3px rgba(10,33,71,.9), inset 0 0 0 4px rgba(226,181,74,.35), 0 3px 0 rgba(32,16,4,.45);
}
.hero::after { content: ""; position: absolute; left: 16px; right: 16px; top: 3px; height: 1px; background: linear-gradient(90deg, transparent, rgba(247,220,138,.8), transparent); pointer-events: none; }
.hero .namein:not(.me) { background: #fffdf6; border-color: var(--tt-gold); }
.lvbox { border: 2px solid var(--tt-gold); border-radius: 4px; background: rgba(4,22,51,.45); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.lvbox small { opacity: 1; color: var(--tt-gold2); }
.expbox { border-radius: 4px; color: #3d2600; background: linear-gradient(180deg, #ffe58a, #f2c84b 60%, #d9a52a); border: 2px solid var(--tt-brown); box-shadow: inset 0 0 0 1px #fff3c4; }
.progline { color: #fff; }
.bigbar { height: 10px; border-radius: 2px; background: #061a3a; box-shadow: inset 0 0 0 1px rgba(226,181,74,.6); }
.bigbar i { background: linear-gradient(180deg, #ffe58a, #e2b54a 60%, #b9821f); }
.mapwrap { border: 2px solid var(--tt-brown); border-radius: 6px; box-shadow: inset 0 0 0 1px var(--tt-gold), 0 3px 0 rgba(32,16,4,.45); }
.mapwrap::before { content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none; border-radius: 4px;
  box-shadow: inset 0 0 0 2px var(--tt-gold), inset 0 0 0 4px rgba(58,35,18,.55); }
.legend { color: var(--tt-ink); background: rgba(255,250,234,.72); border: 1.5px solid rgba(169,130,76,.7); border-radius: 4px; padding: 6px 10px; margin: 8px 0; }
.legend .dot { box-shadow: 0 0 0 1.5px var(--tt-brown); }
.underbar p, .underbar .muted { color: var(--tt-ink); }
.dp { background: var(--tt-strip); border: 2px solid var(--tt-brown); border-radius: 4px; box-shadow: inset 0 0 0 1px var(--tt-gold), 0 3px 0 var(--tt-brown); }
.dp:active { box-shadow: inset 0 0 0 1px var(--tt-gold), 0 1px 0 var(--tt-brown); }
.dp-up::after { border-bottom-color: var(--tt-gold2); } .dp-down::after { border-top-color: var(--tt-gold2); }
.dp-left::after { border-right-color: var(--tt-gold2); } .dp-right::after { border-left-color: var(--tt-gold2); }
.mitem { background: linear-gradient(180deg, #fffaf0, var(--tt-paper1)); border: 2px solid var(--tt-brown); border-radius: 6px; color: var(--tt-ink); box-shadow: var(--tt-win-shadow); }
.mitem .no { border-radius: 4px; transform: none; border: 2px solid var(--tt-redd); box-shadow: inset 0 0 0 1px var(--tt-gold2), 0 3px 0 var(--tt-redd); }
.mitem .t small { color: var(--muted); }
.firsttime { background: rgba(255,250,234,.8); border: 1.5px solid var(--tt-tan); border-radius: 4px; }
.firsttime b { color: var(--tt-blue); }
.demobar button { border-radius: 4px; border-color: var(--tt-amber); color: var(--tt-amber); background: #fffaf0; min-height: 44px; }
.badge.unlock { background: linear-gradient(180deg, #eef3fc, #dce7f8); border-color: var(--tt-blue2); }

/* ---------- หน้าต่าง modal ---------- */
.modal { background: rgba(20,12,4,.62); }
.modal .box { border: 2px solid var(--tt-brown); border-radius: 6px; background-color: var(--tt-paper);
  background-image: var(--tt-grain), linear-gradient(180deg, var(--tt-paper), var(--tt-paper2));
  box-shadow: inset 0 0 0 1px #fffaea, inset 0 0 0 2px var(--tt-tan), 0 6px 0 rgba(20,10,2,.5); color: var(--tt-ink); }
.modal .head { background: var(--tt-strip); border-bottom: 2px solid var(--tt-gold); font-family: var(--fh); text-shadow: 0 1px 0 #041633; }
.modal .body h4 { color: var(--tt-ink2); }

/* ---------- กล่องบทพูด: กระดาษ + ป้ายชื่อน้ำเงินขอบทอง ---------- */
.dlg { background: rgba(20,12,4,.32); }
.dlg-box {
  color: var(--tt-ink); border: 2px solid var(--tt-brown); outline: 0; border-radius: 6px;
  background-color: var(--tt-paper);
  background-image: var(--tt-rivets), var(--tt-grain), linear-gradient(180deg, #fffaea 0%, var(--tt-paper1) 55%, var(--tt-paper2) 100%);
  box-shadow: inset 0 0 0 1px #fffaea, inset 0 0 0 3px var(--tt-tan), inset 0 0 0 4px rgba(58,35,18,.35), 0 5px 0 rgba(20,10,2,.5);
}
.dlg-face { border: 2px solid var(--tt-brown); background: radial-gradient(90% 80% at 50% 30%, #8fc0ef 0%, #2a5fae 60%, #123a78 100%);
  box-shadow: inset 0 0 0 1.5px var(--tt-gold), 0 2px 0 rgba(32,16,4,.4); border-radius: 4px; }
.dlg-who { background: var(--tt-strip); color: #fff; border: 2px solid var(--tt-brown); border-radius: 4px;
  box-shadow: inset 0 0 0 1px var(--tt-gold), 0 3px 0 rgba(20,10,2,.4); text-shadow: 0 1px 0 #041633; }
.dlg-who .draft { color: #6b3f00; }
.dlg-text { color: var(--tt-ink); }
.dlg-more { border-top-color: var(--tt-red); filter: drop-shadow(0 1px 0 rgba(58,35,18,.5)); }
.dlg-skip { background: linear-gradient(180deg, #fffaf0, var(--tt-paper1)); color: var(--tt-blue); border: 2px solid var(--tt-brown); border-radius: 4px;
  box-shadow: inset 0 0 0 1px #fffaea, inset 0 0 0 2px rgba(169,130,76,.55), 0 3px 0 rgba(20,10,2,.45); }

/* ---------- เมนูในเกม ---------- */
.menu { background: rgba(20,12,4,.55); }
.menu-box { color: var(--tt-ink); border: 2px solid var(--tt-brown); outline: 0; border-radius: 6px; overflow: hidden;
  background-color: var(--tt-paper); background-image: var(--tt-grain), linear-gradient(180deg, #fffaea, var(--tt-paper1) 50%, var(--tt-paper2));
  box-shadow: inset 0 0 0 1px #fffaea, inset 0 0 0 2px var(--tt-tan), 0 6px 0 rgba(20,10,2,.5); }
.menu-head { background: var(--tt-strip); border-bottom: 2px solid var(--tt-gold); text-shadow: 0 1px 0 #041633; letter-spacing: .03em; }
.menu-x { color: var(--tt-gold2); }
.menu-tabs { border-bottom: 2px solid var(--tt-brown); background: linear-gradient(180deg, #efe0b8, #e4d09f); }
.menu-tabs button { color: var(--tt-ink2); }
.menu-tabs button[aria-selected="true"] { color: var(--tt-blue); border-bottom-color: var(--tt-red);
  background: linear-gradient(180deg, rgba(255,250,234,.85), rgba(255,250,234,.35)); }
.menu-body h4 { color: var(--tt-blue); display: flex; align-items: center; gap: 8px; }
.menu-body h4::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--tt-gold), transparent); }
.st-av { border: 2px solid var(--tt-brown); border-radius: 4px; background: radial-gradient(90% 80% at 50% 30%, #8fc0ef 0%, #2a5fae 60%, #123a78 100%);
  box-shadow: inset 0 0 0 1.5px var(--tt-gold), 0 2px 0 rgba(32,16,4,.35); }
.st-name { color: var(--tt-blue); }
.st-exp small { color: var(--muted); }
.expbar { border: 2px solid var(--tt-brown); border-radius: 2px; background: #2a1a0c; }
.expbar i { background: linear-gradient(180deg, #ffe58a, #e2b54a 60%, #b9821f); }
.sbar { border: 2px solid var(--tt-brown); border-radius: 2px; background: #eadbb3; box-shadow: inset 0 1px 0 rgba(58,35,18,.2); }
.sbar i { background: linear-gradient(180deg, #3d7fd4, var(--tt-blue2) 50%, var(--tt-blue)); }
.stats4 dd b { color: var(--tt-blue); }
.bag li { border: 2px solid #b99a66; background: rgba(255,250,234,.6); color: var(--tt-ink); }
.bag li.got { border-color: var(--tt-brown); background: linear-gradient(180deg, #fffaf0, #f3e3b8); box-shadow: inset 0 0 0 1px var(--tt-gold); }
.bag li small, .journal small { color: var(--muted); }
.journal li { border-bottom: 1px solid rgba(169,130,76,.55); }
.journal .jwrap { background: radial-gradient(90% 80% at 50% 30%, #fff8e6 0%, #eadbb3 100%); border: 1.5px solid var(--tt-tan); }
.badges li { color: var(--muted); }
.badges li.on { color: var(--tt-ink); }
.badges li.on .ic { color: var(--tt-goldd); }
.set-row { border-bottom: 1px solid rgba(169,130,76,.55); }
.switch { border: 2px solid var(--tt-brown); border-radius: 4px; background: #eadbb3; color: var(--tt-ink); }
.switch[aria-checked="true"] { background: linear-gradient(180deg, #2a9a58, var(--tt-green)); color: #fff; }
.seg { border: 2px solid var(--tt-brown); border-radius: 4px; }
.seg button { background: #fffaf0; color: var(--tt-ink); }
.seg button[aria-pressed="true"] { background: var(--tt-strip); color: #fff; }

/* ---------- หน้าเริ่มเกม: รายการเมนูเป็นแผ่นกระดาษ / แผ่นแดงขอบทอง ---------- */
.tmi {
  color: var(--tt-ink); border: 2px solid var(--tt-brown); border-radius: 6px;
  background: linear-gradient(180deg, rgba(255,250,234,.97), rgba(240,225,186,.97));
  box-shadow: inset 0 0 0 1px #fffaea, inset 0 0 0 2px rgba(169,130,76,.6), 0 4px 0 rgba(20,10,2,.5);
}
.tmi .cur { border-left-color: var(--tt-red); }
.tmi-t small { opacity: 1; color: var(--tt-ink2); }
.tmi.primary, .tmi:focus {
  color: #fff; border-color: var(--tt-redd);
  background: linear-gradient(180deg, #cf3a2f 0%, #b8281f 45%, #8f1c15 100%);
  box-shadow: inset 0 0 0 1px var(--tt-gold2), inset 0 0 0 3px rgba(110,20,15,.6), inset 0 2px 0 3px rgba(255,255,255,.14), 0 4px 0 var(--tt-redd);
  text-shadow: 0 1px 0 rgba(60,8,4,.7);
}
.tmi.primary .tmi-t small, .tmi:focus .tmi-t small { color: #fff3d6; }
.tmi:focus { box-shadow: inset 0 0 0 1px var(--tt-gold2), inset 0 0 0 3px rgba(110,20,15,.6), 0 4px 0 var(--tt-redd), 0 0 0 3px rgba(247,220,138,.85); }
.tmi.primary .cur, .tmi:focus .cur { border-left-color: var(--tt-gold2); }
.tmi:active { box-shadow: inset 0 0 0 1px var(--tt-gold2), 0 1px 0 var(--tt-redd); }
.ticon { border-radius: 6px; }

/* ---------- แผงเผชิญหน้าแบบเก่า (เมื่อยังไม่ใช้ tac-battle) ---------- */
.enc:not(.tac-enc) { border-color: var(--tt-brown); background: linear-gradient(180deg, var(--tt-paper), var(--tt-paper2)); box-shadow: inset 0 -1px 0 var(--tt-gold), 0 3px 0 rgba(32,16,4,.4); }
.enc:not(.tac-enc) .enc-lab { color: var(--tt-blue); }
.enc:not(.tac-enc) .enc-stage { border: 2px solid var(--tt-brown); border-radius: 4px; box-shadow: inset 0 0 0 1px var(--tt-gold); }
.enc:not(.tac-enc) .meter { border-color: var(--tt-brown); background: var(--tt-brown); border-radius: 2px; }
.enc:not(.tac-enc) .cmds { background: var(--tt-strip); border: 2px solid var(--tt-brown); box-shadow: inset 0 0 0 1px var(--tt-gold); }
.enc:not(.tac-enc) .cmds li { border-color: rgba(226,181,74,.35); color: #fff; }
.enc:not(.tac-enc) .cmds li.on { color: #fff; background: rgba(255,255,255,.14); border-color: var(--tt-gold); }

/* ---------- หน้าสรุปผล ---------- */
.score-big { padding: 4px 0 2px; }
.ring text { fill: var(--tt-blue); font-family: var(--fh); }
.verdict { font-family: var(--fh); letter-spacing: .02em; }
.verdict.pass { color: var(--tt-green); text-shadow: 0 1px 0 #fffaea; }
.verdict.fail { color: var(--tt-red); }
.rub .r { color: var(--tt-ink); }
.rub .r .top b { color: var(--tt-blue); font-family: var(--fh); font-variant-numeric: tabular-nums; }
.rub .bar { height: 10px; border-radius: 2px; background: #eadbb3; border: 1.5px solid var(--tt-brown); box-shadow: inset 0 1px 0 rgba(58,35,18,.2); }
.rub .bar i { background: linear-gradient(180deg, #3d7fd4, var(--tt-blue2) 50%, var(--tt-blue)); box-shadow: inset 0 1px 0 rgba(255,255,255,.3); }
.rub .r.locked .bar i { background: linear-gradient(180deg, #e2483c, var(--tt-red)); }
.badge { background: linear-gradient(180deg, #fff6d6, #f6e3a6); border: 2px solid var(--tt-brown); border-radius: 6px; color: var(--tt-ink);
  box-shadow: inset 0 0 0 1px #fffaea, inset 0 0 0 2px rgba(226,181,74,.7), 0 3px 0 rgba(32,16,4,.32); }
.badge .ic { color: var(--tt-goldd); }
.badge small, .badge .muted { color: var(--tt-ink2); }
.badge.unlock .ic { color: var(--tt-blue); }
.levelup { position: relative; background: var(--tt-strip); border: 2px solid var(--tt-brown); border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--tt-gold), inset 0 0 0 3px rgba(10,33,71,.9), inset 0 0 0 4px rgba(226,181,74,.4), 0 3px 0 rgba(32,16,4,.45); }
.levelup b { color: var(--tt-gold2); letter-spacing: .04em; text-shadow: 0 1px 0 #041633; }
.stats b { color: var(--tt-blue); }
.history td, .history th { border-color: rgba(169,130,76,.55); }
.history th { color: var(--tt-ink2); }

/* ---------- ตอนจบ / ใบประกาศ ---------- */
.end-box { color: var(--tt-ink); border: 2px solid var(--tt-brown); outline: 0; border-radius: 6px;
  background-color: var(--tt-paper); background-image: var(--tt-rivets), var(--tt-grain), linear-gradient(180deg, #fffaea, var(--tt-paper2));
  box-shadow: inset 0 0 0 1px #fffaea, inset 0 0 0 3px var(--tt-tan), 0 6px 0 rgba(20,10,2,.5); }
.end-box h2 { color: var(--tt-blue); }
.certwrap { border: 2px solid var(--tt-brown); box-shadow: inset 0 0 0 1px var(--tt-gold); }

/* ---------- หน้าเข้าห้อง ---------- */
.avatar { background: linear-gradient(180deg, #fffcf3, #f7ecd0); border: 2px solid #b99a66; border-radius: 6px; color: var(--tt-ink); }
.avatar[aria-pressed="true"] { border-color: var(--tt-blue); background: linear-gradient(180deg, #eef3fc, #dce7f8); box-shadow: inset 0 0 0 1px #fff, 0 0 0 2px var(--tt-gold); }
.card.login .lead { color: var(--muted); }
.who { color: var(--tt-ink); }
.who-av { border: 1.5px solid var(--tt-brown); border-radius: 3px; }

@media (prefers-reduced-motion: reduce) {
  .btn:active, .iconbtn:active, .dp:active, .tmi:active { transform: none; }
}

/* ---------- รอบขัดเงา: ป้ายชื่อเกม · สมุดบันทึกผล · ตัวเลขบนฉาก ---------- */
.topbar .brand { position: relative; padding-bottom: 6px; }
.topbar .brand::after { content: ""; position: absolute; left: 0; bottom: 0; width: min(160px, 70%); height: 2px;
  background: linear-gradient(90deg, var(--tt-gold) 0%, rgba(226,181,74,.5) 70%, transparent); }
.rub { padding: 10px 12px; border: 1.5px solid rgba(169,130,76,.75); border-radius: 4px;
  background: rgba(255,250,234,.65); box-shadow: inset 0 1px 0 rgba(255,255,255,.7); }
.rub .bar { position: relative; }
.rub .bar::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(43,26,12,.28) calc(10% - 1px) 10%); }
.score-big + * { color: var(--tt-ink); }
.scene .num { text-shadow: 0 1px 2px rgba(0,0,0,.85), 0 0 1px #000; }
.scene .tap.hit { background: rgba(23,112,61,.62); box-shadow: 0 0 0 3px var(--tt-green), 0 0 0 5px rgba(247,220,138,.85); }
