.sd-page.in-port { background: #071f2b; }
.sd-page.in-port :is(.site-masthead,.sd-heading,.sd-manual,.site-footer) { display: none; }
.sd-page.in-port .sd-layout { padding: 12px; max-width: 520px; }
.sd-page.in-port .sd-game { max-width: 480px; }
.sd-port {
  --gold: #f5c75d; --paper: #fff1c8; --panel: #103c43;
  color: var(--paper); position: relative; isolation: isolate;
  width: 100%; height: min(900px, calc(100svh - 24px)); min-height: 680px;
  overflow: hidden; border: 2px solid #b68842; border-radius: 12px;
  background: var(--home-art) center / cover no-repeat, #62412b;
  box-shadow: 0 18px 70px #0008, inset 0 0 0 2px #ffd97c;
  font: 14px/1.5 system-ui, 'Microsoft YaHei', sans-serif;
}
.sd-port button, .sd-gear-dialog button {
  color: var(--paper); font: inherit; min-height: 44px; cursor: pointer; touch-action: manipulation;
}
.sd-port :is(button,a):focus-visible, .sd-gear-dialog button:focus-visible { outline: 3px solid #fff1ac; outline-offset: 2px; }
.sd-port button:disabled, .sd-gear-dialog button:disabled { opacity: .5; cursor: default; }
.sd-port-header {
  height: 64px; display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; gap: 5px;
  padding: 9px 12px; color: #ffe199; background: linear-gradient(#102d29e0,#102d2910);
}
.sd-port-header h1 { margin: 0; text-align: center; font: 800 clamp(23px,6vw,32px)/1.2 var(--serif); text-shadow: 2px 3px #37200f; }
.sd-port-header .sd-port-art { width: 28px; }
.sd-port-header :is(button,a) { display: grid; place-items: center; border: 2px solid #edbd58; border-radius: 7px; background: #0b434a; min-height: 38px; color: #ffe299; }
.sd-port-exit { font-size: 32px; line-height: 1; }
.sd-port-wallet { display: grid; grid-template-columns: 1fr 1fr; margin: 0 12px; padding: 5px 7px; gap: 3px 8px; background: #092c36ef; border: 2px solid #dfb667; box-shadow: 0 2px 0 #3b2416; border-radius: 5px; font-size: 11px; }
.sd-port-wallet > span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.sd-port-wallet .sd-port-art { width: 22px; }
.sd-port-wallet b { margin-left: auto; color: #fff1ce; font-variant-numeric: tabular-nums; }
.sd-port-account { display: flex; gap: 10px; justify-content: center; margin: 5px 12px 0; font-size: 10px; color: #fff2c2; text-shadow: 0 1px 2px #00131e; }
.sd-port-account a { color: #fff2c2; text-decoration: underline; }
.sd-port-body { position: absolute; inset: 153px 0 74px; overflow: auto; scrollbar-width: thin; scrollbar-color: #977346 #123c40; overscroll-behavior: contain; }
.sd-port[data-view='home'] .sd-port-body { overflow: hidden; inset: 153px 0 74px; }
.sd-home-actions { position: absolute; bottom: 18px; left: 20px; right: 20px; display: grid; gap: 10px; }
.sd-port .sd-home-chapter { display: grid; justify-items: center; gap: 2px; min-height: 66px; background: #3e2519ed; border: 3px double #f4ce7a; border-radius: 10px; box-shadow: inset 0 0 0 2px #5e371d,0 3px #281c12; color: #ffe9b2; }
.sd-home-chapter b { font: 700 22px/1.4 var(--serif); }
.sd-home-chapter span { font-size: 12px; }
.sd-port :is(.sd-port-gold,.sd-port-teal), .sd-gear-dialog :is(.sd-port-gold,.sd-port-teal) {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  border: 3px double #ffe394; border-radius: 8px; padding: 8px 12px;
  box-shadow: inset 0 0 0 1px #935f1b,0 3px 0 #281c12;
}
.sd-port .sd-port-gold, .sd-gear-dialog .sd-port-gold { background: linear-gradient(#ffe28a,#efae37); color: #3d2714; font-weight: 800; }
.sd-port .sd-port-teal, .sd-gear-dialog .sd-port-teal { background: linear-gradient(#12616b,#093c47); color: #ffecb3; }
.sd-port .sd-port-play { min-height: 67px; font: 900 30px/1.2 var(--serif); letter-spacing: 3px; }
.sd-port-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.sd-port-quick > button { min-height: 48px; }
.sd-port-quick .sd-port-art { width: 29px; }
.sd-port-art { display: inline-block; flex: none; width: 52px; aspect-ratio: 1; background-size: 500% 600%; background-repeat: no-repeat; image-rendering: pixelated; }
.sd-weapon-art { background-size: 500% 200%; }
.sd-port-nav { position: absolute; inset: auto 0 0; height: 74px; display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); border-top: 3px double #efcb79; background: linear-gradient(#173d49,#0c1e30); z-index: 2; }
.sd-port-nav button { display: grid; justify-items: center; align-content: center; gap: 0; border: 0; border-right: 1px solid #937445; border-radius: 0; background: transparent; color: #ffe9ae; font-size: 12px; }
.sd-port-nav .sd-port-art { width: 43px; }
.sd-port-nav button[aria-pressed='true'] { background: linear-gradient(#236b6b,#134747); box-shadow: inset 0 0 0 2px #eebd5b; color: #fff5cd; }
.sd-port-toast { position: absolute; bottom: 80px; left: 12px; right: 12px; z-index: 5; margin: 0; text-align: center; color: #ffe6b1; font-size: 12px; pointer-events: none; }
.sd-port-toast:not(:empty) { padding: 10px; background: #082b36f5; border: 1px solid #e6b664; border-radius: 6px; box-shadow: 0 5px 20px #0007; }
.sd-port[data-view]:not([data-view='home']) { background-image: var(--armory-art); }
.sd-port-panel { min-height: 100%; padding: 0 12px 20px; background: linear-gradient(#0c2c36dd,#102a31e8); }
.sd-port-panel-title { display: flex; align-items: center; gap: 12px; margin: 0 -12px 12px; padding: 8px 12px; background: #39271ee8; border-bottom: 2px solid #d4a958; }
.sd-port-panel-title h2 { flex: 1; margin: 0; font: 800 23px/1.4 var(--serif); color: #ffe3a1; }
.sd-port .sd-port-back { width: 38px; min-height: 38px; border: 2px solid #deb767; border-radius: 6px; background: #0d4a53; color: #ffe0a1; font-size: 30px; line-height: 1; }
.sd-port-note { display: block; color: #c4d3cc; line-height: 1.6; font-size: 11px; margin: 10px 0; }
.sd-bag-filter { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 12px; }
.sd-bag-filter select { width: 145px; padding: 5px 9px; }
.sd-bag-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; }
.sd-port .sd-item-card, .sd-empty-slot {
  --rarity: #8baca8; display: grid; justify-items: center; align-content: center; position: relative; gap: 2px;
  width: 100%; min-width: 0; min-height: 118px; padding: 5px 3px;
  background: linear-gradient(#182f42,#0c2532); border: 2px solid var(--rarity); border-radius: 7px;
  box-shadow: inset 0 0 0 2px #30464d,0 2px 5px #0006; color: #ffeac2;
}
.sd-item-card b { font-size: 11px; font-weight: 600; }
.sd-item-card small { color: var(--rarity); font-size: 10px; }
.sd-item-card em { font-size: 9px; font-style: normal; color: #9ef0d0; }
.sd-item-card :is(.sd-port-art,.sd-icon) { width: 64px; }
.sd-empty-slot { min-height: 76px; }
.sd-empty-slot .sd-port-art { opacity: .4; }
.sd-empty-slot small { font-size: 10px; }
.sd-paperdoll { display: grid; position: relative; grid-template-columns: 82px 1fr 82px; grid-template-rows: repeat(3,84px); gap: 10px; padding: 15px 8px 24px; background: var(--armory-art) center 67% / cover; border: 2px solid #ac8144; border-radius: 9px; }
.sd-paperdoll .sd-item-card { min-height: 0; padding: 2px; gap: 0; }
.sd-paperdoll .sd-item-card b, .sd-paperdoll .sd-item-card em { display: none; }
.sd-paperdoll .sd-item-card :is(.sd-port-art,.sd-icon) { width: 58px; }
.sd-paperdoll-hero { grid-column: 2; grid-row: 1 / 4; align-self: center; justify-self: center; width: 100%; height: 250px; object-fit: contain; image-rendering: auto; filter: drop-shadow(0 7px 3px #21160f8c); }
.sd-port-stats { display: flex; justify-content: space-around; gap: 5px; padding: 12px 6px; margin: 12px 0; background: #073a43; border: 2px double #c8a864; border-radius: 5px; font-size: 11px; }
.sd-featured-item { display: grid; grid-template-columns: 85px 1fr; align-items: center; column-gap: 12px; padding: 12px; margin: 14px 0; background: #113b43; border: 2px solid var(--rarity); border-radius: 8px; }
.sd-featured-item > :is(.sd-port-art,.sd-icon) { width: 85px; grid-row: 1 / 4; }
.sd-featured-item h3 { font-size: 18px; margin: 0; }
.sd-featured-item p { margin: 3px 0; font-size: 11px; }
.sd-device-card { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 14px 10px; margin-bottom: 12px; background: #123e45; border: 2px solid #9f864e; border-radius: 8px; }
.sd-device-card > .sd-port-art { width: 70px; }
.sd-device-card h3 { font-size: 15px; margin: 0; }
.sd-device-card p, .sd-device-card small { font-size: 11px; margin: 4px 0; }
.sd-device-card > button { grid-column: 1 / 3; }
.sd-draw-stage { height: 220px; position: relative; border: 2px solid #a68043; border-radius: 8px; background-size: cover; background-position: center 47%; overflow: hidden; }
.sd-draw-featured { position: absolute; top: -20px; left: 30%; width: 40%; height: 130px; filter: drop-shadow(0 0 12px #c369ff); }
.sd-draw-featured .sd-port-art { width: 100%; }
.sd-draw-chest { position: absolute; width: 145px; left: calc(50% - 72px); bottom: 0; }
.sd-draw-chest.is-opening { filter: drop-shadow(0 0 13px #e8b6ff); }
.sd-port-quick > [data-draw] { display: grid; gap: 0; }
[data-draw] b { font-size: 20px; }
[data-draw] small { font-size: 10px; }
.sd-port[data-view='draw'] .sd-port-quick { margin-top: 14px; }
.sd-back-port { margin-bottom: 12px; width: 100%; }
.sd-gear-dialog { width: min(calc(100vw - 24px),520px); color: #fff0cc; }
.sd-gear-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.sd-gear-heading h2 { margin: 0; flex: 1; font-size: 23px; }
.sd-gear-heading button { background: transparent; border: 1px solid #aa955f; border-radius: 4px; width: 38px; font-size: 26px; }
#gearContent > .sd-port-gold { width: 100%; margin-top: 14px; }
.sd-gear-detail { display: grid; justify-items: center; border: 2px solid var(--rarity); border-radius: 8px; padding: 8px; background: #102f3c; }
.sd-gear-detail :is(.sd-port-art,.sd-icon) { width: 135px; }
.sd-gear-detail b { color: var(--rarity); }
.sd-gear-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sd-reward-grid, .sd-gallery-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.sd-reward-card, .sd-gallery-card { --rarity: #dfc378; display: grid; justify-items: center; align-content: start; border: 2px solid var(--rarity); background: #113c43; border-radius: 7px; padding: 9px; text-align: center; }
.sd-reward-card .sd-port-art { width: 90px; }
.sd-reward-card b { font-size: 12px; }
.sd-reward-card small { font-size: 11px; color: var(--rarity); }
.sd-gallery-card .sd-port-art { width: 115px; }
.sd-gallery-card h3 { font-size: 14px; margin: 0; }
.sd-gallery-card p { font-size: 10px; margin: 4px 0 0; color: #d4ded0; }
.sd-gallery-card small { color: var(--rarity); font-size: 10px; }
.sd-loot-strip { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
.sd-loot-strip .sd-port-art { width: 55px; }
.sd-loot-strip .sd-reward-card b { font-size: 10px; }
@media (max-width:670px) {
  .sd-page.in-port .sd-layout { padding: 0; max-width: 480px; }
  .sd-port { height: 100svh; min-height: 650px; border-radius: 0; border-width: 0; }
  .sd-port-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(74px + env(safe-area-inset-bottom)); }
  .sd-port-body { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .sd-home-actions { left: 18px; right: 18px; }
}
@media (max-width:350px) {
  .sd-port-header h1 { font-size: 23px; }
  .sd-paperdoll { grid-template-columns: 70px 1fr 70px; gap: 7px; }
  .sd-port-panel { padding-left: 9px; padding-right: 9px; }
  .sd-port .sd-port-play { font-size: 27px; }
  .sd-home-chapter b { font-size: 20px; }
  .sd-home-actions { left: 12px; right: 12px; }
}
@media (prefers-reduced-motion:reduce) { .sd-port * { scroll-behavior: auto; } }

.sd-port-header h1, .sd-port .sd-home-chapter {
  background: var(--frame-wood) center / 100% 100% no-repeat;
  border: 0; border-radius: 0; box-shadow: none;
}
.sd-port-header h1 { display: grid; place-items: center; height: 50px; padding: 4px 16%; font-size: clamp(20px,5vw,28px); white-space: nowrap; }
.sd-port .sd-home-chapter { min-height: 70px; padding: 8px 15%; }
.sd-port :is(.sd-port-gold,.sd-port-teal) {
  border: 0; border-radius: 0; box-shadow: none;
  background-image: var(--frame-teal); background-size: 100% 100%; background-repeat: no-repeat;
  clip-path: polygon(3% 0,97% 0,100% 13%,100% 87%,97% 100%,3% 100%,0 87%,0 13%);
}
.sd-port .sd-port-gold { background-image: var(--frame-gold); }

.sd-prizes-title {margin: 18px 0 9px; font-size: 16px;}
.sd-prize-preview {grid-template-columns: repeat(2, minmax(0, 1fr));}
.sd-prize-preview .sd-gallery-card {min-width: 0; padding: 8px 5px;}
.sd-prize-preview .sd-port-art {width: 80px; max-width: 100%; filter: drop-shadow(0 0 6px var(--rarity));}
.sd-prize-preview h3 {font-size: 12px; overflow-wrap: anywhere;}
.sd-prize-preview small {font-size: 10px;}
