:root {
  /* Disable root view transition so only targeted group/tab elements animate */
  view-transition-name: none;
  --bg-deep: #0b1120;
  --bg-card: #151f32;
  --bg-card-elevated: #1e293b;
  --bg-glass: rgba(15, 23, 42, 0.88);
  --border-subtle: rgba(148, 163, 184, 0.16);
  --border-highlight: rgba(52, 211, 153, 0.45);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-emerald: #10b981;
  --accent-emerald-bright: #34d399;
  --accent-gold: #f59e0b;
  --accent-gold-bright: #fbbf24;
  --accent-crimson: #ef4444;
  --accent-crimson-bright: #f87171;
  --accent-indigo: #6366f1;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.45);
}

body[data-island="sakura"] {
  --bg-deep: #1a0f1f;
  --bg-card: #281730;
  --bg-card-elevated: #382042;
  --accent-emerald: #ec4899;
  --accent-emerald-bright: #f472b6;
  background: radial-gradient(circle at 50% 0%, #4a154b 0%, var(--bg-deep) 65%);
}

body[data-island="stardust"] {
  --bg-deep: #090d24;
  --bg-card: #131b3a;
  --bg-card-elevated: #1e2959;
  --accent-emerald: #6366f1;
  --accent-emerald-bright: #818cf8;
  background: radial-gradient(circle at 50% 0%, #312e81 0%, var(--bg-deep) 65%);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 50% 0%, #172554 0%, var(--bg-deep) 65%);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* Confetti Canvas */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 90;
}

/* Group Element Transitions & View Transitions (modern-web-guidance: group-element-transitions) */
::view-transition {
  pointer-events: none;
}

::view-transition-group(.quest-card-item) {
  animation-duration: 0.32s;
  animation-timing-function: ease-in-out;
}

::view-transition-new(.quest-card-item):only-child {
  animation-name: quest-slide-in;
  animation-duration: 0.32s;
}

::view-transition-old(.quest-card-item):only-child {
  animation-name: quest-slide-out;
  animation-duration: 0.28s;
}

@keyframes quest-slide-in {
  from {
    opacity: 0;
    translate: 0 18px;
  }
}

@keyframes quest-slide-out {
  to {
    opacity: 0;
    translate: -40px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

.app-shell {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}

/* Header */
.kingdom-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
}

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

.kingdom-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.rank-emblem {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #059669, var(--accent-emerald));
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  flex-shrink: 0;
}

.kingdom-meta {
  min-width: 0;
}

.kingdom-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.rank-tag {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: var(--accent-gold-bright);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

.kingdom-name {
  font-size: 0.88rem;
  font-weight: 800;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xp-bar-track {
  width: 112px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  margin-top: 4px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg, var(--accent-emerald-bright), #fbbf24);
  border-radius: 999px;
  transition: transform 0.35s ease-out, width 0.35s ease-out;
}

.header-resources {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.resource-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.74rem;
  font-weight: 700;
}

.streak-pill.is-lit {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(251, 191, 36, 0.65);
  color: #fde68a;
}

.combo-pill.is-hot {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.65);
  color: #fecaca;
}

.combo-timer {
  font-size: 0.64rem;
  color: var(--text-muted);
}

.gold-pill {
  color: var(--accent-gold-bright);
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-elevated);
  color: var(--text-main);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.88rem;
  padding: 0;
}

.icon-btn.is-playing {
  border-color: var(--accent-emerald-bright);
  background: rgba(16, 185, 129, 0.22);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.35);
}

/* Zeigarnik Banner */
.zeigarnik-banner {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.16), rgba(245, 158, 11, 0.14));
  border: 1px solid rgba(52, 211, 153, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.75rem;
}

.zeigarnik-text {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.sparkle-badge {
  background: rgba(245, 158, 11, 0.25);
  color: #fde68a;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 700;
  white-space: nowrap;
}

.territory-ratio {
  font-weight: 800;
  color: var(--accent-emerald-bright);
  white-space: nowrap;
}

/* 2-Minute Boost Arena */
.boost-arena {
  margin: 10px 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(6, 78, 59, 0.95), rgba(30, 41, 59, 0.96));
  border: 2px solid var(--accent-emerald-bright);
  box-shadow: 0 10px 28px rgba(16, 185, 129, 0.3);
}

.boost-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.boost-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #a7f3d0;
  font-size: 0.86rem;
}

.boost-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #34d399;
  animation: pulseDot 1.2s ease-in-out infinite;
  @media (prefers-reduced-motion: reduce) {
    animation: none;
  }
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.55; }
}

.boost-clock {
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--accent-gold-bright);
}

.boost-target-name {
  margin: 6px 0 2px;
  font-weight: 800;
  font-size: 1rem;
}

