/* ============================================================
   ADVENTURE OF CLAIR — MAIN CSS
   Global styles, CSS variables, typography, utilities
   ============================================================ */

/* ── FONTS & ROOT VARIABLES ─────────────────────────────── */
:root {
  /* Colors */
  --color-bg:           #0A0E1A;
  --color-bg-2:         #0F1628;
  --color-bg-card:      #141B2E;
  --color-bg-elevated:  #1A2340;
  --color-border:       rgba(255, 215, 0, 0.12);
  --color-border-hover: rgba(255, 215, 0, 0.35);

  /* Gold palette */
  --gold-light:   #FFE566;
  --gold:         #FFD700;
  --gold-mid:     #C8A200;
  --gold-dark:    #8B6914;

  /* Accent */
  --accent-blue:    #4A90D9;
  --accent-purple:  #7C4DFF;
  --accent-teal:    #00CEC9;
  --accent-red:     #E74C3C;
  --accent-green:   #2ECC71;
  --accent-orange:  #E67E22;

  /* Text */
  --text-primary:   #F0E6C8;
  --text-secondary: rgba(240, 230, 200, 0.65);
  --text-muted:     rgba(240, 230, 200, 0.35);
  --text-inverse:   #0A0E1A;

  /* Fonts */
  --font-display: 'Cinzel', serif;
  --font-body:    'Nunito', sans-serif;

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;

  /* Border radius */
  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   20px;
  --radius-xl:   28px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 40px rgba(0,0,0,0.5);
  --shadow-gold: 0 0 20px rgba(255, 215, 0, 0.25);
  --shadow-glow: 0 0 40px rgba(255, 215, 0, 0.15);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow:   500ms ease;

  /* Z-index layers */
  --z-base:    1;
  --z-card:    10;
  --z-sticky:  100;
  --z-overlay: 500;
  --z-modal:   600;
  --z-toast:   900;
  --z-max:     9999;

  /* Layout */
  --nav-bottom-height: 72px;
  --nav-top-height:    64px;
  --sidebar-width:     260px;
  --max-content-width: 1200px;
}

/* ── RESET ──────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; outline: none; border: none; background: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ── APP CONTAINER ──────────────────────────────────────── */
#app {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

/* ── SCREENS ────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.screen.active  { opacity: 1; transform: translateX(0); pointer-events: all; z-index: var(--z-base); }
.screen.hidden  { opacity: 0; transform: translateX(20px); pointer-events: none; z-index: 0; }
.screen.slide-out { opacity: 0; transform: translateX(-20px); pointer-events: none; }

/* ── TYPOGRAPHY ─────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-display); color: var(--text-primary); line-height: 1.2; }
h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 700; }
h2 { font-size: clamp(1.2rem, 4vw, 1.8rem); font-weight: 600; }
h3 { font-size: clamp(1rem, 3vw, 1.3rem); font-weight: 600; }
p  { font-size: clamp(0.875rem, 2.5vw, 1rem); color: var(--text-secondary); line-height: 1.65; }
small { font-size: 0.75rem; }

.text-gold    { color: var(--gold); }
.text-muted   { color: var(--text-muted); }
.text-center  { text-align: center; }
.text-success { color: var(--accent-green); }
.text-danger  { color: var(--accent-red); }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-mid) 100%);
  color: var(--text-inverse);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-gold);
  transition: all var(--transition-fast);
  white-space: nowrap;
  letter-spacing: 0.03em;
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent);
  pointer-events: none;
}

.btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(255, 215, 0, 0.4); }
.btn-primary:active { transform: translateY(0); box-shadow: var(--shadow-gold); }

.btn-gold {
  background: linear-gradient(135deg, #FFE566 0%, #C8860A 100%);
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.35), 0 0 40px rgba(255, 215, 0, 0.1);
}

.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--color-border-hover);
  color: var(--text-primary);
  padding: 13px 28px;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  transition: all var(--transition-fast);
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }

.btn-full { width: 100%; }
.btn-large { padding: 18px 32px; font-size: 1.05rem; }

.btn-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}

.btn-back {
  position: absolute;
  top: var(--space-md);
  left: var(--space-md);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-bg-elevated);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  z-index: 10;
  transition: all var(--transition-fast);
}
.btn-back:hover { background: var(--color-border-hover); }

/* ── FORM ELEMENTS ──────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-group label i {
  color: var(--gold);
  font-size: 0.8rem;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="password"],
.form-select {
  width: 100%;
  padding: 14px 16px;
  background: var(--color-bg-elevated);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-body);
  transition: all var(--transition-fast);
}

input:focus,
.form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.12);
}

input::placeholder { color: var(--text-muted); }

.form-select option { background: var(--color-bg-2); color: var(--text-primary); }

.input-status {
  position: absolute;
  right: 14px;
  font-size: 0.85rem;
  font-weight: 600;
}
.input-status.ok  { color: var(--accent-green); }
.input-status.err { color: var(--accent-red); }

.form-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}
.card:hover { border-color: var(--color-border-hover); box-shadow: var(--shadow-md); }

/* ── BADGE ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge-gold   { background: rgba(255,215,0,0.15); color: var(--gold); }
.badge-blue   { background: rgba(74,144,217,0.15); color: var(--accent-blue); }
.badge-green  { background: rgba(46,204,113,0.15); color: var(--accent-green); }
.badge-red    { background: rgba(231,76,60,0.15); color: var(--accent-red); }

/* ── DIVIDER ────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-md) 0;
}

/* ── LOADING SCREEN ─────────────────────────────────────── */
#screen-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  z-index: var(--z-max);
}

