:root {
  color-scheme: dark;
  --bg: #101318;
  --panel: #1b212b;
  --panel-2: #252d39;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4efe6;
  --muted: #aeb6c3;
  --gold: #f0bf5b;
  --blue: #48a4ff;
  --red: #e65a5a;
  --green: #70c77a;
  --epic: #b67aff;
  --legend: #ff9c3f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(240, 191, 91, 0.13), transparent 26rem),
    radial-gradient(circle at 80% 0%, rgba(72, 164, 255, 0.16), transparent 24rem),
    linear-gradient(145deg, #0d1015, #161b22 55%, #0f1419);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.hidden {
  display: none !important;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.home-screen,
.guide-overlay,
.library-overlay,
.changelog-overlay,
.settings-overlay,
.deck-builder-overlay,
.online-overlay,
.intro-overlay,
.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(240, 191, 91, 0.26), transparent 22rem),
    radial-gradient(circle at 10% 82%, rgba(72, 164, 255, 0.2), transparent 20rem),
    rgba(9, 12, 16, 0.96);
}

.home-screen {
  z-index: 30;
}

.home-panel {
  width: min(760px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.035)),
    var(--panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.home-panel h1 {
  font-size: clamp(46px, 9vw, 88px);
  line-height: 1;
}

.home-copy,
.home-notice {
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.home-menu {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.home-option {
  min-height: 104px;
  padding: 16px;
  text-align: left;
  display: grid;
  align-content: center;
  gap: 6px;
}

.home-option span {
  font-size: 24px;
  font-weight: 900;
}

.home-option small {
  color: inherit;
  opacity: 0.72;
  font-weight: 800;
}

.home-stats {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.home-stats span {
  min-height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: #dbe5f4;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.danger-button {
  color: #ffb7b7;
}

.settings-section {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.settings-section strong {
  color: var(--gold);
  font-size: 18px;
  font-weight: 1000;
}

.settings-section p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.theme-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.06);
  color: #dbe5f4;
  font-weight: 1000;
}

.theme-button.active {
  border-color: rgba(240, 191, 91, 0.75);
  background: var(--gold);
  color: #17110a;
}

.guide-overlay,
.library-overlay,
.changelog-overlay,
.settings-overlay,
.deck-builder-overlay,
.online-overlay {
  z-index: 35;
  padding: 18px;
}

.guide-panel,
.library-panel,
.changelog-panel,
.settings-panel,
.deck-builder-panel,
.online-panel {
  width: min(1180px, 100%);
  max-height: calc(100vh - 36px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(27, 33, 43, 0.96);
  overflow: auto;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
}

.guide-panel {
  width: min(980px, calc(100vw - 32px));
}

.changelog-panel,
.settings-panel {
  width: min(760px, calc(100vw - 32px));
}

.version-card,
.changelog-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.version-card {
  margin-bottom: 12px;
}

.version-card strong,
.changelog-list span {
  color: var(--gold);
  font-weight: 1000;
}

.version-card p,
.changelog-list p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-weight: 800;
}

.changelog-list {
  display: grid;
  gap: 10px;
}

.changelog-list h3 {
  margin: 4px 0 0;
  font-size: 20px;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.library-tabs {
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.library-tab {
  min-height: 38px;
  border-radius: 999px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-weight: 900;
}

.library-tab.active {
  background: var(--gold);
  border-color: rgba(240, 191, 91, 0.64);
  color: #1b1204;
}

.library-series-intro,
.library-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.library-series-intro {
  margin-bottom: 14px;
}

.library-series-intro strong,
.library-empty strong {
  display: block;
  color: var(--gold);
  margin-bottom: 6px;
}

.library-series-intro p,
.library-empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 800;
}

.library-series-intro img,
.series-avatar,
.leader-card img,
.hero-portrait,
img[src$="otto-leader.png"] {
  width: 64px;
  height: 64px;
  max-width: 64px;
  max-height: 64px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 auto;
}

.leader-card {
  width: min(420px, 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  text-align: left;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.guide-flow {
  margin-bottom: 16px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.flow-step {
  flex: 1 1 118px;
  min-height: 86px;
  border: 1px solid rgba(240, 191, 91, 0.35);
  border-radius: 8px;
  padding: 11px 10px;
  display: grid;
  align-content: center;
  gap: 5px;
  background:
    linear-gradient(145deg, rgba(240, 191, 91, 0.16), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.05);
}

.flow-step strong {
  color: #ffe0a3;
  font-size: 15px;
}

.flow-step small {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.flow-arrow {
  min-width: 24px;
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 26px;
  font-weight: 900;
}

.guide-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.guide-grid strong {
  display: block;
  color: var(--gold);
  margin-bottom: 7px;
}

.guide-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 700;
}

.skill-library {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.skill-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.skill-item strong {
  display: block;
  color: var(--gold);
  margin-bottom: 6px;
}

.skill-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.card-library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.card-library .card {
  min-height: 240px;
  cursor: default;
}

.deck-builder-panel {
  width: min(1320px, 100%);
}

.deck-builder-toolbar {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.deck-builder-toolbar strong {
  display: block;
  color: var(--gold);
  font-size: 22px;
}

.deck-builder-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.deck-builder-warning {
  color: #ffb7b7 !important;
}

.deck-builder-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.online-panel {
  width: min(840px, calc(100vw - 32px));
}

.online-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.online-card,
.room-share,
.online-room-lobby {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.online-card {
  display: grid;
  align-content: start;
  gap: 12px;
}

.online-card strong,
.room-share span {
  color: var(--gold);
  font-size: 18px;
  font-weight: 1000;
}

.online-card p,
.online-status,
.online-invite-link {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.55;
}

.join-row,
.room-share {
  display: flex;
  align-items: center;
  gap: 10px;
}

.join-row input {
  min-width: 0;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--text);
  font: inherit;
  font-weight: 900;
  text-transform: uppercase;
}

.room-share {
  margin-top: 12px;
  justify-content: space-between;
}

.online-room-lobby {
  margin-top: 12px;
  display: grid;
  gap: 12px;
  border-color: rgba(240, 191, 91, 0.45);
  background:
    linear-gradient(135deg, rgba(240, 191, 91, 0.12), rgba(72, 164, 255, 0.07)),
    rgba(255, 255, 255, 0.05);
}

.online-room-main,
.online-room-players {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.online-room-main span,
.online-room-players span {
  color: var(--muted);
  font-weight: 900;
}

.online-room-main strong {
  color: var(--gold);
  font-size: 20px;
  font-weight: 1000;
}

.online-room-players {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.online-ready-button,
.online-edit-deck-button {
  width: 100%;
}

.deck-builder-overlay.online-deck-edit {
  z-index: 45;
}

.online-ready-button.is-ready {
  background: #67ff9a;
  color: #06140a;
}

.online-invite-link {
  overflow-wrap: anywhere;
  color: var(--gold);
}

.battle-online-status {
  border-color: rgba(72, 164, 255, 0.44);
}

.turn-timer-status {
  border-color: rgba(240, 191, 91, 0.44);
  color: #ffe0a3;
}

.turn-timer-status.is-low {
  border-color: rgba(255, 129, 129, 0.66);
  background: rgba(255, 88, 88, 0.14);
  color: #ffc7c7;
}

.opponent-resource-status {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #dbe5f4;
}

.online-room-lobby p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.45;
}

.online-status {
  margin-top: 12px;
}

.deck-builder-cards {
  display: grid;
  gap: 18px;
}

.deck-builder-section {
  display: grid;
  gap: 12px;
}

.deck-builder-section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
}

.deck-builder-section-header strong {
  color: var(--gold);
  font-size: 20px;
  font-weight: 1000;
}

.deck-builder-section-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.deck-builder-section-header span {
  flex: 0 0 auto;
  min-height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 14px;
  background: rgba(240, 191, 91, 0.14);
  border: 1px solid rgba(240, 191, 91, 0.3);
  color: #ffe0a3;
  font-weight: 1000;
}

.deck-builder-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.deck-builder-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.deck-builder-card .card {
  width: 100%;
  min-height: 240px;
  cursor: default;
}

.deck-builder-card .card:disabled {
  opacity: 1;
  filter: none;
}

.deck-card-controls {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 8px;
}

.deck-card-controls .ghost-button {
  min-height: 38px;
  padding: 0;
  font-size: 20px;
}

.deck-card-controls strong {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  font-size: 20px;
}

.intro-video {
  position: absolute;
  width: min(92vw, 900px);
  height: auto;
  opacity: 0;
  pointer-events: none;
}

.intro-canvas {
  position: absolute;
  width: min(112vw, 1080px);
  max-height: 92vh;
  opacity: 0;
  transform: scale(1.25);
  filter: saturate(1.15) contrast(1.05);
  pointer-events: none;
}

.intro-overlay.playing .intro-canvas {
  opacity: 0.42;
  animation: jumpFace 820ms ease-in-out infinite;
}

.intro-overlay.fallback-video .intro-video {
  opacity: 0.24;
  transform: scale(1.3);
}

.intro-content {
  position: relative;
  z-index: 2;
  width: min(760px, calc(100vw - 32px));
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 18px;
}

.intro-content h1 {
  font-size: clamp(48px, 10vw, 104px);
  text-shadow: 0 10px 0 rgba(0, 0, 0, 0.28), 0 0 40px rgba(240, 191, 91, 0.24);
  animation: titlePop 760ms cubic-bezier(0.2, 1.5, 0.4, 1);
}

.intro-copy {
  margin: 0;
  color: #ffe0a3;
  font-size: 20px;
  font-weight: 900;
}

.intro-cast {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 12px;
  width: min(560px, 100%);
}

.intro-cast img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: var(--panel-2);
  animation: characterFlyIn 780ms cubic-bezier(0.2, 1.4, 0.3, 1) both;
}

.intro-cast img:nth-child(2) {
  animation-delay: 80ms;
}

.intro-cast img:nth-child(3) {
  animation-delay: 160ms;
}

.intro-cast img:nth-child(4) {
  animation-delay: 240ms;
}

.intro-actions,
.result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.intro-actions .primary-button {
  animation: goofyWobble 1.1s ease-in-out infinite;
}

.intro-overlay.finished {
  animation: overlayOut 260ms ease forwards;
}

.intro-overlay {
  z-index: 30;
  padding: 24px 16px;
  overflow: auto;
}

.intro-content {
  width: min(900px, calc(100vw - 32px));
  padding: 16px 0;
  gap: 14px;
}

.intro-content h1 {
  font-size: clamp(48px, 9vw, 96px);
}

.intro-cast {
  width: min(520px, 100%);
}

.intro-actions {
  width: min(720px, 100%);
}

.intro-actions .primary-button {
  flex: 1 1 460px;
  min-height: 64px;
  clip-path: polygon(0 8%, 100% 0, 98% 100%, 2% 92%);
  font-size: 28px;
}

.intro-actions .ghost-button {
  flex: 0 1 120px;
}

.difficulty-panel {
  width: min(720px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(240, 191, 91, 0.24);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(12, 14, 18, 0.62);
  text-align: left;
}

.difficulty-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.difficulty-copy strong {
  color: var(--gold);
  font-size: 15px;
  font-weight: 1000;
}

.difficulty-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.difficulty-options {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.difficulty-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.06);
  color: #dbe5f4;
  font-size: 13px;
  font-weight: 1000;
}

.difficulty-button.active {
  border-color: rgba(240, 191, 91, 0.7);
  background: var(--gold);
  color: #17110a;
}

.intro-content .cover-menu {
  width: min(920px, 100%);
  margin-top: 0;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cover-menu .home-option {
  min-height: 70px;
  padding: 10px 12px;
  text-align: center;
  align-content: center;
}

.cover-menu .home-option span {
  font-size: 15px;
}

.cover-menu .home-option small {
  font-size: 11px;
}

.intro-content .home-notice {
  margin-top: 0;
}

.intro-content .home-stats {
  width: min(700px, 100%);
  margin-top: 0;
}


/* Theater title screen skin: generated atmosphere background, HTML/CSS UI stays editable. */
.theme-theater .intro-overlay {
  background-image:
    radial-gradient(circle at 50% 26%, rgba(238, 190, 103, 0.2), transparent 21rem),
    linear-gradient(180deg, rgba(2, 7, 8, 0.18), rgba(2, 6, 7, 0.46) 78%, rgba(0, 0, 0, 0.68)),
    url("./assets/ui/theater-bg.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  padding: clamp(12px, 1.4vw, 22px);
}

.theme-theater .intro-overlay::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 44%, rgba(0, 0, 0, 0.54) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.48), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.52));
  z-index: 0;
}

.theme-theater .intro-content {
  width: min(1180px, calc(100vw - 28px));
  min-height: min(880px, calc(100dvh - 28px));
  gap: clamp(10px, 1.3vh, 15px);
  padding: clamp(18px, 2.2vh, 28px) clamp(14px, 2vw, 28px);
  border: 1px solid rgba(201, 150, 71, 0.22);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(3, 9, 10, 0.04), rgba(2, 6, 7, 0.22));
  box-shadow: inset 0 0 72px rgba(0, 0, 0, 0.34), 0 30px 70px rgba(0, 0, 0, 0.38);
}

.theme-theater .intro-kicker {
  margin: 0;
  color: #d6a960;
  letter-spacing: 0.32em;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(10px, 1vw, 14px);
  text-transform: uppercase;
  text-shadow: 0 0 16px rgba(215, 165, 82, 0.42);
}

.theme-theater .intro-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", "Noto Serif SC", serif;
  font-size: clamp(56px, 8.4vw, 130px);
  line-height: 0.9;
  background: linear-gradient(180deg, #fff0bf, #d7a756 45%, #8c632c 78%, #ffe8ad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 8px 20px rgba(0, 0, 0, 0.7), 0 0 34px rgba(230, 174, 83, 0.26);
  animation: none;
}

.theme-theater .intro-subtitle {
  position: relative;
  margin: 0;
  padding: 0 72px;
  color: #e8c47a;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(15px, 1.6vw, 22px);
  letter-spacing: 0.1em;
}

.theme-theater .intro-subtitle::before,
.theme-theater .intro-subtitle::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 54px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(226, 174, 86, 0.88), transparent);
}
.theme-theater .intro-subtitle::before { left: 0; }
.theme-theater .intro-subtitle::after { right: 0; }

.theme-theater .intro-cast {
  display: none;
}

.theme-theater .intro-actions {
  width: min(650px, 100%);
  margin-top: clamp(4px, 1vh, 12px);
}

.theme-theater #startIntroButton {
  min-height: clamp(72px, 10vh, 112px);
  flex: 1 1 520px;
  clip-path: none;
  border-radius: 8px;
  border: 0;
  background:
    linear-gradient(90deg, rgba(42, 22, 8, 0.18), transparent 14%, transparent 86%, rgba(42, 22, 8, 0.18)),
    url("./assets/ui/ticket-panel.png") center / 100% 100% no-repeat,
    linear-gradient(180deg, #ead6a5, #c69854 58%, #a66d32);
  color: #1d1309;
  font-family: Georgia, "Times New Roman", "Noto Serif SC", serif;
  font-size: clamp(30px, 4.2vw, 58px);
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 0 rgba(255, 246, 214, 0.78);
  box-shadow: 0 22px 42px rgba(0, 0, 0, 0.52), inset 0 0 0 3px rgba(255, 237, 181, 0.22);
  animation: none;
}

.theme-theater .intro-actions .ghost-button {
  flex: 0 1 110px;
  align-self: center;
  border: 1px solid rgba(209, 157, 79, 0.42);
  background: rgba(5, 12, 13, 0.72);
  color: #e9c985;
}

.theme-theater .difficulty-panel {
  width: min(980px, 100%);
  border-radius: 6px;
  border: 1px solid rgba(207, 155, 75, 0.52);
  background: linear-gradient(90deg, rgba(3, 9, 10, 0.84), rgba(12, 22, 22, 0.72));
  box-shadow: inset 0 0 0 1px rgba(255, 234, 177, 0.06), 0 14px 30px rgba(0, 0, 0, 0.44);
}

.theme-theater .difficulty-copy strong {
  color: #f0c777;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.08em;
}

.theme-theater .difficulty-copy small {
  color: rgba(239, 221, 180, 0.8);
}

.theme-theater .difficulty-button {
  border-radius: 4px;
  border-color: rgba(207, 155, 75, 0.42);
  background: rgba(6, 13, 14, 0.68);
  color: #d5b370;
}

.theme-theater .difficulty-button.active {
  border-color: rgba(111, 73, 30, 0.85);
  background: linear-gradient(180deg, #e4c07d, #b57a33);
  color: #1b1208;
}

.theme-theater .cover-menu {
  width: min(1120px, 100%);
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-items: stretch;
  gap: clamp(8px, 1vw, 14px);
}

.theme-theater .cover-menu .home-option {
  min-height: 128px;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid rgba(111, 70, 31, 0.62);
  border-radius: 15px;
  padding: 72px 10px 16px;
  color: #24170b;
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 241, 197, 0.34), transparent 42%),
    linear-gradient(180deg, rgba(255, 239, 191, 0.42), rgba(180, 130, 74, 0.52)),
    url("./assets/ui/menu-card-paper.png") center / cover no-repeat,
    linear-gradient(180deg, rgba(255, 238, 191, 0.82), rgba(185, 139, 82, 0.88));
  box-shadow:
    0 15px 30px rgba(0, 0, 0, 0.38),
    inset 0 0 0 2px rgba(255, 231, 174, 0.12),
    inset 0 -20px 34px rgba(66, 37, 14, 0.14);
  transform: translateY(0);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease, border-color 160ms ease;
}

.theme-theater .cover-menu .home-option::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: clamp(54px, 5.2vw, 72px);
  height: clamp(54px, 5.2vw, 72px);
  transform: translateX(-50%);
  border-radius: 12px;
  background: var(--menu-icon) center / contain no-repeat;
  filter: sepia(0.14) saturate(0.96) contrast(1.04) drop-shadow(0 5px 8px rgba(45, 24, 9, 0.32));
  opacity: 0.92;
  pointer-events: none;
  z-index: 0;
}

.theme-theater .cover-menu .home-option::after {
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: 11px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(72, 46, 23, 0.42), transparent);
  pointer-events: none;
  z-index: 0;
}

