/* ═══ เถ้าแห่งคำสาป v3.0 — targeting · tribes · deck builder · tutorial · credits ═══ */

/* ——— 2 · Spell targeting: ember trail + rune reticle ——— */
.aim-arrow.aim-v3 { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 40; opacity: 0; transition: opacity .18s ease; overflow: visible; }
.aim-arrow.aim-v3.show { opacity: 1; }
.aim-v3 #aim-path { animation: aimFlow .9s linear infinite; }
@keyframes aimFlow { to { stroke-dashoffset: -20; } }
.aim-v3 .mote { fill: #fff3c0; filter: drop-shadow(0 0 4px var(--aim-c, #ffb347)); }
.aim-v3 #aim-reticle { transition: transform .14s cubic-bezier(.2,.9,.3,1.2); }
.aim-v3 .rt-scale { transform: scale(.55); opacity: .55; transition: transform .22s cubic-bezier(.2,.9,.3,1.3), opacity .2s ease; }
.aim-v3.locked .rt-scale { transform: scale(1); opacity: 1; }
.aim-v3 .rt-outer { animation: rtSpin 9s linear infinite; transform-origin: 0 0; }
.aim-v3 .rt-inner { animation: rtSpin 6s linear infinite reverse; transform-origin: 0 0; }
.aim-v3 .rt-core { opacity: 0; transition: opacity .2s ease; }
.aim-v3.locked .rt-core { opacity: 1; animation: rtPulse 1.4s ease-in-out infinite; }
.aim-v3 .rt-runes { font-family: "Segoe UI Symbol", "Noto Sans Runic", serif; letter-spacing: 1px; }
@keyframes rtSpin { to { transform: rotate(360deg); } }
@keyframes rtPulse { 0%, 100% { opacity: .65; } 50% { opacity: 1; } }
/* reduced motion: static sigil, no motes, no flowing dash */
.aim-v3.rm #aim-motes { display: none; }
.aim-v3.rm #aim-path, .aim-v3.rm .rt-outer, .aim-v3.rm .rt-inner, .aim-v3.rm .rt-core { animation: none !important; }
.aim-v3.rm #aim-reticle, .aim-v3.rm .rt-scale { transition: none; }
/* target highlight + dim the others */
.screen.battle.aiming.aim-has-lock .enemy:not(.dead):not(.aim-lock) { filter: brightness(.5) saturate(.6); transform: scale(.96); }
.screen.battle.aiming .enemy { transition: filter .2s ease, transform .2s ease; }
.screen.battle.aiming .enemy.aim-lock { filter: drop-shadow(0 0 14px var(--aim-glow, #ffb347aa)); transform: scale(1.06); }
.screen.battle.aiming .enemy.aim-lock .portrait { outline: 2px solid #fff3c0; outline-offset: 3px; box-shadow: 0 0 26px #ffb34799; }
.screen.battle.aiming .enemy:not(.dead):hover .portrait { outline: none; }
.screen.battle.aiming .enemy.aim-lock .target-mark { opacity: 0; }

/* ——— 4/5 · Tribe crest on cards ——— */
.card .tribe-crest {
  position: absolute; z-index: 6; right: 3px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; line-height: 1; color: #fff8e6;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--tc) 70%, #fff 30%), color-mix(in srgb, var(--tc) 55%, #000 45%) 70%);
  border: 1.5px solid #e9cf8f; box-shadow: 0 2px 6px #000c, 0 0 8px color-mix(in srgb, var(--tc) 60%, transparent), inset 0 1px 0 #fff6;
  text-shadow: 0 1px 1px #000;
  pointer-events: none;
}
.card.sm .tribe-crest { width: 16px; height: 16px; font-size: 9px; }
.card.lg .tribe-crest, .card.xl .tribe-crest { width: 28px; height: 28px; font-size: 15px; }
.card .name-bar { position: relative; padding-right: 24px; padding-left: 24px; }
.card.sm .name-bar { padding-right: 18px; padding-left: 18px; }
.tribe-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 700;
  border: 1px solid color-mix(in srgb, var(--tc) 60%, #000); background: color-mix(in srgb, var(--tc) 18%, #120d08); color: color-mix(in srgb, var(--tc) 55%, #fff); }

/* ——— shared carved-panel look ——— */
.v3-decks, .v3-pick, .v3-credits {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 30%, #2a1a0ccc, #070504f2 70%);
  animation: v3Fade .25s ease;
}
.v3-decks[hidden], .v3-credits[hidden] { display: none; }
@keyframes v3Fade { from { opacity: 0; } }
.v3d-panel, .v3-pick-card, .v3c-frame {
  position: relative; color: var(--ink);
  background:
    linear-gradient(180deg, #ffffff0a, transparent 30%),
    repeating-linear-gradient(115deg, #ffffff04 0 2px, transparent 2px 7px),
    linear-gradient(180deg, #221a12, #120d09);
  border: 1px solid color-mix(in srgb, var(--brass) 55%, #000);
  border-radius: 18px;
  box-shadow: 0 30px 80px #000d, inset 0 1px 0 #ffffff1c, inset 0 0 0 4px #0008, inset 0 0 0 5px color-mix(in srgb, var(--brass) 30%, transparent), 0 0 40px color-mix(in srgb, var(--tc, var(--brass)) 18%, transparent);
}
.v3d-panel::before, .v3c-frame::before { /* carved corner studs */
  content: ""; position: absolute; inset: 8px; pointer-events: none; border-radius: 12px;
  background:
    radial-gradient(circle at 0 0, var(--gold2) 0 2px, transparent 3px) 0 0 / 50% 50% no-repeat,
    radial-gradient(circle at 100% 0, var(--gold2) 0 2px, transparent 3px) 100% 0 / 50% 50% no-repeat,
    radial-gradient(circle at 0 100%, var(--gold2) 0 2px, transparent 3px) 0 100% / 50% 50% no-repeat,
    radial-gradient(circle at 100% 100%, var(--gold2) 0 2px, transparent 3px) 100% 100% / 50% 50% no-repeat;
  opacity: .7;
}
body.v3-modal-open { overflow: hidden; }

/* ——— 4 · Deck builder ——— */
.v3d-panel { width: min(1180px, 100vw - 16px); height: min(860px, 100dvh - 16px); display: flex; flex-direction: column; padding: 14px 16px 12px; gap: 10px; overflow: hidden; }
.v3d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.v3d-head h3 { margin: 0; font-size: 1.35rem; color: var(--gold2); letter-spacing: .03em; text-shadow: 0 2px 0 #000; }
.v3d-rule { margin: 2px 0 0; font-size: .78rem; color: var(--muted); }
.v3d-rule b { color: color-mix(in srgb, var(--tc) 60%, #fff); }
.v3d-tribes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.v3d-tribe { display: flex; gap: 8px; align-items: center; text-align: left; padding: 7px 9px; border-radius: 12px; cursor: pointer; color: var(--ink); font: inherit;
  background: linear-gradient(180deg, #1d1610, #110c08); border: 1px solid #3a3026; transition: border-color .2s, box-shadow .2s, transform .15s; }
.v3d-tribe .cr { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 16px;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--tc) 70%, #fff 30%), color-mix(in srgb, var(--tc) 45%, #000) 70%); border: 1.5px solid #e9cf8f; box-shadow: 0 2px 6px #000a; }
.v3d-tribe b { display: block; font-size: .82rem; } .v3d-tribe small { display: block; font-size: .66rem; color: var(--muted); line-height: 1.2; }
.v3d-tribe.on { border-color: var(--tc); box-shadow: 0 0 0 1px var(--tc), 0 0 18px color-mix(in srgb, var(--tc) 35%, transparent), inset 0 0 20px color-mix(in srgb, var(--tc) 14%, transparent); transform: translateY(-1px); }
.v3d-decks { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.v3d-decks .pm-input { min-height: 36px; padding: 6px 10px; }
.v3d-sel { flex: 1 1 160px; } .v3d-name { flex: 1 1 140px; }
.btn.sm { padding: 7px 11px; font-size: .78rem; min-height: 36px; }
.v3d-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 290px; gap: 12px; }
.v3d-col { min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.v3d-filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip-btn { font: inherit; font-size: .76rem; padding: 5px 11px; border-radius: 99px; border: 1px solid #4a3e30; background: #18120d; color: var(--muted); cursor: pointer; }
.chip-btn.on { color: #1a1208; background: linear-gradient(180deg, var(--gold2), var(--brass)); border-color: var(--gold2); font-weight: 700; }
.v3d-hint { margin-left: auto; font-size: .72rem; color: var(--muted); }
.v3d-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; padding: 4px 4px 20px; align-content: start; }
.v3d-grid .card.v3d-card { width: 100%; height: auto; aspect-ratio: 5 / 7.4; cursor: pointer; transform: none; margin: 0; position: relative; transition: transform .15s ease, filter .2s; }
.v3d-grid .card.v3d-card:hover { transform: translateY(-3px); }
.v3d-grid .card.v3d-card.locked { filter: grayscale(.9) brightness(.45); }
.v3d-n { position: absolute; right: -4px; bottom: -4px; z-index: 9; min-width: 26px; padding: 2px 6px; border-radius: 99px; text-align: center; font-weight: 800; font-size: .8rem;
  color: #1a1208; background: linear-gradient(180deg, #fff3c0, var(--brass)); box-shadow: 0 2px 6px #000c; }
.v3d-lock { position: absolute; inset: 0; z-index: 9; display: grid; place-content: center; text-align: center; font-size: 1.3rem; color: #fff; background: radial-gradient(circle, #000c 30%, #0008 70%); border-radius: var(--r-card); }
.v3d-lock small { display: block; font-size: .62rem; color: var(--gold2); }
.v3d-deck { min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; background: #0d0907cc; border: 1px solid #3a3026; box-shadow: inset 0 2px 12px #000a; }
.v3d-deck-head { display: flex; justify-content: space-between; align-items: center; }
.v3d-count { font-size: 1.3rem; color: var(--danger); } .v3d-count.ok { color: var(--ok); }
.v3d-stats { font-size: .74rem; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.v3d-curve { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; height: 44px; align-items: end; }
.v3d-curve i { position: relative; height: 100%; display: flex; align-items: flex-end; }
.v3d-curve i::before { content: ""; width: 100%; height: var(--h); min-height: 2px; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 80%, #fff), color-mix(in srgb, var(--tc) 40%, #000)); }
.v3d-curve em { position: absolute; top: -2px; left: 0; right: 0; text-align: center; font-style: normal; font-size: .62rem; color: var(--ink); }
.v3d-curve s { position: absolute; bottom: -13px; left: 0; right: 0; text-align: center; text-decoration: none; font-size: .6rem; }
.v3d-list { list-style: none; margin: 10px 0 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.v3d-list li { display: grid; grid-template-columns: 24px 1fr auto auto; gap: 6px; align-items: center; padding: 5px 8px; border-radius: 8px; cursor: pointer; font-size: .8rem;
  background: linear-gradient(90deg, #2a2016, #18120d); border: 1px solid #3a3026; transition: background .15s; }
.v3d-list li:hover { background: linear-gradient(90deg, #3a1a14, #18120d); }
.v3d-list li.type-unit { border-left: 3px solid #4fe3c1; } .v3d-list li.type-attack { border-left: 3px solid #ff5a3d; } .v3d-list li.type-skill { border-left: 3px solid #7ec8ff; }
.v3d-list li.type-buff, .v3d-list li.type-power { border-left: 3px solid #c79bff; } .v3d-list li.type-trap { border-left: 3px solid #d08a4a; }
.v3d-list .cost { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .72rem; background: radial-gradient(circle at 35% 30%, #9fd8ff, #1f5c9a); color: #fff; }
.v3d-list .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v3d-list .tcrest { font-size: .8rem; color: var(--tc); }
.v3d-list li.empty { cursor: default; color: var(--muted); grid-template-columns: 1fr; }
.v3d-valid { font-size: .76rem; padding: 6px 8px; border-radius: 8px; line-height: 1.3; }
.v3d-valid.ok { color: #bff0cf; background: #10301c; border: 1px solid #2f7a4a; } .v3d-valid.bad { color: #ffc6c6; background: #321214; border: 1px solid #7a2f36; }
@media (max-width: 760px) {
  .v3d-panel { width: 100vw; height: 100dvh; border-radius: 0; padding: 10px 10px 8px; gap: 7px; }
  .v3d-tribes { grid-template-columns: repeat(4, 1fr); }
  .v3d-tribe { flex-direction: column; justify-content: center; text-align: center; padding: 6px 2px; gap: 3px; }
  .v3d-tribe small { display: none; } .v3d-tribe b { font-size: .64rem; }
  .v3d-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .v3d-grid { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .v3d-deck { max-height: 30dvh; padding: 8px; gap: 5px; }
  .v3d-curve { display: none; }
  .v3d-decks .v3d-name { display: none; }
  .v3d-list { flex-direction: row; flex-wrap: wrap; margin-top: 12px; }
  .v3d-list li { grid-template-columns: 20px auto auto; font-size: .7rem; padding: 3px 6px; }
  .v3d-list li .tcrest { display: none; }
  .v3d-rule { font-size: .68rem; } .v3d-head h3 { font-size: 1.1rem; }
  .v3d-hint { display: none; }
  .v3d-decks .btn.sm { padding: 6px 8px; font-size: .7rem; }
}
.v3-hero-tribe { margin-top: 6px; }

/* deck choice modal */
.v3-pick-card { width: min(420px, 100vw - 24px); padding: 18px; text-align: center; }
.v3-pick-card h3 { margin: 2px 0 12px; color: var(--gold2); }
.v3-pick-list { display: flex; flex-direction: column; gap: 8px; max-height: 50dvh; overflow-y: auto; }
.v3-pick-opt { font: inherit; color: var(--ink); text-align: left; padding: 10px 12px; border-radius: 12px; cursor: pointer; background: #17110c; border: 1px solid #3a3026; }
.v3-pick-opt b { display: block; } .v3-pick-opt small { color: var(--muted); font-size: .74rem; }
.v3-pick-opt.on { border-color: var(--tc); box-shadow: 0 0 0 1px var(--tc), 0 0 16px color-mix(in srgb, var(--tc) 30%, transparent); }
.v3-pick-foot { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }

/* ——— 1 · Tutorial coach marks ——— */
.v3-coach { position: fixed; inset: 0; z-index: 85; pointer-events: none; opacity: 0; transition: opacity .25s ease; }
.v3-coach.show { opacity: 1; }
.v3-spot { position: fixed; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 9999px #050302b8, 0 0 0 2px var(--gold2), 0 0 24px 4px #ffb34788;
  transition: left .3s cubic-bezier(.3,.8,.3,1), top .3s cubic-bezier(.3,.8,.3,1), width .3s, height .3s; }
.v3-coach.show .v3-spot { animation: spotPulse 1.8s ease-in-out infinite; }
@keyframes spotPulse { 50% { box-shadow: 0 0 0 9999px #050302b8, 0 0 0 2px #fff3c0, 0 0 34px 8px #ffb347aa; } }
.v3-bubble { position: fixed; width: min(340px, calc(100vw - 16px)); pointer-events: auto; padding: 12px 14px 10px; border-radius: 14px; color: var(--ink);
  background: linear-gradient(180deg, #2b1f13f5, #140e09f5); border: 1px solid var(--brass); box-shadow: 0 16px 40px #000c, inset 0 1px 0 #ffffff1c;
  transition: top .3s cubic-bezier(.3,.8,.3,1), left .3s cubic-bezier(.3,.8,.3,1); }
.v3-b-step { font-size: .66rem; letter-spacing: .08em; color: var(--brass); text-transform: uppercase; }
.v3-bubble h4 { margin: 2px 0 4px; color: var(--gold2); font-size: 1rem; }
.v3-bubble p { margin: 0; font-size: .84rem; line-height: 1.45; }
.v3-bubble p b { color: #ffd38a; }
.v3-b-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 8px; }
.v3-skip { font: inherit; font-size: .74rem; color: var(--muted); background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 6px 2px; }
.v3-next { padding: 7px 16px; min-height: 36px; font-size: .84rem; }
body.v3-tut #tutorial-tip, body.v3-tut #class-tip { display: none !important; }
@media (prefers-reduced-motion: reduce) { .v3-coach.show .v3-spot { animation: none; } .v3-spot, .v3-bubble { transition: none; } }
body.reduce-motion .v3-coach.show .v3-spot { animation: none; }

/* ——— 8 · Credits ——— */
.v3c-frame { width: min(520px, 100vw - 20px); height: min(680px, 100dvh - 40px); padding: 22px 18px; }
.v3c-x { position: absolute; top: 10px; right: 10px; z-index: 3; }
.v3c-window { position: absolute; inset: 22px 18px; overflow: hidden; border-radius: 10px;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 14%, #000 86%, transparent); mask-image: linear-gradient(180deg, transparent, #000 14%, #000 86%, transparent); }
.v3c-roll { text-align: center; padding: 60% 6px 70%; animation: v3Roll 38s linear infinite; }
.v3c-window:hover .v3c-roll { animation-play-state: paused; }
.v3c-roll.still { animation: none; padding: 20px 6px; overflow-y: auto; height: 100%; box-sizing: border-box; }
@keyframes v3Roll { from { transform: translateY(0); } to { transform: translateY(-100%); } }
.v3c-roll h2 { margin: 4px 0 0; font-size: 1.9rem; color: var(--gold2); text-shadow: 0 2px 0 #000, 0 0 24px #ffb34766; letter-spacing: .04em; }
.v3c-sub { color: var(--muted); font-size: .8rem; letter-spacing: .12em; margin-bottom: 26px; }
.v3c-sigil { font-size: 1.6rem; color: var(--brass); text-shadow: 0 0 14px #ffb34788; } .v3c-sigil.end { margin-top: 30px; letter-spacing: .5em; font-size: 1.1rem; }
.v3c-roll h5 { margin: 28px 0 8px; font-size: .74rem; letter-spacing: .2em; color: var(--brass); text-transform: uppercase; }
.v3c-roll h5::before, .v3c-roll h5::after { content: " ✦ "; opacity: .6; }
.v3c-name { font-size: 1.35rem; font-weight: 800; color: #fff3dc; text-shadow: 0 0 18px #ffb34755; }
.v3c-roles { color: var(--gold2); font-size: .9rem; margin: 3px 0 6px; }
.v3c-tool { display: flex; flex-direction: column; gap: 1px; margin: 0 auto 12px; max-width: 380px; }
.v3c-tool b { color: var(--ink); } .v3c-tool span { color: var(--muted); font-size: .8rem; } .v3c-tool em { color: #9fd8b0; font-size: .72rem; font-style: normal; }
.v3d-body > * { min-width: 0; }
.v3d-grid .card.v3d-card { width: auto !important; max-width: none; min-width: 0; }
@media (max-width: 760px) {
  .v3d-body { grid-template-columns: minmax(0, 1fr); }
  .v3d-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .v3d-decks { flex-wrap: nowrap; } .v3d-sel { min-width: 0; flex: 1 1 auto; }
  .v3d-decks .btn.sm { white-space: nowrap; }
}
.v3d-card .kw, .v3d-card .kw-row { pointer-events: none; }
