/* ==========================================================================
   School Days Pen-Fight - Master Stylesheet (Updated with Pen-Warrior Animation)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Outfit:wght@300;400;600;800&family=Patrick+Hand&display=swap');

:root {
  /* Color Palette */
  --bg-dark: #0f141d;
  --bg-card: rgba(22, 30, 46, 0.88);
  --bg-card-hover: rgba(30, 42, 65, 0.95);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-glow: rgba(56, 189, 248, 0.25);

  --primary: #38bdf8;
  --primary-glow: #0284c7;
  --secondary: #fbbf24;
  --accent: #f43f5e;
  --success: #10b981;
  --warning: #f59e0b;
  --vip-gold: #f59e0b;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  /* Font Families */
  --font-display: 'Fredoka', cursive, sans-serif;
  --font-hand: 'Patrick Hand', cursive, sans-serif;
  --font-body: 'Outfit', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-body);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(251, 191, 36, 0.06) 0%, transparent 40%);
}

#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 1400px;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  background: var(--bg-dark);
}

@media (min-width: 1024px) {
  #app-container {
    height: 95vh;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
  }
}

/* Navigation Bar */
.top-bar {
  height: 60px;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 20, 29, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 20;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #38bdf8 0%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-title span.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.2);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.4);
  -webkit-text-fill-color: var(--primary);
  font-family: var(--font-body);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-icon {
  height: 40px;
  padding: 0 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  font-family: var(--font-display);
  gap: 0.4rem;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.btn-icon.active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(56, 189, 248, 0.15);
}

/* Finding Pen-Warrior Animation Elements */
.pen-warrior-spin-graphic {
  font-size: 3.5rem;
  animation: warriorSpin 2.5s infinite linear;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 15px rgba(251, 191, 36, 0.8));
}

@keyframes warriorSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}

.warrior-text-pulse {
  animation: warriorTextGlow 1.5s infinite alternate;
}

@keyframes warriorTextGlow {
  0% { text-shadow: 0 0 10px rgba(251, 191, 36, 0.5); }
  100% { text-shadow: 0 0 25px rgba(251, 191, 36, 1), 0 0 35px rgba(244, 63, 94, 0.8); }
}

/* Matchmaking Radar Animation */
.radar-pulse-ring {
  position: absolute;
  width: 140px;
  height: 140px;
  border: 2px dashed var(--secondary);
  border-radius: 50%;
  animation: radarPulse 2s infinite ease-out;
  pointer-events: none;
}

@keyframes radarPulse {
  0% { transform: scale(0.5); opacity: 1; border-color: var(--secondary); }
  100% { transform: scale(1.8); opacity: 0; border-color: var(--accent); }
}

/* Canvas Viewport */
.game-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #090d14;
}

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

/* 8-BALL POOL STYLE VERTICAL POWER CUE BAR */
.pool-power-bar-wrapper {
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  height: 260px;
  width: 24px;
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid var(--glass-border);
  border-radius: 14px;
  padding: 4px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.2);
  z-index: 18;
  pointer-events: auto;
}

.pool-power-fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(0deg, #10b981 0%, #fbbf24 60%, #f43f5e 100%);
  border-radius: 8px;
  transition: height 0.04s linear;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
}

.pool-power-ticks {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 0;
  pointer-events: none;
}

.pool-power-tick {
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

/* Player Badge Mic Buttons */
.btn-badge-mic {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-badge-mic.active {
  background: var(--success);
  border-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* Overlay Screens */
.screen-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 23, 0.88);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
  opacity: 1;
  transition: opacity 0.3s ease;
  padding: 1.5rem;
}

.screen-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.hero-modal {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 2rem;
  width: 92%;
  max-width: 600px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 40px var(--glass-glow);
  animation: floatIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 88vh;
  overflow-y: auto;
}

@keyframes floatIn {
  from { transform: scale(0.92) translateY(15px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.hero-title {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 0.4rem;
  color: #fff;
}

.hero-subtitle {
  font-family: var(--font-hand);
  font-size: 1.4rem;
  color: var(--secondary);
  margin-bottom: 1.25rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  width: 100%;
  margin: 1.25rem 0;
}

.mode-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1.1rem;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: left;
}

.mode-card:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--primary);
  transform: translateY(-4px);
}

.mode-card .icon {
  font-size: 1.8rem;
  margin-bottom: 0.4rem;
}

.mode-card h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: #fff;
  margin-bottom: 0.2rem;
}