.theme-theater .cover-menu .home-option:hover {
  transform: translateY(-5px);
  filter: saturate(1.04) brightness(1.04);
  border-color: rgba(215, 165, 87, 0.78);
  box-shadow:
    0 22px 38px rgba(0, 0, 0, 0.48),
    inset 0 0 0 2px rgba(255, 235, 176, 0.18),
    0 0 24px rgba(225, 170, 82, 0.17);
}

.theme-theater .cover-menu .home-option span,
.theme-theater .cover-menu .home-option small {
  position: relative;
  z-index: 1;
}

.theme-theater .cover-menu .home-option span {
  color: #20160c;
  font-family: Georgia, "Times New Roman", "Noto Serif SC", serif;
  font-size: clamp(14px, 1.1vw, 18px);
  letter-spacing: 0.04em;
  text-shadow: 0 1px 0 rgba(255, 239, 197, 0.5);
}

.theme-theater .cover-menu .home-option small {
  color: rgba(45, 31, 18, 0.72);
  opacity: 1;
  line-height: 1.34;
}

.theme-theater #continueGameButton {
  --menu-icon: url("./assets/ui/menu-icon-continue.png");
}

.theme-theater #libraryButton {
  --menu-icon: url("./assets/ui/menu-icon-library.png");
}

.theme-theater #deckBuilderButton {
  --menu-icon: url("./assets/ui/menu-icon-build.png");
}

