/* ==========================================================================
   Astro-Pon (星际扭蛋号) — v2 Pure Stage & Pop-Art Card UI Stylesheet
   Bottom shortcut spin bar removed per user request; direct 3D machine click
   guided by sculpted 3D volumetric sign ("点击扭蛋") in the scene!
   ========================================================================== */

@font-face {
  font-family: 'AstroNotoSC';
  src: url('../fonts/NotoSansCJKsc-GameSubset.ttf') format('truetype');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --paper-cream: #F6EFD9;
  --paper-light: #FFFDF6;
  --pop-red: #E03131;
  --pop-yellow: #F2C14E;
  --pop-navy: #1E3A5F;
  --ink-dark: #2A2A2A;
  --ink-muted: #524D44;
  --teal-main: #2BB5A0;
  --teal-dark: #166E60;
  --coral-main: #F06A4D;
  --mint-bg: #B5E2CE;
  --font-main: 'AstroNotoSC', 'Noto Sans SC', 'Source Han Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --pixel-hand-cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 16 16'%3E%3Cpath fill='%231E3A5F' d='M5 1h2v5h2V5h2v1h2v2h1v5h-1v2H5v-2H3V9H2V7h2v1h1V1z'/%3E%3Cpath fill='%23F6EFD9' d='M6 2h1v6h2V6h1v2h2v1h1v4H6v-2H4V8h1v1h1V2z'/%3E%3C/svg%3E") 7 2, pointer;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--mint-bg);
  color: var(--ink-dark);
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button, select, input, textarea {
  font-family: inherit;
  font-size: 16px;
}

@media (hover: hover) and (pointer: fine) {
  button:not(:disabled),
  .interactive-cursor,
  #game-canvas.hovering-machine {
    cursor: var(--pixel-hand-cursor);
  }
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--pop-red);
  outline-offset: 2px;
}

#app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#viewport-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.halftone-surface {
  background-color: var(--paper-cream);
  background-image:
    radial-gradient(rgba(224, 49, 49, 0.11) 1.3px, transparent 1.4px),
    radial-gradient(rgba(30, 58, 95, 0.08) 1.2px, transparent 1.3px);
  background-size: 14px 14px, 18px 18px;
  background-position: 0 0, 7px 9px;
}

/* Top HUD Header Bar */
.top-hud {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  pointer-events: none;
}

.brand-plaque {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  background: var(--paper-cream);
  border: 3px solid var(--pop-navy);
  border-radius: 14px;
  box-shadow: 4px 4px 0 var(--pop-navy);
}

.pixel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--pop-red);
  color: var(--paper-cream);
  border: 2px solid var(--pop-navy);
  border-radius: 6px;
  font-weight: 700;
  font-size: 16px;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-title-main {
  font-weight: 800;
  font-size: 17px;
  color: var(--pop-navy);
  letter-spacing: 0.8px;
  line-height: 1.2;
}

.brand-status-pill {
  font-size: 14px;
  color: var(--ink-muted);
  font-weight: 600;
}

.hud-actions {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-dropdown-anchor {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cancel-inline-btn {
  background: #FFFDF6 !important;
  color: var(--pop-red) !important;
}

.theme-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(440px, 92vw);
  padding: 14px;
  border: 3px solid var(--pop-navy);
  border-radius: 16px;
  box-shadow: 6px 6px 0 var(--pop-navy);
  z-index: 35;
}

.theme-popover-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--pop-navy);
  margin-bottom: 10px;
}

.pop-btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 6px 13px;
  background: var(--paper-cream);
  color: var(--pop-navy);
  border: 2.5px solid var(--pop-navy);
  border-radius: 11px;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 3px 3px 0 var(--pop-navy);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

.pop-btn-sm:hover:not(:disabled) {
  background: #FFF9E6;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--pop-navy);
}

.pop-btn-sm:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--pop-navy);
}

.pop-btn-sm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--pop-red);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
}