.loader-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xl);
}

.loader-emblem {
  width: 100px;
  height: 100px;
  animation: emblem-pulse 2s ease-in-out infinite;
}

@keyframes emblem-pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(255,215,0,0.4)); }
  50%       { transform: scale(1.06); filter: drop-shadow(0 0 25px rgba(255,215,0,0.7)); }
}

.loader-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
}

.loader-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.loader-bar-wrap {
  width: 200px;
  height: 4px;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-sm);
}

.loader-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold), var(--gold-light));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
  animation: loader-shimmer 1.5s ease-in-out infinite;
}

@keyframes loader-shimmer {
  0%   { filter: brightness(1); }
  50%  { filter: brightness(1.3); }
  100% { filter: brightness(1); }
}

/* ── TOAST ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-bottom-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-bg-elevated);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  z-index: var(--z-toast);
  white-space: nowrap;
  transition: all var(--transition-normal);
  max-width: 90vw;
  text-align: center;
}
.toast.show    { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.hidden  { opacity: 0; pointer-events: none; }
.toast.success { border-color: var(--accent-green); color: var(--accent-green); }
.toast.error   { border-color: var(--accent-red);   color: var(--accent-red); }
.toast.gold    { border-color: var(--gold);          color: var(--gold); }

/* ── OVERLAY ────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  transition: opacity var(--transition-normal);
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay.show   { opacity: 1; }

/* ── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-border-hover); }

/* ── UTILITY CLASSES ────────────────────────────────────── */
.hidden   { display: none !important; }
.visible  { display: flex !important; }
.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center    { align-items: center; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.w-full { width: 100%; }
.mt-sm  { margin-top: var(--space-sm); }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mb-md  { margin-bottom: var(--space-md); }
.p-md   { padding: var(--space-md); }
.p-lg   { padding: var(--space-lg); }

/* ── RESPONSIVE BREAKPOINTS ─────────────────────────────── */
/* Mobile first. Desktop at 768px+ */
@media (min-width: 768px) {
  :root {
    --nav-bottom-height: 0px;
  }
}

@media (max-width: 360px) {
  html { font-size: 14px; }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .setup-wrap { padding-top: var(--space-sm); }
  .setup-step-content { overflow-y: auto; }
}
/* Coin star burst animation */
.coin-star-conf {
  position: fixed;
  pointer-events: none;
  animation: coin-star-burst 0.6s ease-out forwards;
}
@keyframes coin-star-burst {
  0%   { transform: scale(1) translate(0,0); opacity: 1; }
  100% { transform: scale(0) translate(var(--cx), var(--cy)); opacity: 0; }
}

/* Coin bonus float text */
.coin-bonus-float {
  position: fixed;
  font-size: 0.8rem;
  font-weight: bold;
  color: #f5c842;
  text-shadow: 0 0 4px #000;
  pointer-events: none;
  z-index: 10001;
  white-space: nowrap;
  animation: coin-bonus-rise 1.1s ease-out forwards;
}
@keyframes coin-bonus-rise {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-40px); }
}

/* Optional: coin float idle animation */
.world-coin {
  animation: coin-float 2s ease-in-out infinite;
}
@keyframes coin-float {
  0%,100% { transform: translateX(-50%) translateY(0); }
  50%     { transform: translateX(-50%) translateY(-6px); }
}
/* Battle Module Styles */
.battle-dashboard {
    position: relative;
    min-height: 400px;
    padding: var(--space-md);
    padding-bottom: 80px;
}

.battle-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 8px;
}

.battle-tab {
    background: none;
    border: none;
    padding: 8px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: 0.2s;
}

.battle-tab.active {
    color: var(--gold);
    background: rgba(255, 215, 0, 0.1);
    border-bottom: 2px solid var(--gold);
}

.battle-tab-content {
    margin-top: var(--space-md);
}

.battle-fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), #ffaa00);
    border: none;
    color: #1a1a2e;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.battle-fab-menu {
    position: fixed;
    bottom: 140px;
    right: 20px;
    background: var(--color-bg-elevated);
    border-radius: var(--radius-md);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 101;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.battle-fab-menu button {
    background: none;
    border: none;
    padding: 8px 16px;
    text-align: left;
    color: white;
    cursor: pointer;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.battle-fab-menu button:hover {
    background: rgba(255,215,0,0.2);
}

.battle-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.battle-card {
    background: var(--color-bg-elevated);
    border-radius: var(--radius-md);
    padding: 12px;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid var(--color-border);
}

.battle-card:hover {
    transform: translateY(-2px);
    background: rgba(255,215,0,0.05);
    border-color: var(--gold);
}

.battle-creator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.battle-avatar {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background: var(--gradient-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #1a1a2e;
    font-size: 18px;
}

.battle-creator-info {
    flex: 1;
}

.battle-creator-info strong {
    display: block;
    color: var(--gold);
}

.battle-creator-info span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.battle-details {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.battle-join-btn,
.battle-play-btn,
.battle-cancel-btn {
    background: var(--gold);
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    font-size: 0.8rem;
}

.battle-cancel-btn {
    background: rgba(231,76,60,0.8);
    color: white;
}

.battle-loading,
.battle-empty,
.battle-error {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
}

.battle-empty i,
.battle-error i {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
    display: block;
}