.theme-theater #guideButton {
  --menu-icon: url("./assets/ui/menu-icon-guide.png");
}

.theme-theater #changelogButton {
  --menu-icon: url("./assets/ui/menu-icon-changelog.png");
}

.theme-theater #onlineModeButton {
  --menu-icon: url("./assets/ui/menu-icon-online.png");
}

.theme-theater #settingsButton {
  --menu-icon: url("./assets/ui/menu-icon-settings.png");
}

.theme-theater .cover-menu .danger-button {
  --menu-icon: url("./assets/ui/menu-icon-exit.png");
  border-color: rgba(127, 61, 41, 0.72);
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 224, 187, 0.26), transparent 42%),
    linear-gradient(180deg, rgba(224, 181, 144, 0.42), rgba(131, 61, 46, 0.68)),
    url("./assets/ui/menu-card-paper.png") center / cover no-repeat,
    linear-gradient(180deg, rgba(215, 172, 135, 0.82), rgba(143, 76, 55, 0.9));
}

.theme-theater .cover-menu .danger-button span {
  color: #5a1d15;
}

.theme-theater .home-notice {
  color: rgba(235, 215, 176, 0.8);
  font-family: Georgia, "Times New Roman", serif;
}

.theme-theater .home-stats {
  width: min(860px, 100%);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(203, 154, 78, 0.48);
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(4, 10, 11, 0.86), rgba(13, 25, 25, 0.76));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
}

