/* Arcalink play.html - Bottom sheet (tower / core panel) and the gem bag / slots / shop inside it. Owner: B6.
   Art plan 3-3: page fill, 1.5 px brass ring, big bevel on the two top corners (a sheet shown at the top has four), a brass rule with a diamond under the title. */
#sheet { --fr: var(--ar-fr-l); --bw: var(--ar-border); --fill: var(--ar-page); --ring: linear-gradient(180deg, var(--ar-brass-hi), var(--ar-brass) 30%, var(--ar-brass-lo)); position: absolute; isolation: isolate; background: var(--ring);
  bottom: 0; max-height: 58%; display: none; flex-direction: column; padding: 10px 12px calc(env(safe-area-inset-bottom) + 12px); overflow: hidden; pointer-events: auto; touch-action: pan-y;
  clip-path: polygon(var(--fr) 0, calc(100% - var(--fr)) 0, 100% var(--fr), 100% 100%, 0 100%, 0 var(--fr)); }
#sheet::before { content: ""; position: absolute; inset: var(--bw) var(--bw) 0; z-index: -1; background: var(--fill); --f2: calc(var(--fr) - var(--bw) * .586);
  clip-path: polygon(var(--f2) 0, calc(100% - var(--f2)) 0, 100% var(--f2), 100% 100%, 0 100%, 0 var(--f2)); }
#sheet.on { display: flex; animation: arRise .24s ease-out; }
#sheet.top { bottom: auto; top: calc(env(safe-area-inset-top) + 82px); margin: 0 8px; left: 0; right: 0; padding: 10px 12px; max-height: 46%; --fr: var(--ar-fr-m);   /* (round 7) 46 %: the big title of a tower upgrade sits at 82 px + 46 % + 14 px (play-fx.js) and touched the foot of a 50 % panel */
  clip-path: polygon(var(--fr) 0, calc(100% - var(--fr)) 0, 100% var(--fr), 100% calc(100% - var(--fr)), calc(100% - var(--fr)) 100%, var(--fr) 100%, 0 calc(100% - var(--fr)), 0 var(--fr)); }