.notice-banner {
  position: relative;
  z-index: 15;
  align-self: center;
  margin: 0 12px;
  padding: 6px 14px;
  background: var(--paper-cream);
  border: 2px solid var(--pop-navy);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  color: var(--pop-navy);
  box-shadow: 2px 2px 0 var(--pop-navy);
}

.hidden {
  display: none !important;
}

.theme-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--pop-navy);
  display: inline-block;
}

.theme-chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 2.5px solid var(--pop-navy);
  background: var(--paper-light);
  color: var(--ink-dark);
  font-size: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.theme-chip[aria-pressed="true"] {
  background: var(--pop-navy);
  color: var(--paper-cream);
  transform: translateY(-1px);
}

.theme-chip[aria-pressed="true"] .chip-dot {
  border-color: var(--paper-cream);
}

.theme-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.cancel-theme-btn {
  padding: 3px 10px;
  min-height: 32px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 8px;
  border: 2px solid var(--pop-navy);
  background: #FFFDF6;
  color: var(--pop-navy);
}

/* Loading Screen Overlay */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(181, 226, 206, 0.94);
  transition: opacity 0.3s ease;
}

.loading-box {
  width: min(440px, 100%);
  padding: 28px 24px;
  border: 3.5px solid var(--pop-navy);
  border-radius: 20px;
  box-shadow: 7px 7px 0 var(--pop-navy);
  text-align: center;
}

.loading-bar-track {
  width: 100%;
  height: 18px;
  margin: 16px 0 10px;
  border: 2.5px solid var(--pop-navy);
  border-radius: 999px;
  background: #FFFDF6;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 18%;
  background: repeating-linear-gradient(
    -45deg,
    var(--teal-main),
    var(--teal-main) 12px,
    var(--pop-yellow) 12px,
    var(--pop-yellow) 24px
  );
  transition: width 0.25s ease;
}

/* Affirmation Card Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(24, 44, 58, 0.56);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.card-stage-wrap {
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: cardStageRise 0.36s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes cardStageRise {
  from { opacity: 0; transform: translateY(24px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.reduced-motion .card-stage-wrap {
  animation: cardFadeOnly 0.2s ease;
}

@keyframes cardFadeOnly {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.card-3d-perspective {
  width: 100%;
  perspective: 1400px;
}

.affirmation-card-inner {
  position: relative;
  width: 100%;
  min-height: 430px;
  transform-style: preserve-3d;
  transition: transform 0.58s cubic-bezier(0.22, 0.85, 0.32, 1.08);
}

.reduced-motion .affirmation-card-inner {
  transition: none;
}

.affirmation-card-inner.is-flipped {
  transform: rotateY(180deg);
}

.reduced-motion .affirmation-card-inner.is-flipped .card-face-front {
  display: none;
}
.reduced-motion .affirmation-card-inner:not(.is-flipped) .card-face-back {
  display: none;
}
.reduced-motion .affirmation-card-inner.is-flipped {
  transform: none;
}

.card-face {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 430px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 3.5px solid var(--pop-navy);
  border-radius: 20px;
  box-shadow:
    0 2px 0 #E4DAC0,
    0 4px 0 var(--pop-navy),
    7px 9px 0 rgba(30, 58, 95, 0.88);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.reduced-motion .card-face {
  position: relative;
}

.card-face-back {
  transform: rotateY(180deg);
}

.reduced-motion .card-face-back {
  transform: none;
}

.card-reg-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--pop-navy);
  color: var(--paper-cream);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.card-reg-bar .reg-red {
  background: var(--pop-red);
  padding: 2px 8px;
  border-radius: 4px;
  color: #FFFFFF;
}

.card-front-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px 10px;
  gap: 16px;
}

.card-wax-seal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 2.5px solid var(--pop-navy);
  font-weight: 800;
  font-size: 16px;
  background: #FFFDF6;
  box-shadow: 2px 2px 0 var(--pop-navy);
}

.card-front-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.3;
  font-weight: 800;
  color: var(--ink-dark);
}

.card-decorative-motifs {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--pop-navy);
  font-size: 14px;
  font-weight: 700;
  opacity: 0.85;
}

.card-flip-hint {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--pop-navy);
  padding-top: 8px;
  border-top: 2px dashed rgba(30, 58, 95, 0.3);
}

.card-back-body-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 10px 2px;
  user-select: text;
}

.card-back-title-sm {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--pop-navy);
}

.card-back-body {
  margin: 0;
  font-size: 17px;
  line-height: 1.68;
  color: var(--ink-dark);
  font-weight: 500;
}

.card-action-box {
  background: var(--paper-light);
  border: 2.5px solid var(--pop-navy);
  border-left-width: 8px;
  border-radius: 12px;
  padding: 10px 14px;
}

.card-action-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--teal-dark);
  margin-bottom: 4px;
}

.card-action-text {
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-dark);
}

.card-disclaimer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-muted);
  padding-top: 8px;
  border-top: 2px dashed rgba(30, 58, 95, 0.25);
}

.card-toolbar {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.card-toolbar .pop-btn-sm {
  justify-content: center;
  min-height: 44px;
  font-size: 15px;
}

/* Drawers / Modals */
.drawer-panel {
  width: min(620px, 100%);
  max-height: 86vh;
  border: 3.5px solid var(--pop-navy);
  border-radius: 20px;
  box-shadow: 7px 7px 0 var(--pop-navy);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--pop-navy);
  color: var(--paper-cream);
}