.theme-theater .home-stats span {
  min-height: 44px;
  border: 0;
  border-right: 1px solid rgba(218, 165, 83, 0.28);
  border-radius: 0;
  background: transparent;
  color: #e2bb72;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(12px, 1.15vw, 16px);
}

.theme-theater .home-stats span:last-child {
  border-right: 0;
}

@media (max-width: 1120px), (max-height: 780px) {
  .theme-theater .intro-content {
    min-height: auto;
    gap: 9px;
    padding: 14px;
  }

  .theme-theater .cover-menu {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .theme-theater .cover-menu .home-option {
    min-height: 86px;
    --menu-tilt: 0deg;
  }
}

@media (max-width: 760px) {
  .theme-theater .intro-subtitle {
    padding: 0;
  }

  .theme-theater .intro-subtitle::before,
  .theme-theater .intro-subtitle::after {
    display: none;
  }

  .theme-theater .difficulty-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .theme-theater .cover-menu,
  .theme-theater .home-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.result-overlay {
  z-index: 25;
  background: rgba(7, 9, 13, 0.78);
  backdrop-filter: blur(7px);
}

.result-panel {
  width: min(520px, calc(100vw - 32px));
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 28px;
  text-align: center;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
    var(--panel);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.42);
  animation: resultBurst 520ms cubic-bezier(0.2, 1.5, 0.35, 1);
}

.result-panel h2 {
  margin: 8px 0;
  font-size: clamp(38px, 8vw, 72px);
}

.result-panel p {
  margin: 0 0 20px;
  color: var(--muted);
  font-weight: 800;
}

.result-panel.win h2 {
  color: var(--gold);
}

.result-panel.lose {
  animation-name: defeatDrop;
}

.result-panel.lose h2 {
  color: var(--red);
}

.result-panel.draw h2 {
  color: #9cc7ff;
}

.result-panel.meme {
  width: min(640px, calc(100vw - 32px));
}

.result-meme-video {
  width: 100%;
  max-height: min(46vh, 360px);
  display: block;
  margin: 0 0 18px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  object-fit: cover;
  background: #05070a;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.drag-arrow {
  position: fixed;
  inset: 0;
  z-index: 18;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  overflow: visible;
}

.drag-arrow line {
  stroke: #ffe07a;
  stroke-width: 7;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(255, 224, 122, 0.7)) drop-shadow(0 0 18px rgba(230, 90, 90, 0.42));
  marker-end: url("#dragArrowHead");
}

.drag-arrow path {
  fill: #ffe07a;
}

