:root {
  --bg: #070a12;
  --bg-2: #0b1220;
  --panel: rgba(10, 18, 32, 0.84);
  --line: #22324e;
  --cyan: #3cefff;
  --cyan-dim: rgba(60, 239, 255, 0.16);
  --amber: #ffb020;
  --magenta: #ff4d8d;
  --text: #d7e6ff;
  --muted: #7d8fad;
  --danger: #ff5a4e;
  --ok: #3dff9a;
  --trap: #b388ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}
body {
  font-family: "Rajdhani", sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(60, 239, 255, 0.08), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(255, 77, 141, 0.08), transparent 45%),
    linear-gradient(180deg, #080c16, #05070d);
}
button, h1, h2, h3 { font-family: inherit; }
h1, h2 { font-family: "Orbitron", sans-serif; letter-spacing: 0.08em; }
#app {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.dd-kicker {
  margin: 0;
  color: var(--cyan);
  font-family: "Share Tech Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.dd-start {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.dd-start__panel {
  width: min(640px, 100%);
  padding: 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.dd-start h1 { margin: 8px 0 0; font-size: 42px; color: white; }
.dd-start__lead { color: var(--muted); font-size: 18px; }
.dd-start ul { color: var(--text); line-height: 1.5; padding-left: 18px; }

.dd-table {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
.dd-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 18, 0.9);
  flex-shrink: 0;
}
.dd-top h1 { margin: 0; font-size: 22px; }
.dd-top__meta { display: flex; align-items: center; gap: 12px; font-family: "Share Tech Mono", monospace; font-size: 12px; }
.dd-phases { display: flex; gap: 8px; }
.dd-phase-pip {
  padding: 6px 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.14em;
}
.dd-phase-pip.is-on { color: #041018; background: var(--cyan); border-color: var(--cyan); }

.dd-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr);
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  overflow: hidden;
}

.dd-play {
  display: flex;
  flex-direction: column;
  padding: 12px 16px 18px;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}
