body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #293b5f 0, #101322 55%, #05060a 100%);
  color: #f5f6ff;
}

body.no-game .layout > :not(.fresh-launch) {
  display: none;
}

.fresh-launch {
  grid-column: 1 / -1;
  display: none;
  padding: 16px 18px 18px;
  text-align: center;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: radial-gradient(circle at top, rgba(39, 47, 74, 0.95), rgba(2, 6, 23, 0.95));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

body.no-game .fresh-launch {
  display: block;
}

body.viewport-blocked {
  overflow: hidden;
}

.viewport-blocker {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.95), rgba(4, 7, 15, 0.98));
  text-align: center;
  z-index: 2000;
}

.viewport-blocker.visible {
  display: flex;
}

.viewport-blocker-card {
  max-width: 520px;
  padding: 16px 18px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 12, 24, 0.9);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.7);
}

.viewport-blocker h2 {
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.viewport-blocker p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  color: rgba(229, 231, 235, 0.95);
}

.fresh-launch h2 {
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0.95;
  margin: 0 0 10px;
}

.fresh-launch-text {
  margin: 0 auto 16px;
  max-width: 560px;
  font-size: 1.05rem;
  line-height: 1.5;
  color: rgba(226, 232, 240, 0.95);
}

.fresh-launch-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.fresh-launch-cta {
  padding: 10px 16px;
  font-size: 1rem;
  border-radius: 10px;
  min-width: 160px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.45);
}

.fresh-launch-rules {
  padding: 10px 16px;
  font-size: 1rem;
  border-radius: 10px;
  min-width: 160px;
}