@keyframes titlePop {
  0% {
    opacity: 0;
    transform: scale(0.54) rotate(-6deg);
  }
  70% {
    transform: scale(1.08) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes characterFlyIn {
  0% {
    opacity: 0;
    transform: translateY(80px) rotate(18deg) scale(0.55);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(0) scale(1);
  }
}

@keyframes goofyWobble {
  0%,
  100% {
    transform: rotate(-1deg) scale(1);
  }
  50% {
    transform: rotate(2deg) scale(1.06);
  }
}

@keyframes jumpFace {
  0%,
  100% {
    transform: scale(1.22) translateY(0) rotate(-1deg);
  }
  50% {
    transform: scale(1.36) translateY(-18px) rotate(1deg);
  }
}

@keyframes overlayOut {
  to {
    opacity: 0;
    transform: scale(1.04);
  }
}

@keyframes resultBurst {
  0% {
    opacity: 0;
    transform: scale(0.58) rotate(-4deg);
  }
  70% {
    transform: scale(1.06) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes defeatDrop {
  0% {
    opacity: 0;
    transform: translateY(-120px) rotate(5deg);
  }
  65% {
    transform: translateY(18px) rotate(-2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

@keyframes swaggerLift {
  0% {
    transform: translateY(-16px) rotate(-4deg) scale(1.05);
  }
  50% {
    transform: translateY(-24px) rotate(3deg) scale(1.08);
  }
  100% {
    transform: translateY(-18px) rotate(-2deg) scale(1.06);
  }
}


button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.45);
  opacity: 0.62;
}

.game-shell {
  width: min(1400px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 12px;
  position: relative;
  isolation: isolate;
}

.game-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(180deg, rgba(5, 7, 10, 0.48), rgba(5, 7, 10, 0.72)),
    var(--scene-bg-image, none) center / cover no-repeat;
  transform: scale(1.02);
  transition: opacity 360ms ease, background-image 360ms ease;
}

.game-shell.scene-background-active::before {
  opacity: 1;
}

.game-shell > * {
  position: relative;
  z-index: 1;
}

.topbar,
.player-panel,
.hand-panel,
.center-board {
  border: 1px solid var(--line);
  background: rgba(27, 33, 43, 0.82);
  backdrop-filter: blur(12px);
}

.game-shell.scene-background-active .topbar,
.game-shell.scene-background-active .player-panel,
.game-shell.scene-background-active .hand-panel,
.game-shell.scene-background-active .center-board {
  background: rgba(12, 16, 22, 0.76);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

.topbar {
  min-height: 84px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-radius: 8px;
}

.eyebrow,
.role {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
}

h2 {
  font-size: 16px;
}

.top-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.hero-target {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  background: var(--gold);
  color: #1b1204;
}

.ghost-button,
.hero-target {
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.hero-target.drop-target {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(230, 90, 90, 0.28), 0 0 26px rgba(230, 90, 90, 0.2);
  transform: translateY(-2px);
}

.sound-off {
  color: var(--muted);
}

.player-panel {
  min-height: 170px;
  padding: 12px;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 12px;
}

.opponent-panel {
  grid-template-columns: 150px 1fr;
}

.hero {
  min-height: 140px;
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02)),
    var(--panel-2);
}

.hero strong {
  display: block;
  font-size: 42px;
  line-height: 1;
}

.health-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.ping-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(123, 223, 255, 0.28);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.18);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0;
  white-space: nowrap;
}

.ping-badge.good {
  color: #8cffae;
  border-color: rgba(140, 255, 174, 0.34);
}

.ping-badge.medium {
  color: var(--gold);
  border-color: rgba(240, 191, 91, 0.38);
}

.ping-badge.bad {
  color: #ff8181;
  border-color: rgba(255, 129, 129, 0.42);
}

.enemy strong {
  color: #ff8181;
}

.player strong {
  color: #7bdfff;
}

.mana,
.evo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  min-width: 64px;
  height: 34px;
  border-radius: 999px;
  background: rgba(72, 164, 255, 0.18);
  border: 1px solid rgba(72, 164, 255, 0.35);
  color: #bfe0ff;
  font-weight: 900;
}

.evo {
  background: rgba(240, 191, 91, 0.18);
  border-color: rgba(240, 191, 91, 0.38);
  color: #ffe0a3;
}

.board-row,
.hand-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.board-row {
  min-height: 140px;
}

.center-board {
  min-height: 130px;
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr minmax(210px, 280px);
  overflow: hidden;
}

.log-panel {
  padding: 12px;
  border-right: 1px solid var(--line);
}

.system-status-panel {
  padding: 12px;
  border-left: 1px solid var(--line);
  display: grid;
  align-content: center;
  gap: 10px;
}

.system-status-group {
  display: grid;
  gap: 5px;
}

.system-status-label {
  color: var(--gold);
  font-size: 12px;
  font-weight: 1000;
}

.system-status-panel .trait-status {
  width: 100%;
  justify-content: flex-start;
  min-height: 28px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gal-status-group .trait-status {
  border-color: rgba(160, 116, 255, 0.34);
  background: rgba(160, 116, 255, 0.12);
}

.scene-status-group .trait-status {
  border-color: rgba(112, 199, 122, 0.34);
  background: rgba(112, 199, 122, 0.12);
}


.mulligan-panel {
  width: min(620px, 100%);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(240, 191, 91, 0.38);
  background: linear-gradient(135deg, rgba(240, 191, 91, 0.16), rgba(72, 164, 255, 0.11));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.mulligan-panel strong {
  color: #ffe0a3;
  font-size: 14px;
}

.mulligan-panel p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.mulligan-actions {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.mulligan-actions span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  border: 1px solid rgba(72, 164, 255, 0.34);
  background: rgba(72, 164, 255, 0.12);
  color: #bfe0ff;
  font-size: 12px;
  font-weight: 900;
}

.card.ready::after {
  content: "放回";
  position: absolute;
  inset: 8px auto auto 8px;
  z-index: 3;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(240, 191, 91, 0.94);
  color: #1c1608;
  font-size: 11px;
  font-weight: 1000;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
}

.battle-log {
  margin-top: 8px;
  display: grid;
  gap: 6px;
  max-height: 96px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
}

.target-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 12px;
}

.battle-emote-area {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.emote-button {
  min-width: 92px;
}

.emote-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 30;
  width: min(260px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(240, 191, 91, 0.34);
  border-radius: 8px;
  background: rgba(16, 20, 27, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.36);
  transform: translate(-50%, -50%);
}

.emote-panel button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}

.emote-panel button img {
  width: 42px;
  height: 32px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.emote-panel button:has(img) {
  min-height: 48px;
}

.emote-panel button:hover {
  border-color: rgba(240, 191, 91, 0.65);
  background: rgba(240, 191, 91, 0.16);
}

.emote-bubble {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  z-index: 11;
  min-width: 150px;
  max-width: min(260px, calc(100vw - 36px));
  display: grid;
  gap: 3px;
  justify-items: center;
  padding: 10px 14px;
  border: 1px solid rgba(240, 191, 91, 0.48);
  border-radius: 8px;
  background: rgba(28, 32, 40, 0.96);
  color: var(--text);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.38);
  transform: translateX(-50%);
  pointer-events: none;
}

.emote-bubble span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.emote-bubble-image {
  width: 92px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.emote-bubble strong {
  font-size: 22px;
  line-height: 1.1;
}

.emote-bubble.enemy-emote {
  border-color: rgba(72, 164, 255, 0.54);
}

.emote-bubble.show {
  animation: emote-bubble-pop 2.2s ease both;
}

.emote-frame {
  width: min(360px, 100%);
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.emote-frame-head,
.emote-lane {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.emote-frame-head span,
.emote-lane > span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.emote-frame-head small {
  color: var(--muted);
  font-weight: 800;
}

.emote-frame-grid {
  display: grid;
  gap: 5px;
}

.emote-history {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  overflow: hidden;
}

.emote-chip {
  min-width: 0;
  max-width: 74px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(240, 191, 91, 0.14);
  color: var(--text);
  font-size: 11px;
  font-weight: 900;
}

.emote-chip img {
  width: 34px;
  height: 26px;
  object-fit: cover;
  border-radius: 4px;
}

.emote-chip strong,
.emote-empty {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emote-empty {
  color: var(--muted);
  font-size: 12px;
}

.turn-counter {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(240, 191, 91, 0.14);
  border: 1px solid rgba(240, 191, 91, 0.3);
  color: #ffe0a3;
  font-size: 15px;
  font-weight: 900;
}

.trait-status {
  min-height: 30px;
  max-width: min(560px, 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(72, 164, 255, 0.12);
  border: 1px solid rgba(72, 164, 255, 0.3);
  color: #b9ddff;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.difficulty-status {
  color: #d7ecff;
}

#turnNotice {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.hand-panel {
  min-height: 220px;
  border-radius: 8px;
  padding: 12px;
}

.hand-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--muted);
}

.deck-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.deck-actions #deckCount {
  font-weight: 800;
}

.card {
  min-height: 224px;
  border-radius: 8px;
  border: 2px solid var(--line);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.13), transparent 38%),
    #222a35;
  display: grid;
  grid-template-rows: auto 96px auto auto auto 1fr auto;
  gap: 6px;
  padding: 9px;
  position: relative;
  overflow: hidden;
  transition: transform 140ms ease, border-color 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
}

.card[draggable="true"] {
  cursor: grab;
}

.card[draggable="true"]:active {
  cursor: grabbing;
}

.card:hover {
  transform: translateY(-4px);
}

.card.ready:hover {
  transform: translateY(-10px) rotate(-1deg) scale(1.02);
}

.card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(240, 191, 91, 0.34), 0 0 22px rgba(240, 191, 91, 0.18);
}

.card.ready {
  box-shadow: 0 0 0 2px rgba(112, 199, 122, 0.18), 0 0 18px rgba(112, 199, 122, 0.16);
}

.card.dragging {
  z-index: 4;
  opacity: 0.78;
  border-color: var(--gold);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.42), 0 0 0 2px rgba(240, 191, 91, 0.4);
  animation: swaggerLift 520ms ease-in-out infinite;
}

