:root {
  color-scheme: light;
  --paper: #f6f2e6;
  --cream: #fffaf0;
  --ink: #1d312f;
  --muted: #566050;
  --line: #e4dac3;
  --orange: #f58051;
  --rust: #9b3c21;
  --green: #557e5c;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); }
.hero-friends {
  position: absolute; inset: auto 10% 7%; display: flex; justify-content: center; gap: 22px; pointer-events: none;
}
.hero-friends .portrait { width: clamp(60px,10vw,108px); rotate: -8deg; }
.hero-friends .portrait:last-child { rotate: 8deg; }
.hero-friends figcaption { display: none; }
.hero-friends .portrait canvas { border: 4px solid #fff0cc; border-radius: 18px; }
.world-screen {
  position: relative; width: 100%; height: calc(100dvh - 150px); min-height: 330px;
  overflow: hidden; border-radius: 13px; background: #bcd5af; border: 1px solid #496653;
}
#world-canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.world-location {
  position: absolute; left: 12px; top: 12px; padding: 8px 12px; border-radius: 10px;
  color: #fff0d0; background: #20382ee6; pointer-events: none;
}
.world-location h1 { font-size: 22px; margin: 0; }
.world-location span { font-size: 12px; color: #e4dcc3; }
.world-toolbar { position: absolute; right: 12px; top: 12px; display: flex; gap: 6px; }
.world-help {
  position: absolute; left: 50%; bottom: 11px; translate: -50% 0; padding: 8px 12px;
  border-radius: 8px; background: #20382eda; color: #fff0d0; font-size: 12px; white-space: nowrap;
}
.world-prompt {
  position: absolute; left: 50%; top: 8px; translate: -50% 0; max-width: 36%;
  padding: 6px 10px; border-radius: 9px; background: #fff4dbed; color: #294634;
  text-align: center; font-size: 12px; pointer-events: none;
}
.walk-pad,.walk-actions,.world-touch-help { display: none; }
#settings-dialog {
  width: min(560px,calc(100% - 24px)); padding: 14px; border: 2px solid #aa8154; border-radius: 15px;
  background: #f8ecd1; color: #27382d; max-height: calc(100% - 16px); overflow: auto;
}
#settings-dialog::backdrop { background: #14271eb8; }
#settings-dialog header,.settings-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#settings-dialog header h2 { font-size: 22px; }
#settings-dialog section { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; margin-top: 5px; }
#settings-dialog h3 { grid-column: 1/-1; font-size: 13px; color: #57705b; }
#settings-dialog .sound-setting { padding: 8px; border-radius: 8px; background: #eddfbc; min-width: 0; }
#settings-dialog .sound-setting > label { display: flex; align-items: center; justify-content: space-between; min-height: 33px; }
#settings-dialog input[type="range"] { width: 100%; min-height: 32px; margin: 0; accent-color: #426b4d; }
#settings-dialog input[type="checkbox"] { width: 21px; height: 21px; accent-color: #426b4d; }
.settings-footer { margin-top: 8px; border-top: 1px solid #d4c39e; padding-top: 7px; }
#game-version { font-size: 12px; font-weight: 800; color: #64725b; }
.settings-footer .danger { color: #9f412e; border-color: #caac81; }
.school-notice {
  position:absolute; bottom:62px; left:50%; translate:-50% 0; max-width:calc(100% - 300px); padding:6px 10px;
  border:1px solid #cda661; border-radius:8px; background:#fff3d6f0; color:#354735; font-size:12px;
  pointer-events:none;
}
.map-art.school { background:repeating-linear-gradient(90deg,transparent 0 26px,#c2dedf 26px 43px,transparent 43px 58px),#c5d8af; }
#school-dialog {
  width:min(590px,calc(100% - 24px)); max-height:calc(100% - 16px); overflow:auto; padding:12px;
  border:2px solid #aa8154; border-radius:14px; color:#27382d; background:#f8ecd1;
}
#school-dialog::backdrop { background:#14271eb8; }
#school-dialog header { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
#school-dialog h2 { font-size:20px; }
#school-dialog-body { display:flow-root; font-size:14px; line-height:1.5; }
#school-dialog-body .portrait { float:left; width:78px; margin:0 12px 6px 0; }
#school-dialog .actions { justify-content:flex-end; flex-wrap:wrap; margin-top:9px; gap:5px; }
#school-dialog .actions button { min-height:36px; padding:5px 9px; font-size:13px; }
.school-reward-cards { display:flex; justify-content:center; gap:12px; margin-top:7px; }
.school-reward-cards .collectible { width:125px; }
.school-reward-cards canvas { width:58px; }
#name-dialog,#tutorial-dialog,#profile-dialog {
  width:min(650px,calc(100% - 24px)); max-height:calc(100% - 16px); overflow:auto;
  border:2px solid #aa8154; border-radius:14px; padding:12px; color:#27382d; background:#f8ecd1;
}
#name-dialog { width:min(390px,calc(100% - 24px)); }
#name-dialog::backdrop,#tutorial-dialog::backdrop,#profile-dialog::backdrop { background:#14271eb8; }
#name-form { display:grid; gap:8px; margin-top:10px; }
#player-name { min-height:44px; width:100%; padding:8px; font:inherit; border:1px solid #b9a47e; border-radius:8px; background:#fff9e9; }
#name-error { color:#a34e38; min-height:17px; font-size:12px; }
#name-form .actions,#tutorial-dialog .actions { justify-content:flex-end; gap:6px; }
#tutorial-dialog header,#profile-dialog header { display:flex; justify-content:space-between; align-items:center; gap:8px; }
#tutorial-dialog h2,#profile-dialog h2 { font-size:21px; }
#tutorial-progress { font-size:12px; white-space:nowrap; color:#68755d; }
#tutorial-copy { line-height:1.65; margin:18px 0; font-size:15px; }
.profile-layout { display:grid; grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr); gap:12px; margin-top:7px; }
#profile-stats { margin:0 0 5px; display:grid; grid-template-columns:auto minmax(0,1fr); gap:4px 7px; font-size:12px; }
#profile-stats dt { color:#64725c; }
#profile-stats dd { margin:0; text-align:right; font-weight:800; overflow-wrap:anywhere; }
#profile-experience { padding:5px; border-radius:5px; background:#e7e6cb; font-size:12px; }
.profile-layout small { font-size:10px; color:#6b715e; }
.profile-layout h3 { font-size:14px; margin:0 0 5px; }
#profile-titles { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px; }
.profile-title { display:flex; flex-direction:column; gap:3px; padding:6px; border:1px solid #ddc9a3; border-radius:7px; background:#fff5dd; min-width:0; }
.profile-title strong { font-size:13px; }
.profile-title small { flex:1; line-height:1.25; }
.profile-title button { min-height:28px; padding:3px; font-size:11px; }
.profile-title.equipped { border-color:#6f9772; background:#e6eed7; }
.profile-title.junior strong { color:#9b701e; text-shadow:0 0 6px #f0ca6b; }
.profile-title.overlord strong { color:#a57817; text-shadow:0 0 9px #ffd156,0 0 4px #ffe69d; }
.profile-title.collector strong { color:#49786b; }
.map-rival-copy { display:grid; gap:1px; text-align:left; line-height:1.1; }
.map-rival-copy small { font-size:10px; color:#ecdbb2; }
.duel-lost .duel-board { filter: grayscale(1) brightness(.55); transition: filter .65s; }
.duel-lost .duel-field { background: #39403a; }
@media (pointer: coarse) {
  .walk-pad {
    position: absolute; left: 12px; bottom: 12px; display: grid; grid-template-columns: repeat(3,42px);
    grid-template-rows: repeat(2,42px); gap: 3px; touch-action: none;
  }
  .walk-pad button,.walk-actions button {
    color: #fff1d1; background: #20382edb; border: 1px solid #b8c9a488; border-radius: 10px;
    min-width: 42px; min-height: 42px; font-size: 22px; font-weight: 800; touch-action: none; user-select: none;
  }
  .walk-pad button[aria-pressed="true"],.walk-actions button[aria-pressed="true"] {
    background: #f5d58a; color: #294634;
  }
  .walk-pad button:first-child { grid-column: 2; }
  .walk-pad button:nth-child(2) { grid-area: 2/1; }
  .walk-pad button:nth-child(3) { grid-area: 2/2; }
  .walk-pad button:nth-child(4) { grid-area: 2/3; }
  .walk-actions { display: grid; position: absolute; right: 12px; bottom: 12px; gap: 5px; }
  .walk-actions button { font-size: 12px; padding: 4px 9px; }
  .world-touch-help {
    position: absolute; left: 50%; bottom: 14px; translate: -50% 0; color: #fff1d1; background: #20382eda;
    padding: 5px 8px; border-radius: 6px; display: block; font-size: 11px;
  }
}
h1,h2,h3,p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid #287357; outline-offset: 4px; }
h1:focus { outline: none; }
button:disabled { opacity: .46; cursor: default; }
.topbar { border-bottom: 1px solid var(--line); background: var(--cream); }
.topbar-inner,.shell { width: min(1110px, calc(100% - 56px)); margin: 0 auto; }
.topbar-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 0; background: none; border: 0; font-size: 17px; font-weight: 900; white-space: nowrap; }
.brand-group { display: flex; align-items: center; gap: 5px; }
.game-back { min-width: 34px; padding: 2px 7px; font: 700 26px/1 system-ui; }
.brand-mark { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 11px; background: var(--ink); color: #ffd79a; font-weight: 1000; }
.utilities,nav,.actions { display: flex; align-items: center; gap: 8px; }
nav button,.quiet,.primary { min-height: 40px; padding: 8px 14px; border-radius: 8px; font-weight: 800; }
nav button { background: transparent; border: 1px solid transparent; }
nav button:hover,nav button[aria-current] { background: #efe7d5; border-color: var(--line); }
#nav-team { margin-left: 5px; color: var(--rust); font: 800 12px system-ui; }
.wallet { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 8px; background: #f8e8ba; color: #644415; white-space: nowrap; }
.wallet span { font: 800 13px system-ui; }
.wallet strong { font: 850 17px system-ui; font-variant-numeric: tabular-nums; }
.quiet { background: var(--cream); border: 1px solid var(--line); font-size: 14px; }
.quiet:hover:not(:disabled) { background: #f0e7d3; }
.primary { background: var(--orange); border: 1px solid var(--rust); box-shadow: 0 3px 0 var(--rust); font-size: 15px; color: #271d17; }
.primary:hover:not(:disabled) { background: #ff9a6f; }
.primary:active:not(:disabled) { translate: 0 2px; box-shadow: 0 1px 0 var(--rust); }
.primary span,.quiet span[aria-hidden] { margin-left: 7px; }
.shell { padding: 28px 0 48px; }
.screen { animation: enter .24s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } }
.hero { position: relative; isolation: isolate; min-height: min(610px,78vh); overflow: hidden; display: grid; grid-template-columns: 45% 55%; background: #223732; border: 1px solid #142825; color: #fff3d7; border-radius: 22px; }
.hero-copy { align-self: center; padding: clamp(26px,6vw,78px); padding-right: 0; z-index: 2; }
.eyebrow { display: inline-block; width: fit-content; padding: 5px 10px; border-radius: 5px; background: #f2d58d; color: #503c1b; font-size: 13px; font-weight: 900; letter-spacing: .12em; }
.hero h1 { margin: 14px 0 17px; font-size: clamp(62px,11vw,138px); font-weight: 1000; line-height: .95; letter-spacing: -.1em; text-shadow: 3px 5px #102621; }
.hero h1 em { color: #ff9f66; font-style: normal; }
.hero p { margin-bottom: 24px; color: #f4e5c3; line-height: 1.7; font-size: clamp(13px,1.6vw,17px); }
.hero .primary { min-height: 49px; padding-inline: 21px; }
.elem-badge{display:inline-flex;align-items:center;gap:1px;padding:1px 6px;border-radius:999px;font-size:10px;font-weight:800;line-height:1.25;vertical-align:middle;margin-left:4px;border:1px solid transparent;white-space:nowrap;}
.elem-fire{background:#ffe4dc;color:#b83520;border-color:#eb9d8c;}
.elem-grass{background:#ddf5e4;color:#236e3e;border-color:#8fd1a6;}
.elem-rock{background:#f4ead4;color:#7a541d;border-color:#d4b885;}
.elem-thunder{background:#ede5fa;color:#5a3799;border-color:#bca3e8;}
.elem-water{background:#dcf0fc;color:#196296;border-color:#8ec5eb;}
.elem-creator{background:linear-gradient(135deg,#fff3be,#ffe080);color:#8a5805;border-color:#d9a226;box-shadow:0 0 6px #ffd45e66;}
.fighter.is-countered,.lan-fighter.is-countered{outline:2px solid #e69d28;box-shadow:0 0 0 2px #ffe48a88 inset;}
.counter-pill{display:inline-block;font-size:9px;font-weight:800;color:#9e4e08;background:#ffe799;border-radius:4px;padding:0 4px;margin-left:3px;}

.title-actions { flex-wrap: wrap; }
.hero .quiet { color: var(--ink); }
.hero .save-summary { margin: 14px 0 0; font-size: 12px; }
#fresh-dialog,#card-stats,#back-dialog { width: min(385px,calc(100% - 32px)); padding: 22px; color: var(--ink); background: var(--cream); border: 1px solid var(--line); border-radius: 16px; }
#fresh-dialog::backdrop,#card-stats::backdrop,#back-dialog::backdrop { background: #2136328a; }
#fresh-dialog p,#back-dialog p { margin: 11px 0 17px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.card-stat-heading { display: flex; gap: 12px; align-items: center; }
.card-stat-heading canvas { display: block; width: 67px; height: auto; }
.card-stat-heading .stars { margin-top: 4px; }
#card-stats-values { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; padding: 11px; border-radius: 8px; background: #f3e9d1; font-size: 13px; }
#card-stats-values dd { margin: 0; font-weight: 800; text-align: right; }
.hero-art { position: relative; min-height: 360px; overflow: hidden; background: radial-gradient(ellipse at 48% 48%,#f3ce88 0%,#d58b57 55%,#8f512d 100%); }
.hero-art::before { content: ""; position: absolute; inset: 0; background: url(arena.jpg) center / cover; opacity: .5; mix-blend-mode: multiply; }
.hero-ring { position: absolute; inset: 10% 8%; border: 3px solid #fff4b69c; border-radius: 50%; transform: rotate(-18deg); }
.hero-ring.second { inset: 14% 12%; border-width: 1px; border-style: dashed; }
.hero-cards,.hero-cards canvas { position: absolute; }
.hero-cards { inset: 0; }
.hero-cards canvas { width: 35%; height: auto; aspect-ratio: 1; border-radius: 50%; box-shadow: 5px 9px 0 #552e26,7px 16px 20px #57372198; }
.hero-cards canvas:nth-child(1) { left: 13%; top: 23%; rotate: -16deg; }
.hero-cards canvas:nth-child(2) { right: 15%; top: 19%; rotate: 14deg; }
.hero-cards canvas:nth-child(3) { width: 40%; left: 33%; top: 43%; rotate: -7deg; }
.spark { position: absolute; color: #fff3c8; font: 800 clamp(25px,5vw,56px)/1 system-ui; }
.spark-top { top: 7%; left: 55%; }
.spark-bottom { bottom: 10%; left: 15%; }
.story { display: grid; grid-template-columns: 38% 1fr; border-radius: 20px; border: 1px solid var(--line); overflow: hidden; background: var(--cream); }
.story-art { display: grid; place-items: center; min-height: 370px; background: url(arena.jpg) center / cover, #e6bc80; }
#story-card { text-align: center; }
.story-copy { align-self: center; padding: clamp(21px,5vw,58px); }
.story h1,.page-heading h1 { font-size: clamp(32px,5vw,54px); font-weight: 1000; letter-spacing: -.065em; line-height: 1.12; }
.story h1 { margin: 9px 0 20px; }
.dialogue { border-left: 4px solid #cf8f51; background: #f3ead4; padding: 11px 13px; border-radius: 0 8px 8px 0; margin-bottom: 10px; }
.dialogue strong { font-size: 13px; color: var(--rust); }
.dialogue p { line-height: 1.6; font-size: 14px; margin-top: 4px; }
.story .actions { margin-top: 19px; flex-wrap: wrap; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 7px 0 21px; }
.page-heading p { margin-top: 8px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.page-heading button { flex: 0 0 auto; }
.map-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 15px; }
.map-card { display: flex; flex-direction: column; padding: 0; text-align: left; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--cream); }
.map-card:hover { translate: 0 -2px; border-color: #b5996a; box-shadow: 0 5px 12px #3a2d2115; }
.map-art { display: grid; place-items: center; min-height: 189px; position: relative; isolation: isolate; overflow: hidden; }
.map-art::before { content: ""; position: absolute; inset: 13% 15%; border: 2px dashed #fff9dbaf; border-radius: 50%; rotate: -8deg; }
.map-art canvas { width: 78px; height: 78px; rotate: -12deg; border-radius: 50%; box-shadow: 3px 6px 0 #1a2a2a80,3px 8px 10px #1a2a2a61; }
.map-info { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; width: 100%; padding: 13px 14px 15px; }
.map-info strong { font-size: 21px; }
.map-info small { align-self: center; color: var(--rust); font-size: 13px; font-weight: 800; }
.map-info p { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.sand { background: url(arena.jpg) center / cover, #e4ba80; }
.grass { background: repeating-linear-gradient(153deg,#213d2420 0 1px,transparent 1px 5px), radial-gradient(at 70% 20%,#a6b76a,#557949 74%,#34533c); }
.desk { background: repeating-linear-gradient(6deg,#40251921 0 1px,transparent 1px 4px, #f7d2a82b 5px 6px,transparent 7px 13px),linear-gradient(140deg,#daaa73,#b17b50 65%,#a67146); }
.playground { background: repeating-linear-gradient(0deg,transparent 0 24px,#ffebc6a8 24px 26px,transparent 26px 42px), #b96150; }
.park { background: repeating-linear-gradient(0deg,transparent 0 22px,#e5ead6be 22px 24px),repeating-linear-gradient(90deg,#acb79b 0 33px,#e5ead6bb 33px 35px); }
.parking { background: linear-gradient(90deg,transparent 49%,#fae9c9 49% 50%,transparent 50%),linear-gradient(0deg,transparent 47%,#fae9c9 47% 50%,transparent 50%),#575c68; }
.surface { background: var(--cream); border: 1px solid var(--line); border-radius: 15px; }
.surface h2,.inventory-head h2 { font-size: 18px; }
.shop-layout { display: grid; grid-template-columns: minmax(230px, .74fr) minmax(0,1.5fr); gap: 15px; }
.pack-panel { min-height: 343px; border-radius: 15px; background: #263e36; padding: 25px 16px 15px; color: var(--cream); text-align: center; }
.pack-wrap { display: grid; place-items: center; min-height: 218px; }
.pack { position: relative; width: 137px; padding: 16px 10px 12px; transform: rotate(-8deg); color: #552b24; background: repeating-linear-gradient(135deg,#f9bb6e 0 11px,#ffce7a 11px 23px); border: 2px solid #874429; border-block-width: 7px; box-shadow: 3px 8px 0 #192b27,4px 13px 16px #152823aa; }
.pack span { font-weight: 1000; font-size: 21px; }
.pack canvas { margin: 7px 0 2px; width: 78px; height: 78px; rotate: 9deg; }
.pack small { font-size: 12px; font-weight: 900; }
.pack.opened { animation: pop .36s ease both; }
@keyframes pop { 48% { transform: rotate(5deg) scale(1.14); } }
.pack-panel .primary { width: min(100%,232px); }
.mini-status { font-size: 13px; line-height: 1.45; margin-top: 8px; }
.pack-panel .mini-status { min-height: 21px; margin-top: 12px; color: #f9ebc6; }
.draws { padding: 17px; display: flex; flex-direction: column; align-items: start; gap: 13px; }
#draw-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 6px; width: 100%; }
#draw-empty { color: var(--muted); font-size: 14px; }
#pack-progress { margin: 0; font-weight: 850; color: var(--rust); }
.pack-odds,#exchange-status { font-size: 12px; color: var(--muted); line-height: 1.55; }
#exchange-status { margin: 0 0 7px; }
.draws > button { margin-top: auto; }
.collectible { display: flex; align-items: center; flex-direction: column; gap: 5px; min-width: 0; border-radius: 10px; background: #f6efdd; border: 1px solid var(--line); padding: 8px 4px; text-align: center; }
.collectible canvas { width: min(100%,65px); height: auto; }
.collectible strong { font-size: 13px; line-height: 1.25; }
.collectible.hidden-star { background: #fff0c3; border-color: #b87c29; }
.stars { display: block; color: #924b16; font: 800 12px/1.2 system-ui; letter-spacing: -.055em; white-space: nowrap; }
.team-panel { padding: 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.team-panel p { color: var(--muted); }
#team-slots { display: grid; grid-template-columns: repeat(3,minmax(0,95px)); gap: 7px; }
#team-slots button,.empty-slot { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 75px; min-width: 0; padding: 6px 4px; border: 1px dashed #c6b78e; background: #f6efdd; border-radius: 9px; font-size: 11px; }
#team-slots button { border-style: solid; }
#team-slots button:not(:disabled):hover { border-color: var(--rust); background: #fbe3cd; }
#team-slots button:disabled { opacity: 1; }
#team-slots canvas { width: 42px; height: 42px; margin-bottom: 3px; }
#team-slots i { position: absolute; top: 2px; right: 4px; font: 800 15px system-ui; }
.inventory-head { margin: 22px 0 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.inventory-head span { color: var(--muted); font-size: 13px; }
.inventory-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(135px,1fr)); gap: 8px; }
.inventory-grid .collectible { background: var(--cream); }
.inventory-grid .collectible.selected { border-color: #6d936d; background: #f3f5e5; }
.inventory-grid .collectible small { font-size: 11px; color: var(--muted); }
.inventory-grid button { margin-top: auto; min-height: 33px; padding: 5px 8px; font-size: 12px; }
.duel-layout { display: grid; grid-template-columns: minmax(0,1fr) 314px; gap: 12px; align-items: stretch; }
.duel-board { position: relative; border: 1px solid #69472985; border-radius: 16px; padding: 15px; }
.lineup { display: flex; justify-content: center; gap: clamp(6px,2.75vw,23px); }
.fighter { display: flex; align-items: center; flex-direction: column; min-width: 0; width: min(30%,137px); padding: 5px 3px; background: #fff7e3; border: 2px solid #6e503ed0; border-radius: 11px; box-shadow: 1px 3px 0 #4b372989; }
.fighter[aria-pressed="true"] { border-color: #fff1b1; outline: 2px dashed #402d20; background: #fff0c8; }
.fighter:disabled { opacity: 1; }
.fighter.defeated { filter: grayscale(.9); opacity: .63; }
.fighter canvas { display: block; width: min(100%,71px); height: auto; margin-bottom: 3px; }
.fighter.hit canvas { animation: strike-hit .42s ease both; }
.fighter.flip canvas { animation: strike-flip .58s ease both; }
@keyframes strike-hit { 30% { transform: translateY(-10px) rotate(-10deg); } 65% { transform: rotate(6deg); } }
@keyframes strike-flip { 50% { transform: translateY(-21px) rotateX(175deg) rotate(-12deg); } to { transform: rotateX(360deg); } }
.fighter strong { font-size: 12px; white-space: nowrap; }
.defense { color: #426047; font-size: 11px; font-weight: 800; margin-top: 3px; }
.defeated .defense { color: #6b5550; }
.duel-panel { padding: 16px; min-height: 305px; }
.duel-meter { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.duel-meter div { border-radius: 8px; border: 1px solid var(--line); background: #f8f0dc; padding: 8px; }
.duel-meter span { display: block; font-size: 12px; color: var(--muted); }
.duel-meter strong { font: 850 20px system-ui; white-space: nowrap; }
.turn-marker { margin: 14px 0 6px; display: inline-block; border-radius: 5px; padding: 4px 8px; font-size: 12px; font-weight: 900; background: #ecd8a3; color: #513d22; }
#duel-status { min-height: 41px; color: var(--muted); line-height: 1.55; font-size: 14px; }
.rps,.duel-actions { margin-top: 12px; }
.rps > p { font-size: 14px; font-weight: 800; margin-bottom: 6px; }
.rps-buttons { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; }
.rps-buttons button { padding: 7px 2px; font-size: 12px; }
.rps-buttons button span { display: block; margin: 0 0 3px; font-size: 20px; }
.duel-actions { flex-wrap: wrap; }
@media (max-width: 760px) {
  .topbar-inner,.shell { width: calc(100% - 24px); }
  .topbar-inner { min-height: 56px; gap: 6px; flex-wrap: wrap; padding: 7px 0; }
  nav { order: 3; flex-basis: 100%; }
  nav button { min-height: 29px; padding: 3px 9px; font-size: 13px; }
  .brand { font-size: 15px; }
  .brand-mark { width: 30px; height: 30px; }
  .sound { min-height: 32px; padding: 4px 7px; font-size: 12px; }
  .shell { padding-top: 15px; }
  .hero { min-height: 0; grid-template-columns: 1fr; }
  .hero-copy { padding: 24px; }
  .hero h1 { margin: 10px 0; font-size: clamp(41px,11vw,72px); }
  .hero h1 br { display: none; }
  .hero p { margin-bottom: 13px; }
  .hero-art { min-height: clamp(215px,52vw,330px); }
  .hero-cards canvas { width: 31%; }
  .hero-cards canvas:nth-child(3) { width: 34%; top: 41%; }
  .story { grid-template-columns: 1fr; }
  .story-art { min-height: 140px; }
  .page-heading { margin: 4px 0 13px; }
  .page-heading p { font-size: 12px; }
  .page-heading button { font-size: 12px; padding-inline: 7px; }
  .map-grid { gap: 7px; }
  .map-art { min-height: clamp(80px,23vw,145px); }
  .map-art canvas { width: clamp(38px,12vw,72px); height: auto; }
  .map-info { display: flex; flex-direction: column; align-items: start; padding: 6px; }
  .map-info strong { font-size: 17px; }
  .map-info small { align-self: start; font-size: 11px; }
  .map-info p { font-size: 10px; }
  .shop-layout,.duel-layout { grid-template-columns: 1fr; gap: 8px; }
  .pack-panel { min-height: 0; padding-top: 9px; }
  .pack-wrap { min-height: 150px; }
  .pack { scale: .78; }
  .draws { padding: 11px; }
  .collectible strong { font-size: 11px; }
  .inventory-grid { grid-template-columns: repeat(auto-fill,minmax(103px,1fr)); }
  .duel-board { padding: 7px; }
  .fighter canvas { width: min(100%,49px); }
  .duel-panel { padding: 9px; min-height: 0; }
  #duel-status { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation-duration: .01ms !important; }
}

.day-clock { font-size: 12px; color: #654f31; font-weight: 900; white-space: nowrap; }
.story-cast,.arena-cast,.home-cast { display: flex; align-items: center; justify-content: center; gap: 12px; }
.portrait { position: relative; margin: 0; width: 74px; text-align: center; color: var(--ink); }
.portrait canvas { display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: 13px; border: 2px solid #fff2d1; box-shadow: 2px 3px #634b3966; }
.portrait figcaption { position: relative; width: fit-content; margin: -7px auto 0; padding: 3px 8px; border-radius: 6px; background: #263c36; color: #fff5dd; font-size: 11px; font-weight: 900; white-space: nowrap; }
.story-cast .portrait,.home-cast .portrait { width: clamp(58px,10vw,116px); }
.story-cast .portrait:first-child { rotate: -7deg; }
.story-cast .portrait:last-child { rotate: 6deg; translate: 0 12px; }
.map-art .portrait { position: absolute; top: 12px; left: 12px; width: 48px; }
.map-art .portrait canvas { width: 100%; height: auto; rotate: 0deg; border-radius: 9px; box-shadow: 2px 3px #3a2d2150; }
.map-art .portrait figcaption { display: none; }
.home-layout { display: grid; grid-template-columns: minmax(175px,32%) minmax(0,1fr); gap: 12px; }
.home-cast { padding: 26px 12px; border-radius: 16px; min-height: 220px; background: repeating-linear-gradient(145deg,#ffe9c638 0 10px,transparent 10px 18px), radial-gradient(at 64% 28%,#f6d295,#dba56e); }
.home-work { padding: 18px; }
.home-work .actions { flex-wrap: wrap; }
#home-notice { min-height: 23px; margin-top: 8px; color: var(--rust); font-size: 14px; line-height: 1.55; }
#home-tasks { display: grid; gap: 6px; padding: 0; list-style: none; }
#home-tasks li { padding: 7px 10px; background: #f4ecda; border-radius: 7px; font-size: 13px; }
#home-tasks li.done { color: #325746; background: #e6edda; }
#home-tasks li::before { content: "□"; margin-right: 6px; }
#home-tasks li.done::before { content: "✓"; }
#bag-empty,#borrow { margin-top: 10px; }
.hand-hud { position: fixed; z-index: 5; left: max(12px,env(safe-area-inset-left)); bottom: max(12px,env(safe-area-inset-bottom)); display: grid; grid-template-columns: auto auto; gap: 4px 8px; align-items: center; min-width: 112px; padding: 8px 10px; border: 1px solid #e1cba0; border-radius: 10px; box-shadow: 0 3px 10px #2d241522; background: #fff3d9; color: #534321; pointer-events: none; }
.hand-hud span { font-size: 11px; font-weight: 800; }
.hand-hud strong { justify-self: end; font: 900 18px/1 system-ui; }
.hand-hud i { grid-column: 1 / -1; height: 4px; border-radius: 8px; overflow: hidden; background: #e5d3ad; }
.hand-hud b { display: block; height: 100%; border-radius: inherit; background: #4f7852; transition: width .22s ease; }
.duel-board { position: relative; overflow: hidden; min-height: clamp(340px,44vw,530px); padding: 0; background: #e1bd8d; }
#arena-canvas { width: 100%; height: 100%; position: absolute; inset: 0; display: block; outline-offset: -4px; touch-action: none; -webkit-touch-callout: none; user-select: none; cursor: crosshair; }
#arena-canvas.orbiting { cursor: grabbing; }
.scene-controls { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 14px); padding: 5px 9px; border-radius: 6px; color: #fff5d4; background: #263a34e9; font-size: 11px; line-height: 1.4; pointer-events: none; }
.touch-tools,.touch-instructions { display: none; }
.arena-cast { position: absolute; top: 10px; left: 10px; right: 10px; justify-content: space-between; pointer-events: none; }
.arena-cast .portrait { width: 47px; }
.arena-cast .portrait canvas { border-radius: 9px; }
.edge-hint { position: absolute; top: 13px; left: 50%; translate: -50% 0; max-width: calc(100% - 130px); padding: 5px 7px; color: #e6ffca; background: #2a4a3f; border-radius: 6px; font-weight: 850; font-size: 11px; text-align: center; pointer-events: none; }
.edge-tip { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.rosters { display: grid; gap: 8px; margin-top: 9px; }
.rosters h3 { font-size: 11px; margin-bottom: 4px; color: var(--muted); }
.rosters .lineup { justify-content: flex-start; gap: 5px; }
.rosters .fighter { width: min(33.3%,83px); background: #f9efdb; border: 1px solid #d9cbaa; box-shadow: none; padding: 4px 2px; }
.rosters .fighter[aria-pressed="true"] { outline: 2px solid #648565; outline-offset: 0; background: #e8edda; }
#player-cards .fighter[aria-pressed="true"] { outline-color: #42749d; background: #e0ebf5; }
.rosters .fighter canvas { width: 33px; }
.rosters .fighter strong { font-size: 11px; }
.rosters .fighter .defense { font-size: 10px; }
#cancel-charge { margin-top: 6px; min-height: 29px; padding: 4px 8px; font-size: 12px; }
.stock-section { margin-top: 16px; }
.outfit-strip { padding: 9px 12px; border-left: 3px solid #5f805c; border-radius: 4px; background: #e8ecdc; font-size: 13px; font-weight: 850; }
#outfit-status { margin: 7px 0 12px; color: var(--muted); }
#outfit-loadout { color: var(--ink); font-weight: 750; }
.outfit-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.outfit-card { min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.outfit-card.worn { border-color: #79966f; }
.outfit-swatch { display: grid; min-height: 151px; place-items: center; background: repeating-linear-gradient(143deg,#fff2d82c 0 9px,transparent 9px 18px),var(--swatch); }
.outfit-swatch .portrait { width: 97px; }
.outfit-swatch figcaption { display: none; }
.outfit-copy { display: flex; flex-direction: column; gap: 6px; padding: 12px; flex: 1; }
.outfit-copy h2 { font-size: 17px; }
.outfit-copy strong { font-size: 12px; color: var(--rust); }
.outfit-copy p { font-size: 12px; color: var(--muted); line-height: 1.5; flex: 1; }
.outfit-copy button { min-height: 33px; padding: 4px 7px; font-size: 12px; }
.outfit-copy .quiet[aria-pressed="true"] { background: #edf1df; border-color: #8ca27c; }
.stock-section .inventory-head { margin-bottom: 4px; align-items: center; }
.stock-section .mini-status { color: var(--muted); margin: 4px 0 9px; }
.stock-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(168px,1fr)); gap: 8px; }
.stock-item { display: flex; flex-direction: column; gap: 5px; padding: 9px; min-width: 0; }
.stock-item.carried { border-color: #7d9d7b; background: #eef0df; }
.stock-item h3 { font-size: 14px; }
.stock-kind { color: var(--rust); font-size: 11px; font-weight: 800; }
.stock-item .stock-effect { font-size: 12px; line-height: 1.45; color: var(--muted); flex: 1; }
.stock-item button,.duel-gear button { font-size: 11px; min-height: 30px; padding: 4px 7px; text-align: left; }
.duel-gear { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.duel-gear h3 { font-size: 12px; }
#duel-gear-status { color: var(--muted); font-size: 11px; margin: 4px 0; }
#duel-gear-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.duel-gear .skin-skill { border-color: #b58e54; background: #f6e5bc; }
#victory-confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 20; pointer-events: none; }

@media (pointer: coarse) {
  .primary,.quiet,dialog button { min-height: 44px; }
  .map-card { touch-action: manipulation; }
  .topbar { position: sticky; top: 0; z-index: 7; }
  .touch-tools { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 4px; }
  .touch-tools button { min-width: 44px; min-height: 44px; padding: 3px 7px; border: 1px solid #f8e0b0b0; border-radius: 8px; color: #fff4d5; background: #263c36e8; font-weight: 850; touch-action: manipulation; }
  .touch-tools button[aria-pressed="true"] { background: #f7dd9a; color: #2c3d2c; }
  .touch-instructions { display: block; color: var(--muted); font-size: 11px; line-height: 1.5; margin: 5px 0 0; }
  .desktop-controls { display: none; }
  #cancel-charge { min-height: 44px; }
  .rosters .fighter,.duel-gear button,.stock-item button,.outfit-copy button { min-height: 44px; }
  .arena-cast .portrait { width: 40px; }
}
@media (pointer: coarse) and (max-width: 760px) {
  .topbar-inner { width: calc(100% - 16px); min-height: 50px; display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; gap: 3px 5px; }
  .brand { font-size: 13px; gap: 4px; }
  .brand-mark { width: 25px; height: 25px; border-radius: 8px; }
  .game-back { min-height: 40px; }
  .utilities { display: contents; }
  .day-clock { white-space: normal; text-align: center; line-height: 1.35; font-size: 10px; }
  .wallet { padding: 5px; gap: 2px; }
  .wallet strong { font-size: 14px; }
  .sound { min-height: 40px; }
  .topbar nav { grid-row: 2; grid-column: 1/-1; justify-content: space-between; gap: 3px; }
  .topbar nav button { min-height: 42px; padding-inline: 5px; font-size: 12px; white-space: nowrap; flex: 1; }
  #nav-team { margin-left: 3px; font-size: 10px; }
  .shell { padding-bottom: max(72px,env(safe-area-inset-bottom)); }
  .duel .duel-board { min-height: clamp(228px,62vw,400px); }
  .duel .page-heading { align-items: center; }
  .duel-panel { padding: 9px; }
  .rps-buttons button { min-height: 49px; }
  .rps-buttons button span { display: inline; margin-right: 3px; font-size: 15px; }
  .scene-controls { bottom: 6px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 540px) and (min-width: 620px) {
  .duel .duel-layout { grid-template-columns: minmax(0,1.5fr) minmax(245px,1fr); }
  .duel .duel-board { min-height: min(340px,65vh); }
}
@media (max-width: 760px) {
  .day-clock { font-size: 10px; }
  .home-layout { grid-template-columns: 1fr; }
  .home-cast { min-height: 102px; padding: 9px; }
  .map-art .portrait { top: 5px; left: 5px; width: 29px; }
  .duel-board { min-height: clamp(275px,72vw,435px); }
  .rosters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .rosters .fighter canvas { width: 22px; }
  .rosters .fighter .stars { font-size: 9px; }
  .stock-grid { grid-template-columns: repeat(auto-fit,minmax(132px,1fr)); }
  .outfit-grid { gap: 7px; grid-template-columns: repeat(auto-fit,minmax(143px,1fr)); }
  .outfit-swatch { min-height: 96px; }
  .outfit-swatch .portrait { width: 65px; }
  .outfit-copy { padding: 8px; }
  .shell { padding-bottom: 75px; }
}
.duel-field { display: contents; }
.legend-skill { border-color:#d9ad64; }
.spirit-flash .duel-board { animation:spirit-glow .8s ease-out; }
.doom-flash .duel-board { animation:doom-glow .9s ease-in-out; }
@keyframes spirit-glow { 40% { box-shadow:inset 0 0 90px #bfffa9; } }
@keyframes doom-glow { 50% { box-shadow:inset 0 0 120px #993fd7; filter:hue-rotate(35deg); } }
#profile-legend-skills { font-size:12px; color:#78643f; }
#tattletale-dialog {
  box-sizing:border-box; width:min(860px,95vw); max-width:95vw; max-height:94dvh;
  padding:14px 18px; overflow:hidden; border:2px solid #b28b55; border-radius:22px;
  background:radial-gradient(ellipse at top,#47624d,#253d31 75%); color:#fff0ce;
  box-shadow:0 18px 80px #0008,inset 0 0 0 4px #fff1be0b; transform:translateZ(0);
  font-family:inherit; touch-action:none; user-select:none;
}
#tattletale-dialog::backdrop { background:#10261bc9; backdrop-filter:blur(5px); }
#tattletale-dialog header { display:flex; align-items:center; justify-content:space-between; gap:10px; }
#tattletale-heading { font-size:21px; color:#ffdc8b; }
#tattletale-dialog .quiet { color:#ffe2b1; background:#304d3e; border-color:#7b9476; min-height:36px; padding:5px 12px; font-size:13px; }
.tattletale-story { display:flex; align-items:center; justify-content:center; gap:18px; min-height:88px; padding:5px 0; }
#tattletale-actor { flex-shrink:0; }
#tattletale-actor .portrait { width:68px; margin:0; border:0; background:transparent; box-shadow:none; }
#tattletale-actor canvas { width:68px; height:68px; border-radius:18px; border:2px solid #e6ca89; }
#tattletale-actor figcaption { display:none; }
#tattletale-speech { margin:0; max-width:540px; padding:10px 16px; border-radius:16px 16px 16px 3px; background:#fff0cf; color:#663b2b; font-size:clamp(17px,2.8vw,25px); font-weight:900; line-height:1.4; }
.intro #tattletale-actor { animation:tattletale-jump .65s cubic-bezier(.2,.7,.3,1.3); }
@keyframes tattletale-jump { from { transform:translateY(150px) scale(.2) rotate(-15deg); } 70% { transform:translateY(-12px) scale(1.15) rotate(8deg); } to { transform:translateY(0) scale(1); } }
.tattletale-field { display:grid; grid-template-columns:minmax(0,1fr) 170px; gap:16px; }
.tattletale-table { min-width:0; border:1px solid #b3a77b57; border-radius:14px; padding:10px; background:#182d25aa; }
.tattletale-table>span { display:block; text-align:center; font-size:12px; color:#c6d2b3; }
#tattletale-cards { display:flex; justify-content:center; align-items:center; gap:clamp(6px,2vw,22px); min-height:105px; }
#tattletale-dialog .tattletale-card { display:grid; justify-items:center; gap:3px; border:0; padding:4px; min-width:0; background:transparent; color:#ffedc3; box-shadow:none; cursor:grab; touch-action:none; }
.tattletale-card canvas { width:clamp(56px,11vw,82px); height:auto; border-radius:50%; filter:drop-shadow(0 4px 3px #0008); pointer-events:none; }
.tattletale-card small { font-size:12px; white-space:nowrap; pointer-events:none; }
#tattletale-dialog .tattletale-card.dragging { position:fixed; left:0; top:0; transform:translate(-50%,-50%) scale(1.08); z-index:5; width:var(--drag-width); cursor:grabbing; opacity:1; }
#tattletale-bag { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:5px; border:2px dashed #d7bc7b; border-radius:18px; background:#b7a06716; transition:background .12s; }
#tattletale-bag.drop-ready { background:#c4ed7766; border-color:#f1ffa6; box-shadow:0 0 20px #bcf57a55; }
#tattletale-bag strong { font-size:15px; }
#tattletale-bag small { font-size:12px; color:#c7d3b2; }
.schoolbag-art { display:block; position:relative; width:66px; height:68px; border:3px solid #142b28; border-radius:15px 15px 11px 11px; background:linear-gradient(#5aa995 38%,#35776a 38%); box-shadow:inset 0 3px 0 #c8dfb6; }
.schoolbag-art::before { content:""; position:absolute; top:-12px; left:20px; width:20px; height:11px; border:4px solid #dac690; border-bottom:0; border-radius:8px 8px 0 0; }
.schoolbag-art::after { content:"★"; position:absolute; left:12px; right:12px; bottom:7px; border:2px solid #cfc08b; border-radius:6px; color:#f6db8b; text-align:center; font-size:24px; line-height:28px; background:#234e49; }
.schoolbag-art i { position:absolute; left:29px; top:14px; height:16px; width:6px; border-radius:3px; background:#f6d17b; }
#tattletale-dialog footer { display:flex; gap:12px; align-items:center; justify-content:space-between; margin-top:10px; }
#tattletale-dialog footer>div { display:flex; flex-wrap:wrap; align-items:center; gap:6px 14px; }
#tattletale-timer { color:#fadd82; font-size:24px; font-variant-numeric:tabular-nums; min-width:95px; }
#tattletale-timer.urgent { color:#ff9c80; }
#tattletale-help { color:#d5dec1; font-size:12px; }
#tattletale-continue { min-height:40px; padding:6px 15px; white-space:nowrap; flex-shrink:0; }
#tattletale-dialog.caught { border-color:#d18b75; }
.caught #tattletale-actor { animation:tattletale-jump .5s ease-out; }
.safe #tattletale-speech { background:#e3f2ba; color:#33523b; font-size:19px; }
@media (max-height:410px) and (min-width:521px) {
  #tattletale-dialog { padding:9px 14px; }
  .tattletale-story { min-height:67px; gap:12px; }
  #tattletale-actor .portrait,#tattletale-actor canvas { width:56px; height:56px; }
  #tattletale-speech { font-size:19px; padding:7px 12px; }
  #tattletale-cards { min-height:82px; }
  .tattletale-card canvas { width:63px; }
  .tattletale-table { padding:6px; }
  .tattletale-field { grid-template-columns:minmax(0,1fr) 145px; gap:12px; }
  .schoolbag-art { width:52px; height:51px; }
  .schoolbag-art::before { left:13px; }
  .schoolbag-art::after { left:8px; right:8px; font-size:18px; line-height:19px; bottom:4px; }
  .schoolbag-art i { left:22px; top:8px; }
  #tattletale-dialog footer { margin-top:6px; }
}
@media (max-width:520px) {
  #tattletale-dialog { padding:12px; }
  #tattletale-heading { font-size:18px; }
  .tattletale-story { gap:8px; }
  .tattletale-field { grid-template-columns:1fr; }
  #tattletale-bag { min-height:130px; }
}
@media (prefers-reduced-motion:reduce) { #tattletale-actor,.duel-board { animation:none !important; } }