.drawer-header h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

.drawer-close-btn {
  min-height: 36px;
  padding: 4px 12px;
  border-radius: 8px;
  border: 2px solid var(--paper-cream);
  background: var(--pop-red);
  color: #FFFFFF;
  font-weight: 800;
}

.drawer-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.privacy-note {
  padding: 10px 14px;
  background: #FFFDF6;
  border: 2px solid var(--pop-navy);
  border-radius: 12px;
  font-size: 15px;
  color: var(--ink-dark);
}

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

.collection-item {
  padding: 12px 14px;
  background: #FFFDF6;
  border: 2.5px solid var(--pop-navy);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.collection-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.collection-item-title {
  font-weight: 800;
  font-size: 17px;
  color: var(--pop-navy);
}

.collection-item-body {
  font-size: 16px;
  color: var(--ink-dark);
  margin: 0;
}

.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 8px;
}

.clip-btn {
  padding: 7px 10px;
  border-radius: 9px;
  border: 2px solid var(--pop-navy);
  background: #FFFDF6;
  color: var(--pop-navy);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.clip-btn:hover {
  background: var(--pop-yellow);
}

#toast-stack {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-msg {
  padding: 9px 18px;
  background: var(--pop-navy);
  color: var(--paper-cream);
  border: 2.5px solid var(--paper-cream);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

.copy-fallback-area {
  width: 100%;
  min-height: 130px;
  padding: 10px;
  border: 2.5px solid var(--pop-navy);
  border-radius: 10px;
  background: #FFFFFF;
  color: var(--ink-dark);
  font-size: 16px;
  user-select: text;
}

@media (max-width: 720px) {
  .top-hud {
    padding: 8px 10px;
    flex-wrap: wrap;
  }
  .brand-title-main {
    font-size: 16px;
  }
  .brand-status-pill {
    font-size: 12px;
  }
  .pop-btn-sm {
    padding: 5px 10px;
    font-size: 15px;
    min-height: 38px;
  }
  .theme-popover {
    left: 0;
    right: auto;
    width: min(360px, 92vw);
  }
  .card-face {
    min-height: 410px;
    padding: 14px 15px;
  }
  .card-front-title {
    font-size: 26px;
  }
  .card-toolbar {
    grid-template-columns: repeat(2, 1fr);
  }
}