.card.drop-target {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(230, 90, 90, 0.28);
}

.card.sleeping {
  opacity: 0.68;
}

.card.unplayable {
  filter: saturate(0.6);
  opacity: 0.62;
}

.card.common {
  border-color: rgba(255, 255, 255, 0.18);
}

.card.rare {
  border-color: var(--blue);
}

.card.epic {
  border-color: var(--epic);
}

.card.legendary {
  border-color: var(--legend);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card-art {
  height: 96px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(circle at 50% 14%, rgba(255, 255, 255, 0.12), transparent 58%),
    rgba(7, 9, 13, 0.36);
}

.card-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center top;
}

.spell-art {
  display: grid;
  place-items: center;
  color: rgba(244, 239, 230, 0.74);
  font-size: 18px;
  font-weight: 900;
  background:
    radial-gradient(circle at 50% 40%, rgba(72, 164, 255, 0.32), transparent 58%),
    rgba(255, 255, 255, 0.06);
}

.cost {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-weight: 900;
}

.rarity {
  font-size: 11px;
  color: var(--muted);
}

.card-name {
  font-weight: 900;
  font-size: 15px;
  line-height: 1.15;
}

.card-type {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.keywords {
  min-height: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.keywords span {
  border-radius: 999px;
  padding: 2px 6px;
  background: rgba(240, 191, 91, 0.15);
  border: 1px solid rgba(240, 191, 91, 0.28);
  color: #ffe0a3;
  font-size: 11px;
  font-weight: 900;
}

.card-text {
  color: #d6dde7;
  font-size: 12px;
  line-height: 1.3;
}

.stats {
  display: flex;
  justify-content: space-between;
  padding-right: 32px;
  font-weight: 900;
}

.board-card {
  padding-bottom: 38px;
}

.board-card .stats {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 7px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  pointer-events: none;
}

.board-card .stats span {
  min-width: 44px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(6, 10, 16, 0.88);
  color: var(--text);
  font-size: 13px;
  font-weight: 1000;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32);
}

.atk {
  color: var(--red);
}

.hp {
  color: var(--green);
}

.evolve-button {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #1b1204;
  border: 2px solid rgba(255, 255, 255, 0.38);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.evolve-button:not(:disabled):hover {
  transform: scale(1.08);
}

.evolve-button:disabled {
  background: #596170;
  color: rgba(255, 255, 255, 0.6);
  border-color: rgba(255, 255, 255, 0.16);
}

.empty-slot {
  min-height: 210px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.28);
  font-size: 13px;
}

@media (max-width: 900px) {
  .home-panel,
  .guide-panel,
  .library-panel,
  .changelog-panel,
  .deck-builder-panel {
    padding: 16px;
  }

  .home-menu,
  .home-stats,
  .guide-grid,
  .skill-library,
  .online-grid,
  .deck-builder-toolbar {
    grid-template-columns: 1fr;
  }

  .intro-content .cover-menu,
  .intro-content .home-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-option {
    min-height: 84px;
  }

  .cover-menu .home-option {
    min-height: 64px;
  }

  .guide-flow {
    justify-content: flex-start;
  }

  .flow-step {
    flex-basis: calc(50% - 20px);
  }

  .flow-arrow {
    min-width: 18px;
    font-size: 20px;
  }

  .library-header {
    align-items: stretch;
    flex-direction: column;
  }

  .deck-builder-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .deck-builder-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .join-row,
  .room-share {
    align-items: stretch;
    flex-direction: column;
  }

  .deck-builder-section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .intro-overlay,
  .result-overlay {
    padding: 16px;
  }

  .intro-content {
    gap: 12px;
  }

  .intro-content h1 {
    font-size: clamp(42px, 15vw, 72px);
  }

  .intro-copy {
    font-size: 16px;
  }

  .intro-cast {
    grid-template-columns: repeat(4, minmax(52px, 1fr));
    gap: 8px;
  }

  .intro-actions,
  .result-actions {
    width: 100%;
  }

  .difficulty-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .difficulty-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .intro-actions button,
  .result-actions button {
    flex: 1 1 130px;
  }

  .intro-actions .primary-button {
    flex-basis: 100%;
    min-height: 56px;
    font-size: 22px;
  }

  .result-panel {
    padding: 22px;
  }

  .result-meme-video {
    max-height: 32vh;
  }

  .game-shell {
    padding: 8px;
  }

  .topbar,
  .center-board,
  .player-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .player-panel,
  .opponent-panel {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: 96px;
    flex-direction: row;
    align-items: center;
  }

  .center-board {
    display: block;
  }

  .system-status-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    grid-template-columns: 1fr;
  }

  .log-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .board-row,
  .hand-row {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .hand-header {
    align-items: stretch;
  }

  .deck-actions {
    align-items: end;
  }

  .deck-actions .primary-button {
    min-width: 120px;
  }

  .card {
    min-height: 230px;
  }

  .card-art {
    height: 96px;
  }
}

.reconnect-button {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.reconnect-spinner {
  width: 14px;
  height: 14px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: var(--gold);
  border-radius: 999px;
  display: none;
}

.reconnect-button.is-loading .reconnect-spinner {
  display: inline-block;
  animation: reconnect-spin 0.75s linear infinite;
}

@keyframes reconnect-spin {
  to {
    transform: rotate(360deg);
  }
}

.battle-feedback {
  position: fixed;
  inset: 0;
  z-index: 28;
  pointer-events: none;
  display: grid;
  place-items: center;
  padding: 24px;
}

.battle-feedback.hidden {
  display: none;
}

.battle-feedback-card {
  min-width: min(420px, calc(100vw - 48px));
  max-width: min(560px, calc(100vw - 48px));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 18px 22px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.2), transparent 55%),
    rgba(13, 18, 29, 0.92);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
}