h1, h2, h3 {
  margin: 0;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(90deg, #1f2a44, #303a52, #4b3f72);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.title-block {
  display: flex;
  flex-direction: column;
}

.title-block h1 {
  font-size: 1.25rem;
  letter-spacing: 0.01em;
}

.subtitle {
  margin-top: 4px;
  font-size: 0.85rem;
  opacity: 0.85;
}

.status-summary {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-link {
  font-size: 0.85rem;
  color: #e5e7eb;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(248, 250, 252, 0.25);
  background: rgba(15, 23, 42, 0.35);
}

button.top-link {
  cursor: pointer;
}

.top-link-external::after {
  content: "↗";
  margin-left: 6px;
  font-size: 0.95em;
  opacity: 0.9;
}

.top-link:hover,
.top-link:focus-visible {
  background: rgba(148, 163, 184, 0.35);
  outline: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(200px, 0.65fr) minmax(260px, 1fr) minmax(0, 1.8fr);
  gap: 16px;
  padding: 12px 16px 20px;
  align-items: flex-start;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: minmax(260px, 1fr) minmax(0, 1.4fr);
    grid-template-rows: auto auto;
  }
  .turn-panel {
    grid-row: 1;
    grid-column: 1;
  }
  .board-panel {
    grid-row: 1;
    grid-column: 2;
  }
  .story-panel {
    grid-row: 2;
    grid-column: 1 / -1;
  }
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .story-panel {
    grid-column: auto;
  }
  .story-card-view {
    flex-direction: column;
  }
  .story-card-art-wrap {
    width: min(360px, 100%);
  }
}

section {
  background: rgba(7, 9, 18, 0.9);
  border-radius: 10px;
  padding: 10px 12px 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.board-panel h2,
.side-panel h2 {
  font-size: 1.05rem;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.turn-panel h2,
.story-panel h2 {
  font-size: 1.02rem;
  margin-bottom: 6px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 600;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.current-dragon-card {
  position: relative;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: radial-gradient(circle at top left, #232842, #141827);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.55);
}

.current-dragon-art {
  width: min(240px, 100%);
  height: auto;
  aspect-ratio: 751 / 1051;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.45);
  background: rgba(15, 23, 42, 0.35);
}

.roster-thumb {
  display: none;
}

.current-dragon-turn {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.95;
}

.current-dragon-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.current-dragon-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.current-dragon-color-badge {
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.current-dragon-color-badge.brown { background: #e1c7a0; color: #2b1600; }
.current-dragon-color-badge.red { background: #f07979; color: #3b0505; }
.current-dragon-color-badge.blue { background: #6ea8ff; color: #031b3c; }
.current-dragon-color-badge.white { background: #f9f9f9; color: #111827; }
.current-dragon-color-badge.black { background: #000000; color: #f5f5f5; }
.current-dragon-color-badge.green { background: #6fd78a; color: #042612; }

.current-dragon-ability-title {
  margin-top: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.current-dragon-ability-text {
  font-size: 0.78rem;
  opacity: 0.9;
}

.current-dragon-ability-btn {
  margin-top: auto;
  align-self: flex-start;
}

.location-card {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px;
  background: linear-gradient(145deg, #151a28, #1e2435);
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.45);
  transform: translateY(0);
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, border-color 0.12s ease-out;
}

.location-card.bracken {
  background: radial-gradient(circle at top, #283b63, #181d2b);
  border-color: #9db9ff;
}

.location-card.clickable {
  cursor: pointer;
}

.location-card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 255, 255, 0.2);
}

.location-card.active-location {
  border-color: rgba(226, 232, 240, 0.55);
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.25), 0 8px 18px rgba(0, 0, 0, 0.55);
}

.board-grid.move-mode .location-card,
.board-grid.teleport-mode .location-card {
  opacity: 0.55;
}

.board-grid.move-mode .location-card.move-target,
.board-grid.teleport-mode .location-card.teleport-target {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.28);
}

.location-card.move-target {
  box-shadow: 0 0 0 2px rgba(75, 230, 164, 0.35), 0 10px 18px rgba(0, 0, 0, 0.65);
  animation: targetPulse 900ms ease-in-out infinite;
}

.location-card.teleport-target {
  box-shadow: 0 0 0 2px rgba(157, 185, 255, 0.45), 0 10px 18px rgba(0, 0, 0, 0.65);
  animation: targetPulseTeleport 900ms ease-in-out infinite;
}

@keyframes targetPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(75, 230, 164, 0.25), 0 10px 18px rgba(0, 0, 0, 0.65); }
  50% { box-shadow: 0 0 0 4px rgba(75, 230, 164, 0.55), 0 16px 26px rgba(0, 0, 0, 0.7); }
}

@keyframes targetPulseTeleport {
  0%, 100% { box-shadow: 0 0 0 2px rgba(157, 185, 255, 0.25), 0 10px 18px rgba(0, 0, 0, 0.65); }
  50% { box-shadow: 0 0 0 4px rgba(157, 185, 255, 0.6), 0 16px 26px rgba(0, 0, 0, 0.7); }
}

.location-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px;
}

.location-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.location-status {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.location-status.open {
  color: #4be6a4;
}

.location-status.completed {
  color: #cbd2ff;
}

.location-status.locked {
  color: #ff6b7a;
}

.token-track {
  margin-top: 2px;
  font-size: 0.78rem;
}

.token-bar {
  display: flex;
  gap: 2px;
  margin-top: 2px;
}

.token-dot {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #3a4460;
}

.token-dot.filled {
  background: #4da3ff;
}

.token-dot.completed {
  background: #2dd48f;
}

.token-bar-flash {
  animation: tokenBarFlash 600ms ease-out 0s 2;
}

@keyframes tokenBarFlash {
  0% {
    box-shadow: 0 0 0 rgba(45, 212, 143, 0.0);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 18px rgba(45, 212, 143, 0.9);
    transform: scale(1.03);
  }
  100% {
    box-shadow: 0 0 0 rgba(45, 212, 143, 0.0);
    transform: scale(1);
  }
}

.piece-row {
  margin-top: 4px;
  font-size: 0.8rem;
}

.piece-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  margin: 1px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.25);
  min-height: 35px;
  width: 80px;
}

.piece-badge.dragon {
  font-weight: 600;
}

.piece-badge.friend {
  background: rgba(255, 244, 209, 0.95);
}

.piece-badge.brown { background: #e1c7a0; color: #1f2933; }
.piece-badge.red { background: #f07979; color: #111827; }
.piece-badge.blue { background: #6ea8ff; color: #0b1220; }
.piece-badge.white { background: #f9fafb; color: #111827; }
.piece-badge.black { background: #000000; color: #f9fafb; }
.piece-badge.green { background: #6fd78a; color: #052e16; }
.piece-badge.wizard {
  background: linear-gradient(90deg, #b7f0c1, #f6e7a3, #a3c8f6);
  color: #111827;
}

.piece-badge .short {
  margin-left: 4px;
  margin-right: 0;
}

.piece-badge .color {
  opacity: 0.85;
}

.piece-badge.dragon img {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.piece-badge.black img {
  filter: invert(1);
}

.quest-item-summary {
  margin-top: 4px;
  font-size: 0.76rem;
  color: #d3d8ff;
}

.quest-item-colors {
  display: inline-flex;
  gap: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

.quest-color-square {
  width: 18px;
  height: 18px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.quest-color-square.brown { background: #e1c7a0; }
.quest-color-square.red { background: #f4a0a0; }
.quest-color-square.blue { background: #a7c9ff; }
.quest-color-square.white { background: #f9f9f9; }
.quest-color-square.black { background: #000000; }
.quest-color-square.green { background: #a9e3a9; }

.quest-item-any {
  font-style: italic;
}

.quest-item-table {
  width: 100%;
  border-collapse: collapse;
}

.quest-item-table th,
.quest-item-table td {
  padding: 2px 4px;
  vertical-align: middle;
}

.quest-item-table thead th {
  font-weight: 600;
  font-size: 0.9rem;
}

.quest-item-table .quest-item-row-label {
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
}

.quest-item-table td.empty-cell {
  opacity: 0.4;
}

.quest-item-or {
  margin: 0 2px;
  font-size: 0.7rem;
  opacity: 0.9;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.turn-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.story-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-footer {
  grid-column: 1 / -1;
}

.story-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.roster-select {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  font-size: 0.85rem;
}

.roster-choice {
  position: relative;
}

.roster-checkbox {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.roster-choice-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: radial-gradient(circle at top, rgba(39, 47, 74, 0.9), rgba(21, 24, 34, 0.9));
  padding: 10px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.55);
  transition: transform 0.12s ease-out, border-color 0.12s ease-out, box-shadow 0.12s ease-out;
  user-select: none;
}

.roster-choice-label:hover {
  transform: translateY(-1px);
  border-color: rgba(157, 185, 255, 0.5);
}

.roster-checkbox:checked + .roster-choice-label {
  border-color: rgba(75, 230, 164, 0.6);
  background: radial-gradient(circle at top, rgba(45, 212, 143, 0.25), rgba(20, 83, 45, 0.25)), radial-gradient(circle at top, rgba(39, 47, 74, 0.9), rgba(21, 24, 34, 0.9));
  box-shadow: 0 0 0 2px rgba(75, 230, 164, 0.25), 0 12px 26px rgba(0, 0, 0, 0.65);
}

.roster-card-art {
  width: 100%;
  height: auto;
  aspect-ratio: 751 / 1051;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.35);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.55);
  display: block;
}

.roster-choice-caption {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-align: center;
  color: #f5f6ff;
}

.roster-check-ui {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 6px 14px rgba(0, 0, 0, 0.45);
  position: relative;
  flex: 0 0 auto;
}

.roster-checkbox:checked + .roster-choice-label .roster-check-ui {
  background: radial-gradient(circle at 35% 35%, #c7ffe8 0, #2dd48f 44%, #0a6b3c 100%);
  border-color: rgba(45, 212, 143, 0.7);
}

.roster-checkbox:checked + .roster-choice-label .roster-check-ui::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 3px;
  width: 6px;
  height: 10px;
  border-right: 3px solid rgba(255, 255, 255, 0.92);
  border-bottom: 3px solid rgba(255, 255, 255, 0.92);
  transform: rotate(40deg);
}

.current-roster {
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid #dde1f1;
  background: #fafbff;
  color: #1b213b;
  min-height: 1.7em;
}

.hint {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #9ca3c7;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

label {
  font-size: 0.85rem;
}

select {
  min-width: 120px;
  padding: 3px 6px;
  font-size: 0.85rem;
}

button {
  padding: 4px 8px;
  font-size: 0.85rem;
  border-radius: 4px;
  border: 1px solid #c3c7d9;
  background: #fff;
  cursor: pointer;
  color: #111827;
}

button.primary {
  background: #4c6fff;
  border-color: #3b58cc;
  color: #fff;
}

button.secondary {
  background: #f3f4fb;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.astrid-panel h2 {
  font-size: 1.02rem;
  margin-bottom: 6px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 600;
}

.astrid-track {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: fit-content;
}

.astrid-space {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), 0 2px 8px rgba(0, 0, 0, 0.55);
}

.astrid-space.filled {
  background: radial-gradient(circle at 35% 35%, #ffd1d1 0, #ff5b5b 36%, #9a1020 100%);
  box-shadow: 0 2px 10px rgba(255, 91, 91, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.game-status {
  margin-top: 4px;
  font-size: 0.85rem;
  min-height: 1.2em;
}

.game-status.win {
  color: #1b7f4a;
}

.game-status.loss {
  color: #b01c2e;
}

.log-panel .log {
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
  background: #050608;
  color: #e5e7eb;
  font-family: Menlo, Consolas, "Courier New", monospace;
  font-size: 0.78rem;
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.recent-card {
  padding: 6px;
  min-height: 40px;
  border-radius: 4px;
  border: 1px solid #d5d8e6;
  font-size: 0.85rem;
  background: #f9f9ff;
  color: #111827;
}

.story-card-display {
  margin-top: 10px;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: radial-gradient(circle at top left, #272f4a, #151822);
  min-height: 140px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6);
}

.story-card-only {
  display: flex;
  justify-content: center;
}

.story-card-art-only {
  width: min(360px, 100%);
}

.story-card-view {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.story-card-art-wrap {
  width: 220px;
  flex: 0 0 auto;
}

.story-card-art {
  width: 100%;
  height: auto;
  aspect-ratio: 751 / 1051;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.55);
  background: rgba(15, 23, 42, 0.35);
  display: block;
}

.story-card-details {
  min-width: 0;
  flex: 1 1 auto;
}

.story-card-type {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}

.story-card-meta {
  font-size: 0.8rem;
  color: #d3d8ff;
  margin-bottom: 4px;
}

.story-card-text {
  font-size: 0.85rem;
}

.story-card-placeholder {
  font-size: 0.85rem;
  color: #cfd3e5;
}

.story-card-pop {
  animation: storyCardPop 260ms ease-out;
}

@keyframes storyCardPop {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.friend-placement-prompt {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.location-art-wrap {
  margin-top: 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
  position: relative;
  background: rgba(15, 23, 42, 0.35);
  overflow: visible;
  margin-bottom: 22px;
}

.location-art-wrap.no-progress {
  margin-bottom: 0;
}

.location-art {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 751 / 1051;
  object-fit: contain;
  border-radius: 8px;
}

.quest-progress {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  transform: translateY(50%);
}

.quest-progress-dots {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}

.quest-progress-dot {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.quest-progress-dot.filled {
  background: radial-gradient(circle at 35% 35%, #bdf6ff 0, #4da3ff 40%, #1f5fa9 100%);
  box-shadow: 0 2px 8px rgba(77, 163, 255, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.quest-progress-label {
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #e5e7eb;
  flex: 0 0 auto;
}

.quest-progress-flash {
  animation: questProgressFlash 600ms ease-out 0s 2;
}

@keyframes questProgressFlash {
  0% { box-shadow: 0 0 0 rgba(45, 212, 143, 0.0); transform: scale(1); }
  50% { box-shadow: 0 0 18px rgba(45, 212, 143, 0.9); transform: scale(1.02); }
  100% { box-shadow: 0 0 0 rgba(45, 212, 143, 0.0); transform: scale(1); }
}

.friend-placement-title {
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.friend-placement-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.friend-placement-button {
  font-size: 0.78rem;
}

.story-choice-prompt {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.choice-note {
  margin-top: 4px;
  font-size: 0.78rem;
  opacity: 0.9;
}

.story-deck-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-right: 6px;
}

.story-deck-label,
.story-discard-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.story-deck-stack,
.story-discard-stack {
  position: relative;
  width: 72px;
  height: 96px;
}

.deck-card {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.6);
}

.deck-card.back {
  background: linear-gradient(135deg, #1b2133, #2e3a5c);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.deck-card.back-1 { top: 4px; left: 4px; }
.deck-card.back-2 { top: 2px; left: 2px; }
.deck-card.back-3 { top: 0; left: 0; }

.deck-card.empty {
  border: 1px dashed rgba(255, 255, 255, 0.3);
  background: transparent;
}

.story-deck-stack {
  cursor: pointer;
}

.story-deck-stack:hover .deck-card.back-3 {
  transform: translateY(-2px);
}

.deck-nudge {
  animation: deckNudge 180ms ease-out;
}

@keyframes deckNudge {
  0% { transform: translateY(0); }
  40% { transform: translateY(-2px); }
  100% { transform: translateY(0); }
}

.story-reveal {
  animation: storyReveal 260ms ease-out;
}

@keyframes storyReveal {
  0% { transform: translateY(6px) scale(0.99); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6); }
  60% { transform: translateY(0) scale(1.01); box-shadow: 0 0 0 2px rgba(157, 185, 255, 0.25), 0 12px 24px rgba(0, 0, 0, 0.7); }
  100% { transform: translateY(0) scale(1); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6); }
}

.discard-bounce {
  animation: discardBounce 220ms ease-out;
}

@keyframes discardBounce {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-2px) scale(1.03); }
  100% { transform: translateY(0) scale(1); }
}

.flying-card {
  position: fixed;
  z-index: 2000;
  pointer-events: none;
  border-radius: 8px;
}

.flying-card-back {
  background: linear-gradient(135deg, #1b2133, #2e3a5c);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.55);
}

.flying-card-discard {
  filter: saturate(0.95);
}

@media (prefers-reduced-motion: reduce) {
  .location-card.move-target,
  .location-card.teleport-target,
  .deck-nudge,
  .story-reveal,
  .discard-bounce,
  .story-card-pop {
    animation: none !important;
  }
}

.story-draw-button {
  margin-top: 6px;
  min-width: 130px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.visible {
  display: flex;
}

.modal-content {
  background: radial-gradient(circle at top, rgba(31, 41, 55, 0.95), rgba(2, 6, 23, 0.92));
  color: #f5f6ff;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 14px 14px 14px;
  width: min(520px, 92vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.modal-content h2 {
  font-size: 1rem;
  margin-bottom: 6px;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* Event overlay for automatic game events */

.event-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}

.event-overlay.visible {
  display: flex;
}

.event-overlay-inner {
  max-width: 480px;
  width: 90%;
  padding: 16px 18px;
  border-radius: 10px;
  background: radial-gradient(circle at top, #1f2937, #020617);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.event-overlay-body {
  font-size: 0.95rem;
  line-height: 1.5;
}

.event-card-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.event-card {
  width: min(260px, 100%);
  height: auto;
  aspect-ratio: 751 / 1051;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  background: rgba(15, 23, 42, 0.35);
}

.event-quest-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 6px 0 12px;
}

.event-quest-card {
  position: relative;
  width: 118px;
  flex: 0 0 auto;
}

.event-quest-image {
  width: 100%;
  height: auto;
  aspect-ratio: 751 / 1051;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55);
  background: rgba(15, 23, 42, 0.35);
  display: block;
}

.event-quest-delta {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e5e7eb;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-align: center;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.event-attack-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 6px 0 12px;
}

.event-attack-card {
  position: relative;
  width: 180px;
}

.event-attack-image {
  width: 100%;
  height: auto;
  aspect-ratio: 751 / 1051;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  background: rgba(15, 23, 42, 0.35);
  display: block;
}

.event-attack-delta {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffe4e6;
  font-weight: 750;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.event-attack-defenders {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.event-attack-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
}

.event-attack-line .k {
  opacity: 0.85;
}

.event-attack-line .v {
  text-align: right;
  font-weight: 650;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-attack-track {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: radial-gradient(circle at top, rgba(39, 47, 74, 0.85), rgba(2, 6, 23, 0.85));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffe4e6;
}

.event-overlay-body .event-line + .event-line {
  margin-top: 6px;
}

.event-overlay-hint {
  margin-top: 10px;
  font-size: 0.8rem;
  opacity: 0.8;
  text-align: right;
}

.board-hint {
  font-size: 0.8rem;
  color: #a5b4fc;
  margin-bottom: 8px;
}

/* Full-screen card zoom */

.card-zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 18px 12px;
}

.card-zoom-overlay.visible {
  display: flex;
}

.card-zoom-inner {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-height: 92vh;
  max-width: 96vw;
}

.card-zoom-image {
  height: 92vh;
  width: auto;
  max-width: min(70vw, 720px);
  object-fit: contain;
  aspect-ratio: 751 / 1051;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  background: rgba(15, 23, 42, 0.35);
  display: block;
}

.card-zoom-side {
  width: min(360px, 28vw);
  max-height: 92vh;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: radial-gradient(circle at top, rgba(31, 41, 55, 0.95), rgba(2, 6, 23, 0.92));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  padding: 12px 14px;
  display: none;
}

.card-zoom-overlay.has-side .card-zoom-side {
  display: block;
}

.card-zoom-side h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.card-zoom-side .hint {
  margin: 0 0 10px;
  font-size: 0.85rem;
  opacity: 0.9;
  color: #cbd5e1;
}

.card-zoom-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-zoom-actions button {
  min-width: 110px;
}

.card-zoom-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.card-zoom-checklist label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.card-zoom-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.card-zoom-close:hover,
.card-zoom-close:focus-visible {
  background: rgba(30, 41, 59, 0.9);
  outline: none;
}

/* Rules overlay (iframe) */

.rules-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1250;
  padding: 18px 12px;
}

.rules-overlay.visible {
  display: flex;
}

.rules-overlay-inner {
  position: relative;
  width: min(980px, 96vw);
  height: 92vh;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(15, 23, 42, 0.75);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.rules-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #0b1020;
}

.rules-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.rules-close:hover,
.rules-close:focus-visible {
  background: rgba(30, 41, 59, 0.9);
  outline: none;
}

@media (max-width: 900px) {
  .card-zoom-inner {
    flex-direction: column;
    align-items: center;
  }
  .card-zoom-image {
    max-width: 96vw;
    height: 80vh;
  }
  .card-zoom-side {
    width: min(560px, 96vw);
    max-height: 40vh;
  }
}

.story-deck-layout {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

@media (max-width: 700px) {
  .story-deck-layout {
    flex-direction: column;
  }
}

.rules-hint a {
  color: #a5b4fc;
}

/* Turn sequence stepper */

.turn-sequence-panel {
  margin-top: 10px;
}

.turn-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.turn-step {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.25);
  font-size: 0.8rem;
}

.turn-step .step-number {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(55, 65, 81, 0.9);
}

.turn-step .step-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.turn-step .step-title {
  font-weight: 600;
}

.turn-step .step-text {
  opacity: 0.9;
}

.turn-step .step-actions {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.turn-step.current {
  border-color: #4c6fff;
  box-shadow: 0 0 0 1px rgba(76, 111, 255, 0.5);
}

.turn-step.current .step-number {
  background: #4c6fff;
}

.turn-step.done {
  opacity: 0.7;
}

.turn-step.disabled {
  opacity: 0.45;
}

.turn-step-caption {
  margin-top: 6px;
  font-size: 0.78rem;
  color: #e5e7eb;
}