.mode-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Action Buttons */
.btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
  color: #fff;
  border: none;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.8rem 2rem;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(2, 132, 199, 0.6);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  font-family: var(--font-display);
  font-size: 0.95rem;
  padding: 0.7rem 1.4rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-vip {
  background: linear-gradient(135deg, #d97706 0%, #fbbf24 100%);
  color: #000;
  border: none;
  font-family: var(--font-display);
  font-weight: 700;
  padding: 0.8rem 2rem;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
  animation: goldenPulse 2s infinite alternate;
}

@keyframes goldenPulse {
  from { box-shadow: 0 0 15px rgba(251, 191, 36, 0.4); }
  to { box-shadow: 0 0 30px rgba(251, 191, 36, 0.9); }
}

/* VIP HIGHLIGHTED GLOWING NAME TAG FRAME */
.player-badge {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--glass-border);
  padding: 0.6rem 1.2rem;
  border-radius: 14px;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  pointer-events: auto;
  transition: all 0.3s ease;
}

.player-badge.vip-frame {
  border: 2px solid #fbbf24 !important;
  background: rgba(30, 25, 10, 0.9) !important;
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.7), inset 0 0 12px rgba(251, 191, 36, 0.3) !important;
  animation: vipGlow 2s infinite alternate;
}

@keyframes vipGlow {
  0% { border-color: #fbbf24; box-shadow: 0 0 15px rgba(251, 191, 36, 0.6); }
  100% { border-color: #f59e0b; box-shadow: 0 0 28px rgba(245, 158, 11, 0.9); }
}

/* Voice Wave Indicator */
.voice-wave-container {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}

.voice-wave-bar {
  width: 3px;
  background: var(--success);
  border-radius: 2px;
  height: 4px;
  transition: height 0.1s ease;
}

/* In-Game HUD */
.hud-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  z-index: 15;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.turn-banner {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--glass-border);
  padding: 0.5rem 1.5rem;
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--secondary);
}

.power-meter-container {
  width: 180px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--glass-border);
  padding: 0.5rem;
  border-radius: 12px;
}

.power-meter-bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
}

.power-meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981 0%, #fbbf24 60%, #f43f5e 100%);
}

.avatar-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #000;
}

.score-pill {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--secondary);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.3rem 0.8rem;
  border-radius: 10px;
}

/* Chat Drawer Overlay */
.chat-drawer {
  position: absolute;
  bottom: 70px;
  right: 1.5rem;
  width: 300px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 0.75rem;
  backdrop-filter: blur(10px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: auto;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.chat-drawer.minimized {
  width: 140px;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
}

.chat-drawer.minimized .chat-messages-list,
.chat-drawer.minimized .chat-input-row {
  display: none !important;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
}

.btn-chat-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-main);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  cursor: pointer;
}

.chat-messages-list {
  height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.chat-input-row {
  display: flex;
  gap: 0.4rem;
}

.chat-input-row input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  color: #fff;
  font-family: var(--font-body);
}

/* Form Controls & General UI */
.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: #fff;
  font-family: var(--font-body);
}

/* Base Layout & Utilities */
.hidden {
    display: none !important;
}

/* Header & Profile Controls */
.nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    background: #1e1e24;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-icon.active {
    background: #e74c3c;
    color: #fff;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: #2b2b36;
    color: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-large {
    max-width: 720px;
}

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

.btn-close {
    background: none;
    border: none;
    color: #bbb;
    font-size: 1.6rem;
    cursor: pointer;
}

/* Locker Roster Grid */
.pen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 16px;
}

.pen-card {
    background: #1e1e24;
    border: 2px solid #3a3a48;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.pen-card.equipped {
    border-color: #2ecc71;
}

.pen-card-preview {
    width: 100%;
    height: 60px;
    border-radius: 6px;
}

/* Workshop */
.workshop-body {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.workshop-preview-pane {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #18181f;
    border-radius: 8px;
}

.workshop-controls-pane {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Toast Notification Stack */
.toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.toast {
    padding: 10px 18px;
    border-radius: 6px;
    background: #333;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: opacity 0.4s ease;
}

.toast-success { background: #27ae60; }
.toast-error { background: #c0392b; }
.toast-info { background: #2980b9; }

.toast.fade-out {
    opacity: 0;
}