#sheet.top::before { inset: var(--bw); clip-path: polygon(var(--f2) 0, calc(100% - var(--f2)) 0, 100% var(--f2), 100% calc(100% - var(--f2)), calc(100% - var(--f2)) 100%, var(--f2) 100%, 0 calc(100% - var(--f2)), 0 var(--f2)); }
#sheet .body { padding: 2px 2px 14px; touch-action: pan-y; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0; }
.sh-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 2px; }
.sh-h h2 { margin: 0; font-size: 18px; font-weight: 800; line-height: 1.25; } .sh-h .sub { font-size: 11px; font-weight: 600; color: var(--ar-text-sub); line-height: 1.35; }
.sh-h .ti { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wic { width: 44px; height: 44px; flex: none; --fr: 8px; position: relative; isolation: isolate; padding: 5px; background: linear-gradient(180deg, var(--ar-brass), var(--ar-brass-lo));
  clip-path: polygon(var(--fr) 0, calc(100% - var(--fr)) 0, 100% var(--fr), 100% calc(100% - var(--fr)), calc(100% - var(--fr)) 100%, var(--fr) 100%, 0 calc(100% - var(--fr)), 0 var(--fr)); }
.wic::before { content: ""; position: absolute; inset: 1.5px; z-index: -1; background: var(--ar-pit); clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 7px, 100% calc(100% - 7px), calc(100% - 7px) 100%, 7px 100%, 0 calc(100% - 7px), 0 7px); }
.sh-h .btn { flex: none; white-space: nowrap; min-width: 44px; padding: 0; } .sh-h > div { min-width: 0; }
.rule { height: 9px; margin: 2px 0 6px; position: relative; display: flex; align-items: center; justify-content: center; }
.rule::before { content: ""; position: absolute; left: 0; right: 0; top: 4px; height: 1px; background: color-mix(in srgb, var(--ar-brass) 30%, transparent); }
.rule i { width: 7px; height: 7px; background: var(--ar-brass); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); position: relative; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 13px; margin: 4px 0 8px; }
.kv span:nth-child(odd) { color: var(--ar-text-sub); } .kv span:nth-child(even) { text-align: right; font-weight: 700; }
.kv .num { min-width: 2.6em; font-size: 14px; } .kv span:nth-child(odd) .num { min-width: 0; font-size: inherit; }   /* numbers inside a caption are not padded (no gaps in "魔力 10 の 84%") */
.delta { color: var(--ar-up); font-weight: 700; } .delta .num { min-width: 0; }
.acts { display: flex; gap: 8px; margin-top: 8px; } .acts .btn { flex: 1; white-space: nowrap; gap: 4px; padding: 6px 8px; }
.btn.up { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 12px; min-height: 64px; width: 100%; margin-top: 8px; justify-content: flex-start; }
.up .t { flex: 1; min-width: 0; } .up .nm { font-weight: 800; font-size: 15px; } .up .ds { font-size: 12px; color: var(--ar-text-sub); margin-top: 1px; font-weight: 500; }
.up.iv .nm { color: var(--ar-mana); } .up.mana .nm { color: var(--ar-mana-x); }
.up .nm .num, .up .ds .num { min-width: 0; font-size: inherit; text-align: left; }
.note { font-size: 11px; color: var(--ar-text-sub); margin: 4px 0; font-weight: 600; }
.note .num { min-width: 0; }
/* ---------- gem bag / slots / shop (魔石): dark octagon pits, no coloured squares */
.gems { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0; }
.gcell, .slot { --fr: 8px; --fill: var(--ar-pit); --bw: 1.5px; --ring: color-mix(in srgb, var(--ar-brass) 30%, var(--ar-ink)); }
.gcell { min-height: 48px; padding: 0; border: 0; display: flex; align-items: center; justify-content: center; }
.gcell::before, .slot::before { background-image: linear-gradient(180deg, rgba(10,12,24,.9), transparent 35%), linear-gradient(0deg, rgba(255,255,255,.06) 1px, transparent 1px); background-color: var(--ar-pit); }
.gcell.sel, .slot.sel { --ring: linear-gradient(180deg, var(--ar-brass-hi), var(--ar-brass)); }
.gcell.sel::after, .slot.sel::after { content: ""; position: absolute; inset: 3px; border: 1px solid var(--ar-mana); pointer-events: none; clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px); }
.gcell .dash, .slot .dash { position: absolute; inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); pointer-events: none; }
.dash polygon { fill: none; stroke: color-mix(in srgb, var(--ar-brass) 30%, transparent); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.gem { --gc: var(--ar-mana); width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: relative; }
.gem .ai { width: 92%; height: 92%; position: relative; }
.gem em { display: none; }
.gem[data-g=fire] { --gc: var(--ar-fire); } .gem[data-g=thunder] { --gc: var(--ar-thunder); } .gem[data-g=ice] { --gc: var(--ar-ice); }
.gem[data-g=rapid], .gem[data-g=split], .gem[data-g=pierce], .gem[data-g=echo], .gem[data-g=finish], .gem[data-g=fray], .gem[data-g=repel] { --gc: var(--ar-gem-green); }
.gem[data-g=far], .gem[data-g=heavy], .gem[data-g=hunter], .gem[data-g=crit], .gem[data-g=strong], .gem[data-g=sweep], .gem[data-g=first], .gem[data-g=lone], .gem[data-g=bond], .gem[data-g=rally] { --gc: var(--ar-gem-red); }
.gem[data-g=absorb], .gem[data-g=store] { --gc: var(--ar-gem-blue); } .gem[data-g=relay] { --gc: var(--ar-relay); } .gem[data-g=wealth] { --gc: var(--ar-coin); }
.slots { display: flex; gap: 6px; margin: 6px 0; }
.slot { flex: 1; min-height: 52px; padding: 4px 6px; display: flex; align-items: center; gap: 6px; font-size: 12px; text-align: left; border: 0; color: var(--ar-text-sub); }
.slot .gem { width: 40px; height: 40px; flex: none; }
.slot.ok { --ring: var(--ar-mana); color: var(--ar-text); }
.slots.core { padding-left: 12px; }
.slots.core .slot { flex: 0 0 calc(50% - 6px); min-width: 0; min-height: 48px; padding: 4px 12px 4px 14px; }      /* 核の魔石の枠: about two bag cells wide, left aligned (the weapon's slots keep their own look) */
.sh-r { display: flex; align-items: center; gap: 8px; flex: none; }
.cgmark { width: 44px; height: 44px; flex: none; padding: 0; border: 1.5px solid color-mix(in srgb, var(--ar-brass) 55%, transparent); border-radius: 10px; background: rgba(240, 207, 133, .08); display: flex; align-items: center; justify-content: center; position: relative; color: var(--ar-brass-hi); }
.cgmark.new { animation: cgGlow 1.3s ease-in-out 4; }
@keyframes cgGlow { 0%, 100% { box-shadow: 0 0 0 rgba(240, 207, 133, 0); } 50% { box-shadow: 0 0 12px 3px rgba(240, 207, 133, .75); } }
.cgmark .gem { width: 30px; height: 30px; }
.cgmark svg { width: 28px; height: 28px; fill: none; stroke: var(--ar-brass-hi); stroke-width: 1.7; stroke-dasharray: 3.2 2.6; }
.slot.idle .gem { opacity: .72; }      /* 核の魔石の枠: a gem that does not work yet (a trap-type gem without 線の罠 / 燃える線) */
.note.cidle { font-size: 11px; margin-top: 3px; }
.slot span:not(.gem) { position: relative; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shopc { --fill: var(--ar-page-hi); --bw: 1px; --ring: color-mix(in srgb, var(--ar-brass) 40%, transparent); display: flex; gap: 8px; align-items: center; padding: 6px 8px; margin-top: 6px; min-height: 52px; text-align: left; }
.shopc .gem { width: 40px; height: 40px; flex: none; } .shopc .t { flex: 1; min-width: 0; } .shopc .nm { font-weight: 800; font-size: 13px; } .shopc .ds { font-size: 11px; color: var(--ar-text-sub); line-height: 1.3; }
.shopc .btn { min-width: 64px; }
.gdet { --fill: var(--ar-page-hi); --bw: 1px; --ring: color-mix(in srgb, var(--ar-brass) 40%, transparent); margin-top: 6px; padding: 6px 10px; font-size: 12px; min-height: 48px; } .gdet b { font-size: 14px; }
h3 { margin: 8px 0 2px; font-size: 11px; font-weight: 600; color: var(--ar-text-sub); }
.wi { font-size: 11px; color: var(--ar-text-sub); margin: 2px 0 4px; }

/* an open panel is above the tutorial finger and the red hit vignette (11-27: they were drawn over the gem sheet) */
#sheet { z-index: 4; }
body.insheet #finger, body.insheet #redflash { display: none !important; }
body.insheet .tag { visibility: hidden; }          /* round 6: field tags (the 「Lv3」 of an upgraded tower) peeked out under the panel's foot */

/* scroll hint (11-27 design review: the gem bag was below the fold of a tall weapon panel with nothing saying so): a soft fade + chevron at the foot while there is more to scroll to */
#sheet::after { content: ""; position: absolute; left: var(--bw); right: var(--bw); bottom: 0; height: 36px; z-index: 2; pointer-events: none; opacity: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 8'%3E%3Cpath d='M1 1l7 6 7-6' fill='none' stroke='%23f0cf85' stroke-width='2'/%3E%3C/svg%3E") 50% calc(100% - 7px) / 16px 8px no-repeat, linear-gradient(180deg, transparent, var(--ar-page) 85%); }
#sheet.more::after { opacity: 1; }

/* gems that do not fit the chosen tower (docs/specs/arcalink-run-detail.md 1): grey, still pressable (a short notice; merging still works) */
.gcell { position: relative; }
.gcell.nofit .gem { filter: grayscale(1) brightness(1.9) contrast(.85); opacity: .55; }      /* grey at one level for every colour (a red gem was near black), then lifted */
.gcell .nfm { position: absolute; right: 4px; bottom: 4px; width: 11px; height: 11px; pointer-events: none; border: 1.5px solid rgba(231,236,248,.85); border-radius: 50%; background: linear-gradient(to top right, transparent calc(50% - 1px), rgba(231,236,248,.9) calc(50% - 1px), rgba(231,236,248,.9) calc(50% + 1px), transparent calc(50% + 1px)); }      /* the small slash: does not fit */
.gdet .fitl { color: var(--ar-gold-hi, #f0cf85); font-size: 12px; font-weight: 800; margin-bottom: 2px; }

/* the fit notice stays readable over an open panel: top of the screen when the panel is at the bottom */
body.fittoast #toast { z-index: 6; }
body.fittoast-up #toast { top: calc(env(safe-area-inset-top) + 64px); bottom: auto; }
/* (12-01 QA) an 「A → B」 delta never breaks around the arrow */
.nwu { white-space: nowrap; }
.sh-h .sub .pct { margin-left: 0; color: var(--ar-brass-hi); }

/* 全体の強化 (12-01 長旅): the 無限ウェーブ's shop line, above the gems */
.shopc.boost .bsti { display: flex; width: 40px; height: 40px; flex: none; align-items: center; justify-content: center; } .shopc.boost .bsti svg { width: 30px; height: 30px; display: block; }
.shopc.boost .nm .num { min-width: 0; color: var(--ar-coin-hi); font-size: 13px; }

/* 全体の強化 (12-01 長旅 QA): the row has a gold frame and a small 「無限ウェーブ限定」 tag; the hint line / the bag button's dot lead the player to it */
.shopc.boost { --ring: linear-gradient(180deg, var(--ar-brass-hi), var(--ar-brass) 60%, var(--ar-brass-lo)); --bw: 2px; }
.shopc .ltag { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: 800; letter-spacing: .04em; color: #1a1204; background: linear-gradient(180deg, var(--ar-brass-hi), var(--ar-brass)); vertical-align: 1px; white-space: nowrap; }