.boost-micro-hint {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: #cbd5e1;
}

.boost-progress-track {
  height: 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.boost-progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #fbbf24, #34d399);
  transform-origin: left center;
  transition: transform 0.3s linear;
}

.boost-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-conquer-now {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
}

.btn-retreat-honor {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

/* Main Content */
.main-viewport {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.map-card,
.panel-card,
.decrees-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.map-card-header,
.frontline-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.island-selector-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.island-select {
  background: var(--bg-card-elevated);
  color: var(--accent-gold-bright);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.section-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
}

.section-title:focus {
  outline: none;
}

.section-subtitle {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.map-legend {
  display: flex;
  gap: 7px;
  font-size: 0.68rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-claimed { background: var(--accent-emerald-bright); }
.dot-target { background: var(--accent-crimson-bright); }
.dot-chest { background: var(--accent-gold-bright); }

/* Guardian Companion Widget */
.guardian-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  margin-bottom: 12px;
}

.guardian-avatar-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.15);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.guardian-sprite {
  font-size: 1.7rem;
  transition: transform 0.25s ease;
}

.guardian-stage-pill {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--accent-gold);
  color: #0f172a;
  font-size: 0.58rem;
  font-weight: 900;
  padding: 0 5px;
  border-radius: 999px;
}

.guardian-info {
  flex: 1;
  min-width: 0;
}

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

.guardian-top-line strong {
  font-size: 0.78rem;
  color: var(--accent-gold-bright);
}

.guardian-bond-text {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--accent-emerald-bright);
}

.guardian-speech {
  margin: 2px 0 5px;
  font-size: 0.72rem;
  color: #e2e8f0;
}

.guardian-bar-track {
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.guardian-bar-fill {
  height: 100%;
  width: 60%;
  background: linear-gradient(90deg, #34d399, #fbbf24);
  transition: width 0.3s ease;
}

.btn-guardian-breath {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.74rem;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-guardian-breath:disabled {
  background: rgba(148, 163, 184, 0.15);
  color: #64748b;
  cursor: not-allowed;
}

/* 5x5 Territory Map Grid */
.territory-grid-wrapper {
  position: relative;
}

.territory-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  aspect-ratio: 1 / 0.94;
}

.map-tile {
  position: relative;
  border-radius: 12px;
  border: 1.5px solid rgba(148, 163, 184, 0.18);
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.18s ease, border-color 0.2s ease, background-color 0.2s ease;
  overflow: hidden;
  background: #1e293b;
  color: var(--text-main);
}

.map-tile:active {
  transform: scale(0.93);
}

.map-tile.tile-claimed {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.26), rgba(5, 150, 105, 0.42));
  border-color: rgba(52, 211, 153, 0.55);
}

.map-tile.tile-castle {
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.35), rgba(16, 185, 129, 0.45));
  border-color: var(--accent-gold-bright);
}

.map-tile.tile-target {
  background: linear-gradient(145deg, rgba(239, 68, 68, 0.28), rgba(127, 29, 29, 0.55));
  border-color: rgba(248, 113, 113, 0.85);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.28);
}

.map-tile.tile-chest {
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.28), rgba(120, 53, 15, 0.55));
  border-color: rgba(251, 191, 36, 0.85);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}

.map-tile.tile-fog {
  background: repeating-linear-gradient(
    -45deg,
    #0f172a,
    #0f172a 6px,
    #172033 6px,
    #172033 12px
  );
  border-color: rgba(148, 163, 184, 0.12);
  color: #64748b;
}

.map-tile.is-reach-tile {
  border-color: var(--accent-gold-bright);
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.35);
}

.tile-coord {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 0.56rem;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 700;
}

.tile-reach-badge {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.55rem;
  background: rgba(245, 158, 11, 0.9);
  color: #0f172a;
  font-weight: 900;
  padding: 0 4px;
  border-radius: 4px;
}

.tile-icon {
  font-size: 1.4rem;
  line-height: 1.1;
  margin-top: 4px;
}

.tile-label {
  font-size: 0.6rem;
  font-weight: 700;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.tile-hp-dots {
  display: flex;
  gap: 2px;
  margin-top: 2px;
  font-size: 0.55rem;
}

/* Daily Royal Decrees */
.decrees-card {
  margin-top: 12px;
  padding: 12px 14px;
}

.decrees-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.decrees-sub {
  font-size: 0.7rem;
  color: var(--accent-gold-bright);
  font-weight: 700;
}

.decrees-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.decree-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.76rem;
}

.decree-row.is-ready {
  border-color: var(--accent-gold-bright);
  background: rgba(245, 158, 11, 0.14);
}

.decree-row.is-claimed {
  opacity: 0.55;
}