.dd-row { display: grid; grid-template-columns: 1fr 200px; gap: 10px; align-items: stretch; }
.dd-row--ai { grid-template-columns: 200px 1fr; }
.dd-hp {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px;
}
.dd-hp span { color: var(--muted); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; }
.dd-hp strong {
  display: block;
  font-family: "Share Tech Mono", monospace;
  font-size: 28px;
  color: var(--cyan);
}
.dd-hp--you strong { color: var(--amber); }
.dd-hp__track { height: 6px; background: #152033; margin: 8px 0; }
.dd-hp__track i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--cyan), #7affd6); }
.dd-hp--you .dd-hp__track i { background: linear-gradient(90deg, var(--amber), #ffe08a); }
.dd-hp small { color: var(--muted); }
.dd-ai-status {
  margin: 6px 0 0;
  color: var(--amber);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dd-ai-hand {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin-top: 8px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.dd-field {
  min-height: 116px;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px dashed var(--line);
  background: rgba(16, 24, 40, 0.45);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.dd-empty { color: var(--muted); padding: 12px; font-size: 13px; }
.dd-field.is-direct-target {
  border-style: solid;
  border-color: var(--danger);
  background: rgba(255, 90, 78, 0.08);
  justify-content: center;
}
.dd-inspect { color: var(--text); font-size: 14px; }
.dd-inspect p { margin: 0 0 8px; }
.dd-inspect__empty { color: var(--muted); margin: 0; }
.dd-inspect__art {
  display: block;
  height: 148px;
  overflow: hidden;
  border: 1px solid #24344f;
  margin-bottom: 10px;
}
.dd-inspect__art svg,
.dd-inspect__art img { width: 100%; height: 100%; display: block; object-fit: cover; }
.dd-inspect__sub { color: var(--cyan); margin: 0 0 6px; }
.dd-inspect__atk { font-family: "Share Tech Mono", monospace; color: var(--amber); }
.dd-inspect__tags { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.dd-log { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; max-height: 240px; overflow: auto; }

.dd-direct {
  border: 1px solid var(--danger);
  background: rgba(255, 90, 78, 0.16);
  color: #ffd4d0;
  padding: 18px 22px;
  cursor: pointer;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 13px;
  width: min(280px, 100%);
}
.dd-direct.is-ready { animation: pulse 1.2s infinite; }

.dd-dock {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 10px;
}
.dd-status { margin: 0 0 6px; color: var(--amber); font-size: 13px; }
.dd-hand {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 2px 12px;
  min-height: 160px;
  scrollbar-width: thin;
}
.dd-dock__actions { display: flex; gap: 8px; }

.dd-btn {
  border: 1px solid var(--line);
  background: #121b2c;
  color: var(--text);
  padding: 10px 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.dd-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.dd-btn--primary { background: var(--cyan); color: #041018; border-color: var(--cyan); font-weight: 700; }
.dd-btn--danger { background: var(--magenta); border-color: var(--magenta); color: #18040c; font-weight: 700; }

.dd-card {
  position: relative;
  flex: 0 0 auto;
  width: 124px;
  min-width: 124px;
  height: 176px;
  border: 1px solid #4d6488;
  background: #101826;
  color: var(--text);
  padding: 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.dd-field::-webkit-scrollbar,
.dd-hand::-webkit-scrollbar,
.dd-ai-hand::-webkit-scrollbar {
  height: 6px;
}
.dd-field::-webkit-scrollbar-thumb,
.dd-hand::-webkit-scrollbar-thumb,
.dd-ai-hand::-webkit-scrollbar-thumb {
  background: #2a3d5c;
  border-radius: 99px;
}
.dd-card--hand {
  width: 112px;
  min-width: 112px;
  height: 158px;
  padding: 6px 0;
}
.dd-card--hand .dd-card__art { height: 68px; }
.dd-card--hand .dd-card__name { font-size: 10px; }
.dd-card--field {
  width: 104px;
  min-width: 104px;
  height: 142px;
  padding: 6px 0;
}
.dd-card--monster { border-color: #4aa7c8; background: linear-gradient(180deg, #152433, #0d141f); }
.dd-card--trap { border-color: #8a6ad6; background: linear-gradient(180deg, #1a1530, #0e101c); }
.dd-card--fusion { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(255, 176, 32, 0.4), var(--shadow); }
.dd-card--hand .dd-card__kind,
.dd-card--hand .dd-card__name,
.dd-card--hand .dd-card__sub,
.dd-card--hand .dd-card__tag,
.dd-card--hand .dd-card__atk,
.dd-card--field .dd-card__kind,
.dd-card--field .dd-card__name,
.dd-card--field .dd-card__sub,
.dd-card--field .dd-card__tag,
.dd-card--field .dd-card__atk {
  padding-inline: 6px;
}
.dd-card--monster { border-color: #4aa7c8; background: linear-gradient(180deg, #152433, #0d141f); }
.dd-card--trap { border-color: #8a6ad6; background: linear-gradient(180deg, #1a1530, #0e101c); }
.dd-card--fusion { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(255, 176, 32, 0.4), var(--shadow); }
.dd-card__kind {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.dd-card__name,
.dd-card__sub,
.dd-card__tag {
  display: block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.dd-card__name { font-family: "Orbitron", sans-serif; font-size: 11px; }
.dd-card__sub, .dd-card__tag {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
  line-height: 1.2;
}
.dd-card__art {
  display: block;
  width: 100%;
  align-self: stretch;
  flex-shrink: 0;
  height: 78px;
  overflow: hidden;
  border: 1px solid #24344f;
}
.dd-card--hand .dd-card__art,
.dd-card--field .dd-card__art {
  width: 100%;
  border-left: 0;
  border-right: 0;
}
.dd-card--field .dd-card__art { height: 58px; }
.dd-card--field .dd-card__name { font-size: 10px; }
.dd-card__art svg,
.dd-card__art img { width: 100%; height: 100%; display: block; object-fit: cover; }
.dd-card__atk {
  margin-top: auto;
  font-family: "Share Tech Mono", monospace;
  color: var(--amber);
  font-size: 12px;
}
.dd-card__atk.is-mod { color: var(--ok); }
.dd-card--back {
  width: 42px;
  min-width: 42px;
  height: 58px;
  background: repeating-linear-gradient(135deg, #122036, #122036 8px, #0c1626 8px, #0c1626 16px);
  color: var(--cyan);
  align-items: center;
  justify-content: center;
  cursor: default;
}
.dd-card--back:hover { transform: none; }
.dd-card__back-mark { font-family: "Orbitron", sans-serif; font-size: 11px; }

.is-playable { box-shadow: 0 0 0 2px var(--cyan); }
.is-attackable { box-shadow: 0 0 0 2px var(--ok); }
.is-targetable { box-shadow: 0 0 0 2px var(--magenta); animation: pulse 1.1s infinite; }
.is-selected { transform: translateY(-10px); box-shadow: 0 0 0 2px var(--amber), var(--shadow); }

.dd-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: #080d16;
}
.dd-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.dd-tab {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 12px 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  cursor: pointer;
}
.dd-tab:last-child { border-right: 0; }
.dd-tab.is-active {
  color: #041018;
  background: var(--cyan);
  font-weight: 700;
}
.dd-tab-panel {
  display: none;
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 20px;
}
.dd-tab-panel.is-active {
  display: flex;
  flex-direction: column;
}
.dd-tab-panel h3 {
  margin: 16px 0 8px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--cyan);
}
.dd-tab-panel section:first-child h3 { margin-top: 0; }
.dd-zone-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
  margin: 12px 0 4px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.dd-zone-actions .dd-btn {
  width: 100%;
  padding: 10px 8px;
  font-size: 11px;
}
.dd-sidebar__meta {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: "Share Tech Mono", monospace;
  font-size: 12px;
}

.dd-debug { font-size: 13px; }
.dd-debug h3 { margin: 14px 0 6px; font-size: 11px; letter-spacing: 0.14em; color: var(--cyan); }
.dd-debug__list { margin: 0; padding-left: 18px; }
.dd-debug__list li { display: flex; justify-content: space-between; gap: 8px; margin: 4px 0; }
.dd-debug__list .is-chosen { color: var(--ok); }
.dd-debug__row { display: flex; justify-content: space-between; color: var(--muted); }
.dd-debug__total { color: var(--text); border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.dd-debug__pick { color: var(--amber); }

.dd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 14, 0.72);
  display: grid;
  place-items: center;
  z-index: 20;
}
.dd-start[hidden],
.dd-table[hidden],
.dd-overlay[hidden],
.dd-btn[hidden] {
  display: none !important;
}
.dd-overlay--zone { z-index: 19; }
.dd-overlay__card {
  width: min(420px, 92vw);
  background: #10192a;
  border: 1px solid var(--cyan);
  padding: 24px;
  box-shadow: var(--shadow);
}
.dd-overlay__card--wide {
  width: min(960px, 94vw);
  max-height: min(86vh, 920px);
  overflow: auto;
  padding: 20px 22px;
}
.dd-overlay__actions { display: flex; gap: 8px; margin-top: 16px; }
.dd-zone__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.dd-zone__head h2 { margin: 0; font-size: 18px; }
.dd-zone-lead {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}
.dd-zone-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.dd-zone-col h3 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--cyan);
}
.dd-zone-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 24, 0.7);
}
.dd-zone-item.is-used { opacity: 0.62; }
.dd-zone-item h4 { margin: 0 0 4px; font-size: 14px; }
.dd-zone-item p { margin: 0 0 6px; font-size: 13px; }
.dd-zone-item__art {
  height: 110px;
  overflow: hidden;
  border: 1px solid #24344f;
}
.dd-zone-item__art svg,
.dd-zone-item__art img { width: 100%; height: 100%; display: block; object-fit: cover; }
.dd-zone-item__kicker {
  margin: 0 0 2px;
  color: var(--amber);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.dd-zone-item__sub { color: var(--cyan); }
.dd-zone-item__atk { font-family: "Share Tech Mono", monospace; color: var(--amber); }
.dd-zone-item__summon { color: var(--muted); }
.dd-zone-item--extra .dd-zone-item__summon,
.dd-zone-item--extra .dd-zone-mats { grid-column: 1 / -1; }
.dd-zone-mats {
  display: flex;
  align-items: end;
  gap: 8px;
}
.dd-zone-mat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 0;
  max-width: 120px;
}
.dd-zone-mat__art {
  height: 64px;
  overflow: hidden;
  border: 1px solid #24344f;
  background: #0a1018;
}
.dd-zone-mat__art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.dd-zone-mat__name {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dd-zone-mat__plus {
  flex: 0 0 auto;
  color: var(--cyan);
  font-weight: 700;
  padding-bottom: 18px;
}
.dd-zone-empty { color: var(--muted); margin: 0; }

.is-ai-turn .dd-hand, .is-ai-turn .dd-field { pointer-events: none; opacity: 0.86; }

@keyframes pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

@media (max-width: 720px) {
  .dd-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 42vh);
  }
  .dd-sidebar {
    height: auto;
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .dd-row, .dd-row--ai { grid-template-columns: 1fr; }
  .dd-top { flex-wrap: wrap; }
  .dd-zone-grid { grid-template-columns: 1fr; }
  .dd-zone-item { grid-template-columns: 72px minmax(0, 1fr); }
}
