.nocte-magic-deck {
  --nd-ink: #e6e8df;
  --nd-muted: #9faea6;
  --nd-line: #b8cbb529;
  --nd-accent: #bbd5ba;
  --nd-surface: #0c1613;
  --nd-card-width: clamp(34px, 9.4vw, 76px);
  width: 100%;
  min-width: 0;
  isolation: isolate;
  color: var(--nd-ink);
  font: 400 13px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color-scheme: dark;
}
.nocte-magic-deck *, .nocte-magic-deck *::before, .nocte-magic-deck *::after { box-sizing: border-box; }
.nocte-magic-deck button, .nocte-magic-deck input { font: inherit; }
.nocte-magic-deck button { -webkit-tap-highlight-color: transparent; color: inherit; cursor: pointer; }
.nocte-magic-deck button:disabled { cursor: default; }
.nocte-magic-deck button:focus-visible, .nocte-magic-deck input:focus-visible { outline: 2px solid var(--nd-accent); outline-offset: 5px; }
.nocte-magic-deck svg { width: 20px; height: 20px; flex-shrink: 0; }
.nd-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.nd-kicker { font-size: 9px; letter-spacing: .18em; color: var(--nd-muted); }
.nd-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; min-height: 44px; border: 1px solid var(--nd-line); border-radius: 3px; background: #a8c6ad08; padding: 9px 14px; transition: transform .2s, background .2s, border-color .2s; }
.nd-button:hover:not(:disabled) { background: #b8d3ba14; border-color: #c1d6bd6b; transform: translateY(-1px); }
.nd-button:active:not(:disabled) { transform: scale(.98); }
.nd-button:disabled { opacity: .42; }
.nd-shuffle { font-size: 11px; border-color: transparent; padding-inline: 8px; }
.nd-shuffle svg { width: 17px; height: 17px; }
.nd-stage { width: 100%; height: clamp(310px, 85vw, 650px); position: relative; overflow: hidden; isolation: isolate; touch-action: pan-y; contain: layout paint; }
.nd-stage::after { content: ""; position: absolute; inset: 9% 0; background: radial-gradient(ellipse, #729c7210, transparent 65%); z-index: -1; pointer-events: none; }
.nd-ring { position: absolute; inset: 0; }
.nd-card { position: absolute; left: 50%; top: 46%; margin-left: calc(var(--nd-card-width) * -.5); margin-top: calc(var(--nd-card-width) * -.75); width: var(--nd-card-width); aspect-ratio: 2 / 3; padding: 0; border: 1px solid #8b9e8c61; border-radius: 4px; background: #101b17; box-shadow: 0 2px 0 #08100d, 0 6px 12px #0008; transform-origin: center; backface-visibility: hidden; }
.nd-back, .nd-active-card img, .nd-tray-back { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; user-select: none; pointer-events: none; }
.nd-card.is-active { border-color: #dcf0d9; box-shadow: 0 0 0 1px #d3eac1bb, 0 0 13px #a5d7a947, 0 6px 12px #000a; }
.nd-card.is-selected::after { content: ""; position: absolute; inset: 3px; border: 2px solid #cde5c0; border-radius: 2px; background: #b1d5a81f; pointer-events: none; }
.nd-card.is-held { filter: grayscale(.9); }
.nocte-magic-deck[data-state="stack"] .nd-card,
.nocte-magic-deck[data-state="scatter"] .nd-card,
.nocte-magic-deck[data-state="circle"] .nd-card { will-change: transform, opacity; }
.nd-halo { position: absolute; width: min(80%, 630px); aspect-ratio: 1; left: 50%; top: 46%; transform: translate(-50%, -50%) scaleY(.87); pointer-events: none; opacity: .72; }
.nd-halo i { position: absolute; border: 1px solid #c4ddbc15; border-radius: 50%; inset: 2%; }
.nd-halo i:nth-child(2) { inset: 17%; border-style: dashed; border-color: #c4ddbc20; }
.nd-halo i:nth-child(3) { inset: 33%; border-color: #c4ddbc10; }
.nd-halo::after { content: ""; position: absolute; inset: 10%; border-radius: 50%; background: radial-gradient(circle, #b6d9aa18 0, transparent 65%); opacity: .2; transform: scale(.55); }
.nocte-magic-deck[data-state="scatter"] .nd-halo::after { animation: nd-magic-pulse 1.5s cubic-bezier(.16,1,.3,1) both; }
@keyframes nd-magic-pulse { 0% { transform: scale(.45); opacity: .1; } 40% { opacity: 1; } 100% { transform: scale(1.35); opacity: .05; } }
.nd-focus { position: absolute; z-index: 120; left: 50%; top: 46%; transform: translate(-50%, -50%); display: flex; align-items: center; flex-direction: column; gap: 9px; width: 160px; pointer-events: none; opacity: 1; transition: opacity .3s; }
.nocte-magic-deck:not([data-state="ready"]) .nd-focus { opacity: 0; }
.nd-focus-eyebrow { font-size: 9px; letter-spacing: .08em; color: #c2d5bf; text-shadow: 0 2px 10px #000; }
.nd-active-card { position: relative; width: clamp(88px, 25vw, 128px); aspect-ratio: 2 / 3; padding: 0; border: 1px solid #cadaaa9c; border-radius: 5px; background: #15221c; box-shadow: 0 0 0 5px #0a1512bb, 0 0 0 6px #b2c6a82c, 0 12px 26px #000a; pointer-events: auto; transition: transform .25s, box-shadow .25s; }
.nd-active-card:hover:not(:disabled) { transform: translateY(-4px) rotate(-1deg); box-shadow: 0 0 0 5px #0a1512dd, 0 0 0 6px #b2c6a85c, 0 18px 30px #000b; }
.nd-active-card.is-selected { border-color: #e0ebc8; box-shadow: 0 0 0 5px #183322dd, 0 0 0 6px #e1efcda8, 0 12px 26px #000a; }
.nd-active-card.is-held img { filter: grayscale(.95); opacity: .55; }
.nd-active-check { position: absolute; right: -10px; top: -10px; display: none; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: #c8dec0; color: #102416; border: 2px solid #172c1e; }
.nd-active-check svg { width: 17px; height: 17px; }
.is-selected .nd-active-check { display: flex; }
.nd-counter { font: 11px Georgia, "Times New Roman", serif; letter-spacing: .18em; color: #cfdbc6; }
.nd-navigation { display: grid; grid-template-columns: 46px minmax(0, 1fr) 46px; align-items: center; gap: 16px; width: min(440px, 100%); margin: -5px auto 0; }
.nd-previous, .nd-next { padding: 8px; width: 46px; height: 46px; }
.nd-range-wrap { min-width: 0; text-align: center; }
.nd-range-wrap label { display: block; color: var(--nd-muted); font-size: 10px; letter-spacing: .03em; }
.nd-range { display: block; width: 100%; height: 44px; margin: 0; padding: 0; accent-color: #b9d0b0; cursor: ew-resize; }
.nd-action-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; max-width: 530px; margin: 3px auto 24px; min-height: 50px; }
.nd-active-status { margin: 0; color: var(--nd-muted); font-size: 11px; line-height: 1.6; }
.nd-select { min-width: 108px; background: #c9d9bd; color: #0e1e17 !important; border-color: #d7e5cc; font-size: 12px; font-weight: 600; }
.nd-select:hover:not(:disabled) { background: #deead4; border-color: #eaf1df; }
.nd-tray-head { max-width: 530px; margin: 0 auto 10px; display: flex; align-items: center; justify-content: space-between; color: var(--nd-muted); font-size: 11px; }
.nd-tray-head strong { color: var(--nd-accent); font: 12px Georgia, "Times New Roman", serif; letter-spacing: .15em; }
.nd-tray { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; list-style: none; margin: 0 auto; padding: 0; width: min(530px, 100%); }
.nd-tray-slot { display: flex; position: relative; align-items: center; justify-content: center; flex-direction: column; min-height: 126px; margin: 0; border: 1px solid var(--nd-line); border-radius: 4px; background: linear-gradient(145deg, #b4d1b106, #b4d1b102); }
.nd-tray-number { position: absolute; top: 8px; left: 9px; z-index: 1; font: 11px Georgia, "Times New Roman", serif; letter-spacing: .08em; color: var(--nd-muted); }
.nd-tray-empty { font-size: 9px; color: #9eac9e8c; letter-spacing: .03em; }
.nd-tray-slot.is-filled { border-color: #bcd2b55c; }
.nd-tray-back { width: 57px; height: 86px; border: 1px solid #b8c4a65e; box-shadow: 0 6px 14px #0007; margin: 6px 0; }
.nd-tray-remove { position: absolute; z-index: 2; display: flex; align-items: center; justify-content: center; top: 0; right: 0; padding: 0; width: 44px; height: 44px; background: #0b1912eb; color: #d6e4cf; border: 0; border-left: 1px solid #b2c6a829; border-bottom: 1px solid #b2c6a829; border-radius: 0 3px 0 4px; }
.nd-tray-remove:hover { background: #264132; }
.nd-tray-remove svg { width: 16px; height: 16px; }
.nd-hold { color: #b4b49a; font-size: 10px; max-width: 530px; margin: 15px auto 0; line-height: 1.7; }
.nd-hold[hidden] { display: none; }
.nd-hint { max-width: 530px; font-size: 10px; line-height: 1.7; color: #84978b; margin: 9px auto 0; }
.nd-live { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.nocte-magic-deck[data-asset-error="true"] .nd-stage { opacity: .35; }
@media (min-width: 768px) {
  .nocte-magic-deck { --nd-card-width: 68px; }
  .nd-kicker { font-size: 10px; }
  .nd-focus { gap: 14px; }
  .nd-focus-eyebrow { font-size: 11px; }
  .nd-active-status { font-size: 12px; }
  .nd-action-row { margin-top: 10px; }
  .nd-tray-slot { min-height: 146px; }
  .nd-tray-back { width: 68px; height: 102px; }
}
@media (min-width: 1024px) {
  .nocte-magic-deck { --nd-card-width: 76px; }
  .nd-stage { height: 650px; }
  .nd-navigation { margin-top: -12px; }
}
@media (max-width: 359px) {
  .nd-navigation { gap: 10px; }
  .nd-action-row { gap: 8px; grid-template-columns: minmax(0, 1fr) 108px; }
  .nd-select { padding-inline: 8px; font-size: 11px; }
  .nd-tray { gap: 8px; }
  .nd-tray-slot { min-height: 119px; }
  .nd-tray-back { width: 51px; height: 77px; }
  .nd-tray-number { left: 7px; }
}
/* Host can opt into a light canvas without altering the locked artwork. */
[data-theme="light"] .nocte-magic-deck, .nocte-magic-deck[data-theme="light"] {
  --nd-ink: #23392c; --nd-muted: #566e5b; --nd-line: #4e725731; --nd-accent: #355a3c; --nd-surface: #f2f1e7; color-scheme: light;
}
[data-theme="light"] .nocte-magic-deck .nd-hold { color: #706a46; }
[data-theme="light"] .nocte-magic-deck .nd-hint { color: #5c725f; }
[data-theme="light"] .nocte-magic-deck .nd-tray-empty { color: #6a806d; }
@media (prefers-reduced-motion: reduce) {
  .nocte-magic-deck *, .nocte-magic-deck *::before, .nocte-magic-deck *::after { animation: none !important; transition: none !important; }
}
.nocte-magic-deck[data-reduced-motion="true"] *, .nocte-magic-deck[data-reduced-motion="true"] *::before, .nocte-magic-deck[data-reduced-motion="true"] *::after { animation: none !important; transition: none !important; }