.decree-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.btn-claim-decree {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #0f172a;
  border: none;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.decree-status-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Hit / Shake Animation */
.is-shaking {
  animation: tileShake 0.32s ease-in-out;
  @media (prefers-reduced-motion: reduce) {
    animation: none;
  }
}

@keyframes tileShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-5px, 2px) scale(0.95); }
  45% { transform: translate(5px, -2px) scale(1.04); }
  70% { transform: translate(-3px, 1px); }
}

/* FX Floating Layer */
.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating-fx {
  position: absolute;
  font-weight: 900;
  font-size: 0.92rem;
  color: #fde047;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  transform: translate(-50%, -50%);
  animation: floatUpFade 0.85s ease-out forwards;
  @media (prefers-reduced-motion: reduce) {
    animation-duration: 0.25s;
  }
}

@keyframes floatUpFade {
  0% { opacity: 1; transform: translate(-50%, -20%) scale(0.85); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(1.1); }
}

/* Frontline Controls, Mood Filter & Cards */
.frontline-section {
  margin-top: 12px;
}

.frontline-controls {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.mood-filter-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 6px;
}

.mood-chip {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.mood-chip.is-active {
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-emerald-bright);
  border-color: var(--accent-emerald-bright);
}

.chip-btn {
  background: var(--bg-card-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.frontline-cards,
.all-quests-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quest-card {
  view-transition-class: quest-card-item;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.quest-card.is-roulette-picked {
  border-color: var(--accent-gold-bright);
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.35), var(--shadow-soft);
}

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

.quest-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.coord-pill {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.45);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
}

.reward-building-pill {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
}

.chain-hint-pill {
  background: rgba(245, 158, 11, 0.22);
  color: #fde68a;
  border: 1px solid rgba(251, 191, 36, 0.45);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
}

.hp-badge {
  font-size: 0.78rem;
  letter-spacing: 1px;
}

.quest-title {
  margin: 0 0 4px;
  font-size: 0.98rem;
  font-weight: 800;
}

.quest-micro-box {
  background: rgba(15, 23, 42, 0.65);
  border-left: 3px solid var(--accent-gold);
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 0.76rem;
  color: #fde68a;
  margin-bottom: 10px;
}

.quest-actions {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 6px;
}

.btn-strike {
  background: linear-gradient(135deg, var(--accent-emerald-bright), #059669);
  color: #052e16;
  border: none;
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 900;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-finish {
  background: var(--bg-card-elevated);
  color: var(--text-main);
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
}

.btn-split {
  background: var(--bg-card-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

/* Quick Templates & Collection */
.quick-templates {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.template-btn {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 10px;
  color: var(--text-main);
  text-align: left;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.template-btn small {
  color: var(--accent-emerald-bright);
  font-size: 0.68rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.stat-box {
  background: var(--bg-card-elevated);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--accent-emerald-bright);
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.kingdom-upgrade-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.gacha-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(245, 158, 11, 0.18));
  border-color: var(--accent-emerald-bright);
}

.voyage-box {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(129, 140, 248, 0.35);
}

.btn-gold {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #0f172a;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 900;
  font-size: 0.78rem;
  white-space: nowrap;
  cursor: pointer;
}

.btn-secondary-sm {
  background: var(--bg-card-elevated);
  color: var(--text-main);
  border: 1px solid rgba(129, 140, 248, 0.5);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 0.76rem;
  white-space: nowrap;
  cursor: pointer;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.collection-item {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.collection-item.is-locked {
  opacity: 0.5;
}

.collection-icon {
  font-size: 1.6rem;
}

.collection-info strong {
  display: block;
  font-size: 0.8rem;
}

.collection-info small {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.78rem;
}

.history-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 10px;
  background: var(--bg-card-elevated);
  border-radius: 8px;
}

.danger-zone {
  margin-top: 14px;
  text-align: right;
}

/* Floating Action Button & Bottom Nav */
.fab-add {
  position: fixed;
  right: max(16px, calc((100vw - 540px) / 2 + 16px));
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  z-index: 25;
  background: linear-gradient(135deg, #34d399, #059669);
  color: #042f2e;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 900;
  font-size: 0.88rem;
  box-shadow: 0 8px 22px rgba(16, 185, 129, 0.45);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  max-width: 540px;
  margin: 0 auto;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
}

.nav-item {
  position: relative;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 4px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
}

.nav-item.is-active {
  color: var(--accent-emerald-bright);
  background: rgba(16, 185, 129, 0.12);
}

.nav-icon {
  font-size: 1.15rem;
}

.nav-badge {
  position: absolute;
  top: 3px;
  right: 24%;
  background: var(--accent-crimson);
  color: #fff;
  font-size: 0.62rem;
  padding: 0 5px;
  border-radius: 999px;
}

/* Dialogs & Popovers: Top-Layer Discrete Animations (modern-web-guidance) */
dialog,
[popover] {
  opacity: 0;
  transform: scale(0.92);
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.26s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog::backdrop,
[popover]::backdrop {
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(2px);
  transition-property: background-color, display, overlay;
  transition-duration: 0.26s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

[popover]:is(:popover-open, .\:popover-open) {
  display: flex;
}

:is(dialog[open], [popover]:is(:popover-open, .\:popover-open)):where(:not([data-closing])) {
  opacity: 1;
  transform: scale(1);

  @starting-style {
    opacity: 0;
    transform: scale(0.92);
  }

  &::backdrop {
    background-color: rgba(0, 0, 0, 0.62);

    @starting-style {
      background-color: rgba(0, 0, 0, 0);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog,
  [popover] {
    transform: none;
    transition-duration: 0.1s;
  }

  @starting-style {
    dialog[open],
    [popover]:is(:popover-open, .\:popover-open) {
      transform: none;
    }
  }
}

.game-dialog {
  width: min(92vw, 460px);
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid rgba(52, 211, 153, 0.4);
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.65);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.dialog-header h2 {
  margin: 0;
  font-size: 0.98rem;
}

.dialog-close-btn {
  background: var(--bg-card-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  cursor: pointer;
}

.dialog-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 70dvh;
  overflow-y: auto;
}

.dialog-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

input[type="text"] {
  width: 100%;
  background: #0f172a;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
}

.micro-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.preset-chip,
.chip-btn-xs {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

.radio-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.hp-radios {
  grid-template-columns: repeat(3, 1fr);
}

.radio-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-card-ui {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  background: #0f172a;
  border: 1.5px solid var(--border-subtle);
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.radio-card-ui small {
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 500;
}

.radio-card input:checked + .radio-card-ui {
  border-color: var(--accent-emerald-bright);
  background: rgba(16, 185, 129, 0.16);
}

.btn-primary,
.btn-primary-sm {
  background: linear-gradient(135deg, #34d399, #059669);
  color: #042f2e;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 900;
  font-size: 0.84rem;
  cursor: pointer;
}

.btn-primary-sm {
  padding: 7px 11px;
  font-size: 0.76rem;
}

.btn-secondary {
  background: var(--bg-card-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
}

/* Shikake Guide List */
.shikake-item {
  display: flex;
  gap: 10px;
  background: var(--bg-card-elevated);
  padding: 10px 12px;
  border-radius: 12px;
}

.shikake-num {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-gold-bright);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 6px;
  height: fit-content;
  white-space: nowrap;
}

.shikake-item h3 {
  margin: 0 0 4px;
  font-size: 0.85rem;
}

.shikake-item p {
  margin: 0;
  font-size: 0.75rem;
  color: #cbd5e1;
}

/* Toast Notifications (popover="manual") */
.toast-stack {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  pointer-events: none;
}

.toast-popover {
  position: fixed;
  inset: auto 14px 92px auto;
  margin: 0;
  margin-bottom: calc((sibling-index() - 1) * 54px);
  width: min(90vw, 340px);
  background: rgba(15, 23, 42, 0.96);
  color: var(--text-main);
  border: 1.5px solid var(--accent-emerald-bright);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.toast-popover + .toast-popover {
  margin-top: 0.6rem;
}

.toast-close {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  border: none;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 0.72rem;
  cursor: pointer;
}

/* Cloud Sync & Mobile App Badges & Dialogs */
.cloud-pill {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(30, 58, 138, 0.28);
  color: #93c5fd;
  cursor: pointer;
}

.cloud-pill.is-online {
  border-color: rgba(16, 185, 129, 0.6);
  background: rgba(6, 78, 59, 0.35);
  color: #6ee7b7;
}

.cloud-pill.is-error {
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(127, 29, 29, 0.35);
  color: #fca5a5;
}

.sync-status-box {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.8rem;
}

.sync-status-box .status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sync-auth-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ffffff;
  color: #1e293b;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-anonymous {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.config-toggle-btn {
  background: none;
  border: none;
  color: var(--accent-gold-bright);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 0;
  text-align: left;
}

.config-textarea {
  width: 100%;
  box-sizing: border-box;
  background: #090d16;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: #e2e8f0;
  font-family: monospace;
  font-size: 0.72rem;
  padding: 8px;
  resize: vertical;
  min-height: 90px;
}

/* App Install / APK Download Card */
.app-install-banner {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(16, 185, 129, 0.15));
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.install-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.install-option-card {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
}

.install-option-card h3 {
  margin: 0 0 4px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.install-option-card p {
  margin: 0 0 10px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