.battle-feedback.show .battle-feedback-card {
  animation: battle-feedback-pop 1.5s ease both;
}

.battle-feedback-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  margin-bottom: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 1000;
}

.battle-feedback-card strong {
  display: block;
  color: var(--text);
  font-size: clamp(20px, 4vw, 34px);
  line-height: 1.18;
}

.battle-feedback-card.damage {
  border-color: rgba(255, 129, 129, 0.62);
  box-shadow: 0 24px 70px rgba(180, 35, 35, 0.35);
}

.battle-feedback-card.heal {
  border-color: rgba(120, 255, 169, 0.58);
  box-shadow: 0 24px 70px rgba(47, 190, 96, 0.3);
}

.battle-feedback-card.buff,
.battle-feedback-card.summon,
.battle-feedback-card.draw {
  border-color: rgba(240, 191, 91, 0.62);
  box-shadow: 0 24px 70px rgba(240, 191, 91, 0.24);
}

.deck-breakdown {
  width: min(560px, 100%);
  border: 1px solid rgba(240, 191, 91, 0.28);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  overflow: hidden;
}

.deck-breakdown summary {
  min-height: 34px;
  padding: 8px 12px;
  cursor: pointer;
  color: #ffe0a3;
  font-size: 13px;
  font-weight: 1000;
  list-style-position: inside;
}

.deck-breakdown-list {
  max-height: 180px;
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 0 10px 10px;
}

.deck-breakdown-item,
.deck-breakdown-empty {
  min-height: 30px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  font-weight: 900;
}

.deck-breakdown-empty {
  display: flex;
  justify-content: center;
  color: var(--muted);
}

.deck-card-count {
  color: var(--gold);
}

.deck-card-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-card-meta {
  color: var(--muted);
  white-space: nowrap;
}

.battle-feedback-card.start {
  border-color: rgba(240, 191, 91, 0.78);
  box-shadow: 0 24px 80px rgba(240, 191, 91, 0.34);
}

.game-shell.spell-flash-damage::after,
.game-shell.spell-flash-heal::after,
.game-shell.spell-flash-buff::after,
.game-shell.spell-flash-summon::after,
.game-shell.spell-flash-draw::after,
.game-shell.spell-flash-generic::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 24;
  pointer-events: none;
  opacity: 0;
  animation: spell-screen-flash 0.72s ease-out both;
}

.game-shell.spell-flash-damage::after {
  background: radial-gradient(circle, rgba(255, 88, 88, 0.32), transparent 58%);
}

.game-shell.spell-flash-heal::after {
  background: radial-gradient(circle, rgba(103, 255, 154, 0.28), transparent 58%);
}

.game-shell.spell-flash-buff::after,
.game-shell.spell-flash-summon::after,
.game-shell.spell-flash-draw::after {
  background: radial-gradient(circle, rgba(240, 191, 91, 0.3), transparent 58%);
}

.game-shell.spell-flash-generic::after {
  background: radial-gradient(circle, rgba(123, 223, 255, 0.22), transparent 58%);
}

.spell-hit-shake {
  animation: spell-hit-shake 0.46s ease both;
  box-shadow: 0 0 0 1px rgba(255, 129, 129, 0.42), 0 0 28px rgba(255, 74, 74, 0.24);
}

.spell-heal-glow {
  animation: spell-soft-pulse 0.72s ease both;
  box-shadow: 0 0 0 1px rgba(120, 255, 169, 0.4), 0 0 30px rgba(120, 255, 169, 0.26);
}

.spell-buff-glow,
.spell-cast-glow {
  animation: spell-soft-pulse 0.72s ease both;
  box-shadow: 0 0 0 1px rgba(240, 191, 91, 0.4), 0 0 30px rgba(240, 191, 91, 0.24);
}

.spell-shake-all {
  animation: spell-board-shake 0.38s ease both;
}

@keyframes battle-feedback-pop {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  16%, 76% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
}

@keyframes emote-bubble-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.96);
  }
  12%, 82% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.98);
  }
}

@keyframes spell-screen-flash {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes spell-hit-shake {
  0%, 100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-5px);
  }
  42% {
    transform: translateX(5px);
  }
  64% {
    transform: translateX(-3px);
  }
  82% {
    transform: translateX(2px);
  }
}

@keyframes spell-soft-pulse {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  42% {
    transform: scale(1.015);
    filter: brightness(1.18);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes spell-board-shake {
  0%, 100% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-3px, 2px);
  }
  40% {
    transform: translate(3px, -2px);
  }
  60% {
    transform: translate(-2px, -1px);
  }
  80% {
    transform: translate(2px, 1px);
  }
}


/* Compact battle layout for short laptop screens. */
@media (min-width: 901px) and (max-height: 980px) {
  html,
  body {
    height: 100%;
  }

  body {
    overflow: hidden;
  }

  .game-shell {
    width: min(1400px, 100%);
    height: 100dvh;
    min-height: 0;
    padding: 7px 10px;
    gap: 7px;
    grid-template-rows: auto minmax(92px, 0.68fr) minmax(88px, auto) minmax(92px, 0.68fr) minmax(176px, 1.25fr);
    overflow: hidden;
  }

  .topbar {
    min-height: 50px;
    padding: 7px 12px;
  }

  .topbar .eyebrow {
    display: none;
  }

  .topbar h1 {
    font-size: clamp(22px, 2.7vw, 30px);
  }

  .top-actions {
    gap: 8px;
  }

  .primary-button,
  .ghost-button,
  .hero-target {
    min-height: 32px;
    padding: 0 11px;
    font-size: 12px;
  }

  .player-panel {
    min-height: 0;
    padding: 6px;
    gap: 6px;
    grid-template-columns: 1fr minmax(92px, 116px);
  }

  .opponent-panel {
    grid-template-columns: minmax(92px, 116px) 1fr;
  }

  .hero {
    min-height: 0;
    padding: 10px;
  }

  .hero strong {
    font-size: 28px;
  }

  .ping-badge {
    min-height: 20px;
    padding: 2px 7px;
    font-size: 10px;
  }

  .mana,
  .evo {
    min-width: 48px;
    height: 24px;
    font-size: 12px;
  }

  .board-row,
  .hand-row {
    grid-template-columns: repeat(7, minmax(70px, 1fr));
    gap: 6px;
    min-height: 0;
  }

  .hand-row {
    align-items: start;
  }

  .center-board {
    min-height: 0;
    grid-template-columns: minmax(210px, 270px) 1fr minmax(190px, 240px);
  }

  .log-panel {
    padding: 7px 9px;
  }

  .battle-log {
    max-height: 54px;
    gap: 4px;
    font-size: 12px;
  }

  .target-zone {
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    align-items: center;
    justify-content: center;
    gap: 5px 7px;
    padding: 8px;
  }

  .system-status-panel {
    padding: 7px 8px;
    gap: 6px;
  }

  .system-status-group {
    gap: 3px;
  }

  .system-status-label {
    font-size: 10px;
  }

  .system-status-panel .trait-status {
    min-height: 22px;
  }

  .turn-counter,
  #turnNotice {
    flex-basis: 100%;
  }

  .turn-counter {
    min-height: 24px;
    font-size: 12px;
  }

  .trait-status {
    min-height: 22px;
    max-width: 100%;
    padding: 0 9px;
    font-size: 11px;
  }

  .mulligan-panel {
    width: min(560px, 72%);
    padding: 7px 9px;
    gap: 7px;
  }

  .mulligan-panel strong,
  .mulligan-panel p,
  .mulligan-actions span {
    font-size: 11px;
  }

  .deck-breakdown {
    width: min(520px, 68%);
  }

  .deck-breakdown summary {
    min-height: 24px;
    padding: 4px 9px;
    font-size: 12px;
  }

  .deck-breakdown-list {
    max-height: 96px;
  }

  #turnNotice {
    font-size: 13px;
    text-align: center;
  }

  .hand-panel {
    min-height: 0;
    padding: 7px;
    overflow: hidden;
  }

  .hand-header {
    align-items: center;
    margin-bottom: 5px;
  }

  .deck-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .card {
    min-height: 136px;
    grid-template-rows: auto 48px auto auto auto minmax(20px, 1fr) auto;
    gap: 4px;
    padding: 7px;
  }

  .card-art {
    height: 48px;
  }

  .cost {
    width: 24px;
    height: 24px;
    font-size: 13px;
  }

  .rarity,
  .card-type,
  .keywords span,
  .card-text {
    font-size: 10px;
  }

  .card-name {
    font-size: 12px;
  }

  .card-text {
    line-height: 1.18;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .keywords {
    min-height: 16px;
  }

  .evolve-button {
    right: 6px;
    bottom: 6px;
    width: 26px;
    height: 26px;
    font-size: 12px;
  }

  .stats {
    padding-right: 28px;
    font-size: 13px;
  }

  .empty-slot {
    min-height: 94px;
    font-size: 12px;
  }
}

@media (min-width: 901px) and (max-height: 760px) {
  .game-shell {
    padding: 6px 8px;
    gap: 6px;
    grid-template-rows: auto minmax(94px, 0.72fr) minmax(86px, auto) minmax(94px, 0.72fr) minmax(124px, 1fr);
  }

  .topbar {
    min-height: 48px;
    padding: 7px 12px;
  }

  .topbar .eyebrow {
    display: none;
  }

  .topbar h1 {
    font-size: clamp(22px, 2.6vw, 30px);
  }

  .player-panel {
    padding: 6px;
    grid-template-columns: 1fr minmax(90px, 112px);
  }

  .opponent-panel {
    grid-template-columns: minmax(90px, 112px) 1fr;
  }

  .hero {
    padding: 8px;
  }

  .hero strong {
    font-size: 28px;
  }

  .board-row,
  .hand-row {
    grid-template-columns: repeat(7, minmax(68px, 1fr));
    gap: 6px;
  }

  .center-board {
    grid-template-columns: minmax(180px, 230px) 1fr minmax(170px, 210px);
  }

  .battle-log {
    max-height: 52px;
    font-size: 11px;
  }

  .target-zone {
    gap: 4px 6px;
    padding: 6px;
  }

  .turn-counter,
  .trait-status,
  .deck-breakdown summary,
  #turnNotice {
    font-size: 11px;
  }

  .trait-status {
    min-height: 21px;
  }

  .mulligan-panel {
    width: min(480px, 70%);
    grid-template-columns: 1fr;
  }

  .mulligan-actions {
    grid-template-columns: auto auto;
    justify-content: center;
    justify-items: center;
  }

  .deck-breakdown {
    width: min(460px, 62%);
  }

  .deck-breakdown-list {
    max-height: 72px;
  }

  .hand-panel {
    padding: 6px;
  }

  .card {
    min-height: 0;
    grid-template-rows: auto 38px auto auto 0 0 auto;
    gap: 2px;
    padding: 4px;
  }

  .card-art {
    height: 38px;
  }

  .cost {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }

  .card-name,
  .stats {
    font-size: 11px;
  }

  .keywords,
  .card-text {
    display: none;
  }

  .card-type {
    font-size: 10px;
  }

  .empty-slot {
    min-height: 96px;
  }
}
