/* ==========================================================================
   ROSE QUARTZ & SERENITY • RETRO ARCADE THEME (Matching leaa.web.id)
   ========================================================================== */

:root {
  color-scheme: light;

  /* Light Palette (Rose Quartz & Serenity) */
  --primary-color: #41749e;
  --primary-hover: #345f82;
  --primary-soft: rgba(65, 116, 158, 0.15);
  --rose-quartz: #f4a8b8;
  --rose-quartz-soft: rgba(244, 168, 184, 0.25);
  --serenity: #8da4ce;
  --serenity-soft: rgba(141, 164, 206, 0.25);

  --background-pink: #ffe6ea;
  --background-blue: #e6f0ff;
  --bg-gradient: linear-gradient(135deg, #ffe6ea 0%, #f7cad0 30%, #e6f0ff 70%, #d8e6ff 100%);

  --card-bg: rgba(255, 255, 255, 0.94);
  --card-border: var(--primary-color);
  --card-shadow: 6px 6px 0 var(--primary-color);
  --card-hover-shadow: 8px 8px 0 var(--primary-color);

  --text-main: #000000;
  --text-desc: #333333;
  --text-muted: #555555;

  --title-color: var(--primary-color);
  --title-shadow: 3px 3px 0 rgba(255, 255, 255, 0.8), 5px 5px 0 rgba(244, 168, 184, 0.45);

  --btn-bg: var(--primary-color);
  --btn-hover: var(--primary-hover);
  --btn-text: #ffffff;
  --btn-border: #000000;
  --btn-shadow: 4px 4px 0 #000000;

  --btn-secondary-bg: #ffffff;
  --btn-secondary-text: var(--primary-color);
  --btn-secondary-border: var(--primary-color);
  --btn-secondary-shadow: 4px 4px 0 var(--primary-color);

  --vs-bg: #f4a8b8;
  --vs-text: #ffffff;
  --vs-border: #000000;

  --meter-bg: #e2e8f0;
  --meter-fill: linear-gradient(90deg, #f4a8b8 0%, var(--primary-color) 100%);

  --cloud-color: rgba(255, 255, 255, 0.7);
  --square-1: #fff9db;
  --square-2: #e6ffed;
  --square-3: #f3e6ff;
}

/* Dark Palette (Rose Quartz & Serenity) */
[data-theme="dark"] {
  color-scheme: dark;

  --primary-color: #8da4ce;
  --primary-hover: #7b94bf;
  --primary-soft: rgba(141, 164, 206, 0.18);
  --rose-quartz: #f4a8b8;
  --rose-quartz-soft: rgba(244, 168, 184, 0.25);
  --serenity: #8da4ce;
  --serenity-soft: rgba(141, 164, 206, 0.25);

  --background-pink: #1c1626;
  --background-blue: #0d0f17;
  --bg-gradient: radial-gradient(circle at 50% 0%, #1c1626 0%, #111422 45%, #0a0b12 100%);

  --card-bg: rgba(22, 26, 40, 0.92);
  --card-border: #8da4ce;
  --card-shadow: 6px 6px 0 #8da4ce;
  --card-hover-shadow: 8px 8px 0 #f4a8b8;

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

  --title-color: #f4a8b8;
  --title-shadow: 3px 3px 0 #111422, 5px 5px 0 #8da4ce;

  --btn-bg: #f4a8b8;
  --btn-hover: #e691a3;
  --btn-text: #1a1e2d;
  --btn-border: #8da4ce;
  --btn-shadow: 4px 4px 0 #8da4ce;

  --btn-secondary-bg: #1c2132;
  --btn-secondary-text: #f4a8b8;
  --btn-secondary-border: #8da4ce;
  --btn-secondary-shadow: 4px 4px 0 #8da4ce;

  --vs-bg: #8da4ce;
  --vs-text: #111422;
  --vs-border: #f4a8b8;

  --meter-bg: #1c2132;
  --meter-fill: linear-gradient(90deg, #8da4ce 0%, #f4a8b8 100%);

  --cloud-color: rgba(255, 255, 255, 0.04);
  --square-1: rgba(244, 168, 184, 0.08);
  --square-2: rgba(141, 164, 206, 0.08);
  --square-3: rgba(255, 255, 255, 0.05);
}

/* Base Reset & Fonts */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Chakra Petch', sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Floating Retro Decorations */
.decorations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cloud {
  position: absolute;
  background: var(--cloud-color);
  border-radius: 50px;
}

.cloud-1 {
  width: 180px;
  height: 48px;
  top: 8%;
  left: 5%;
  animation: floatCloud 25s infinite linear;
}

.cloud-2 {
  width: 220px;
  height: 56px;
  top: 35%;
  right: -5%;
  animation: floatCloudReverse 30s infinite linear;
}

.cloud-3 {
  width: 140px;
  height: 40px;
  bottom: 15%;
  left: 10%;
  animation: floatCloud 20s infinite linear;
}

.square {
  position: absolute;
  border: 2px dashed rgba(0, 0, 0, 0.1);
  transform: rotate(45deg);
  animation: spinSquare 20s infinite linear;
}

[data-theme="dark"] .square {
  border-color: rgba(255, 255, 255, 0.1);
}

.square-1 { width: 50px; height: 50px; top: 18%; right: 12%; background: var(--square-1); }
.square-2 { width: 40px; height: 40px; top: 58%; left: 8%; background: var(--square-2); }
.square-3 { width: 35px; height: 35px; bottom: 20%; right: 15%; background: var(--square-3); }

@keyframes floatCloud {
  0% { transform: translateX(0); }
  50% { transform: translateX(40px); }
  100% { transform: translateX(0); }
}

@keyframes floatCloudReverse {
  0% { transform: translateX(0); }
  50% { transform: translateX(-40px); }
  100% { transform: translateX(0); }
}

@keyframes spinSquare {
  0% { transform: rotate(45deg); }
  100% { transform: rotate(405deg); }
}

/* Header & Navigation */
.app-header {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1rem 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.back-link {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  color: var(--primary-color);
  text-decoration: none;
  background: var(--card-bg);
  padding: 0.35rem 0.6rem;
  border: 2px solid var(--card-border);
  box-shadow: 2px 2px 0 var(--card-border);
  display: inline-flex;
  align-items: center;
  transition: all 0.15s ease;
  letter-spacing: 0.5px;
}

.back-link:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--card-border);
  background: var(--rose-quartz-soft);
}

/* Absolute Theme Switcher */
.theme-switch-container {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 20;
}

.theme-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  border: 2px solid #000;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 2px 0 #000;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  border: 1px solid #000;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
}

input:checked + .slider {
  background-color: var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(22px);
  background-color: var(--rose-quartz);
}

.slider.round { border-radius: 26px; }
.slider.round:before { border-radius: 50%; }

/* Main Container */
.main-container {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
  flex: 1;
}

/* Screen Transitions */
.screen-view {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.screen-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero Box */
.hero-box, .result-hero-box {
  text-align: center;
  margin-bottom: 1rem;
}

.arcade-badge {
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  padding: 0.3rem 0.65rem;
  background: var(--rose-quartz);
  color: #1a1e2d;
  border: 2px solid #000;
  box-shadow: 2px 2px 0 #000;
  margin-bottom: 0.5rem;
  letter-spacing: 1px;
}

.main-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.25rem;
  line-height: 1.35;
  color: var(--title-color);
  text-shadow: var(--title-shadow);
  margin-bottom: 0.35rem;
  word-break: break-word;
}

.main-subtitle {
  font-size: 0.92rem;
  color: var(--text-desc);
  max-width: 560px;
  margin: 0 auto;
  font-weight: 500;
  line-height: 1.35;
}

/* Setup Compact Card (Clean & Focused ala SetlistJKT48 & Teras48) */
.setup-compact-card {
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  box-shadow: var(--card-shadow);
  padding: 1.1rem 1.25rem;
  max-width: 620px;
  margin: 0 auto 1.5rem auto;
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-group-compact {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.compact-label {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-color);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.compact-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--btn-secondary-bg);
  color: var(--text-main);
  border: 2px solid var(--card-border);
  box-shadow: 2px 2px 0 var(--card-border);
  outline: none;
  transition: all 0.15s ease;
}

.compact-input:focus {
  border-color: var(--rose-quartz);
  box-shadow: 3px 3px 0 var(--rose-quartz);
}

/* Status Tabs Grid (iOS / One UI Segmented Control Feel) */
.status-tabs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  background: var(--primary-soft);
  padding: 0.25rem;
  border: 2px solid var(--card-border);
  box-shadow: 2px 2px 0 var(--card-border);
}

.tab-btn {
  background: transparent;
  color: var(--text-main);
  border: 2px solid transparent;
  padding: 0.5rem 0.35rem;
  font-family: 'Chakra Petch', sans-serif;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  position: relative;
  transition: all 0.24s cubic-bezier(0.25, 1, 0.5, 1);
  user-select: none;
}

.tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.tab-btn:active {
  transform: scale(0.96);
}

.tab-btn.active {
  background: var(--primary-color);
  color: #ffffff;
  border: 2px solid #000000;
  box-shadow: 2px 2px 0 #000000;
  transform: scale(1.02);
}

[data-theme="dark"] .tab-btn.active {
  color: #111422;
  background: var(--rose-quartz);
  border-color: #ffffff;
  box-shadow: 2px 2px 0 #ffffff;
}

.tab-label-main {
  font-size: 0.88rem;
  font-weight: 700;
}

.tab-label-sub {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.85;
}

/* Team Filter Group with iOS Collapsible Slide & Fade */
#team-filter-group {
  overflow: hidden;
  transition: max-height 0.32s cubic-bezier(0.25, 1, 0.5, 1),
              opacity 0.25s cubic-bezier(0.25, 1, 0.5, 1),
              transform 0.28s cubic-bezier(0.25, 1, 0.5, 1),
              margin 0.28s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: max-height, opacity, transform;
}

#team-filter-group.collapsed {
  max-height: 0 !important;
  opacity: 0 !important;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

#team-filter-group.expanded {
  max-height: 180px !important;
  opacity: 1 !important;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Team Pills Grid */
.team-pills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 0.35rem;
}

.team-pill {
  background: var(--btn-secondary-bg);
  color: var(--text-main);
  border: 2px solid var(--card-border);
  box-shadow: 2px 2px 0 var(--card-border);
  padding: 0.42rem 0.35rem;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: all 0.12s ease;
}

.team-pill:hover {
  background: var(--serenity-soft);
}

.team-pill.active {
  background: var(--serenity);
  color: #ffffff;
  border-color: #000000;
  box-shadow: 2px 2px 0 #000000;
}

[data-theme="dark"] .team-pill.active {
  background: var(--serenity);
  color: #111422;
}

/* Select Dropdown ala Teras48 */
.select-wrapper {
  position: relative;
  width: 100%;
}

.compact-select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--btn-secondary-bg);
  color: var(--text-main);
  border: 2px solid var(--card-border);
  box-shadow: 2px 2px 0 var(--card-border);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2341749e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1.1rem;
  transition: all 0.15s ease;
}

[data-theme="dark"] .compact-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238da4ce' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.compact-select:focus {
  border-color: var(--rose-quartz);
  box-shadow: 3px 3px 0 var(--rose-quartz);
}

/* Setup Footer Bar */
.setup-footer-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  padding-top: 0.8rem;
  border-top: 2px solid var(--card-border);
}

.member-count-badge {
  display: flex;
  flex-direction: column;
}

.count-number {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.82rem;
  color: var(--primary-color);
}

.count-estimate {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-start-action {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.75rem;
  background: var(--rose-quartz);
  color: #000;
  border: 2px solid #000;
  box-shadow: 3px 3px 0 #000;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.15s ease;
}

.btn-start-action:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #000;
  background: #ffb8c7;
}

.btn-start-action:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #000;
}

.battle-filter-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* ==========================================
   SCREEN 2: BATTLE ARENA STYLING
   ========================================== */
.battle-header-card {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  box-shadow: var(--card-shadow);
  padding: 0.9rem 1.2rem;
  margin-bottom: 1.2rem;
}

.battle-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.battle-counter {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85rem;
  color: var(--primary-color);
}

.battle-progress-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85rem;
  color: var(--rose-quartz);
}

.progress-track {
  width: 100%;
  height: 14px;
  background: var(--meter-bg);
  border: 2px solid #000;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--meter-fill);
  transition: width 0.25s ease-out;
}

/* Versus Arena */
.versus-arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.member-battle-card {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  box-shadow: var(--card-shadow);
  padding: 1rem;
  cursor: pointer;
  text-align: center;
  transition: transform 0.22s cubic-bezier(0.25, 1, 0.5, 1),
              box-shadow 0.22s cubic-bezier(0.25, 1, 0.5, 1),
              border-color 0.22s cubic-bezier(0.25, 1, 0.5, 1),
              opacity 0.22s ease-out;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  user-select: none;
  will-change: transform, opacity;
}

.member-battle-card:hover, .member-battle-card:focus {
  transform: translateY(-4px);
  box-shadow: var(--card-hover-shadow);
  border-color: var(--rose-quartz);
}

.member-battle-card:active {
  transform: scale(0.97);
}

/* Card Transitions (iOS / One UI Butter Smooth Animations) */
@keyframes cardSlideEnter {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cardPickedPop {
  0% { transform: scale(1); }
  35% { transform: scale(0.94); border-color: var(--rose-quartz); }
  75% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.member-battle-card.anim-enter {
  animation: cardSlideEnter 0.28s cubic-bezier(0.25, 1, 0.5, 1) both;
}

.member-battle-card.anim-picked {
  animation: cardPickedPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  z-index: 2;
}

.member-battle-card.anim-fadeout {
  opacity: 0.35 !important;
  transform: scale(0.96) !important;
  transition: all 0.16s ease-out;
}

/* Counter & Value Pop Animations */
@keyframes counterPop {
  0% { transform: scale(0.88); opacity: 0.5; }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}

.anim-counter {
  animation: counterPop 0.24s cubic-bezier(0.25, 1, 0.5, 1) both;
}

@keyframes pulseValue {
  0% { transform: scale(0.92); opacity: 0.5; }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.anim-pulse {
  display: inline-block;
  animation: pulseValue 0.26s cubic-bezier(0.25, 1, 0.5, 1) both;
}

.card-photo-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 2px solid #000;
  background: #222;
  margin-bottom: 0.8rem;
}

.member-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  transition: transform 0.25s ease;
}

.member-battle-card:hover .member-photo {
  transform: scale(1.04);
}

.photo-overlay-indicator {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(65, 116, 158, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.member-battle-card:hover .photo-overlay-indicator {
  opacity: 1;
}

.pick-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85rem;
  color: #000;
  background: var(--rose-quartz);
  padding: 0.5rem 1rem;
  border: 2px solid #000;
  box-shadow: 3px 3px 0 #000;
}

.card-details {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
  gap: 0.4rem;
}

.member-gen-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  background: var(--rose-quartz-soft);
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  padding: 0.25rem 0.5rem;
  width: fit-content;
  margin: 0 auto;
}

.member-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.member-status-tag {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* VS Badge in Center */
.vs-center-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}

.vs-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.1rem;
  background: var(--vs-bg);
  color: var(--vs-text);
  border: 3px solid var(--vs-border);
  box-shadow: 3px 3px 0 var(--vs-border);
  padding: 0.8rem 0.7rem;
  border-radius: 50%;
  animation: pulseVS 2s infinite ease-in-out;
}

@keyframes pulseVS {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Action Buttons */
.battle-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.btn-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.9rem 0.6rem;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.72rem;
  cursor: pointer;
  border: 3px solid #000;
  box-shadow: 4px 4px 0 #000;
  transition: all 0.12s ease;
}

.btn-action:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 #000;
}

.btn-action:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #000;
}

.btn-pick {
  background: var(--primary-color);
  color: #ffffff;
}

[data-theme="dark"] .btn-pick {
  color: #111422;
}

.btn-tie {
  background: var(--btn-secondary-bg);
  color: var(--text-main);
  border-color: var(--primary-color);
  box-shadow: 4px 4px 0 var(--primary-color);
}

.btn-key-badge {
  font-size: 0.55rem;
  opacity: 0.85;
}

/* Battle Bottom Bar */
.battle-bottom-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.btn-secondary-arcade {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.68rem;
  background: var(--btn-secondary-bg);
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  box-shadow: 3px 3px 0 var(--primary-color);
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-secondary-arcade:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--primary-color);
  background: var(--primary-soft);
}

.btn-secondary-arcade:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-finish-early-arcade {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.68rem;
  background: var(--rose-quartz);
  color: #111422;
  border: 2px solid #000000;
  box-shadow: 3px 3px 0 #000000;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.25, 1, 0.5, 1);
}

.btn-finish-early-arcade:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #000000;
  background: #f4a8b8;
}

.btn-finish-early-arcade:active {
  transform: scale(0.96);
}
  box-shadow: none;
}

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

/* ==========================================
   SCREEN 3: RESULT & PODIUM STYLING
   ========================================== */
.podium-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.podium-card {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  box-shadow: var(--card-shadow);
  padding: 1.2rem;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.podium-rank-1 {
  border-color: #f59e0b;
  box-shadow: 6px 6px 0 #f59e0b;
  transform: scale(1.02);
}

.podium-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.72rem;
  padding: 0.35rem 0.8rem;
  border: 2px solid #000;
  box-shadow: 2px 2px 0 #000;
  margin-bottom: 0.8rem;
}

.badge-rank-1 { background: #fbbf24; color: #000; }
.badge-rank-2 { background: #cbd5e1; color: #000; }
.badge-rank-3 { background: #d97706; color: #fff; }

.podium-photo-frame {
  width: 140px;
  height: 180px;
  border: 2px solid #000;
  overflow: hidden;
  margin-bottom: 0.8rem;
  background: #222;
}

.podium-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.podium-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.3rem;
}

.podium-gen {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary-color);
}

/* Result Action Buttons */
.result-actions-card {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.btn-result-action {
  flex: 1 1 200px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.75rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
  border: 2px solid #000;
  box-shadow: 3px 3px 0 #000;
  text-align: center;
  transition: all 0.12s ease;
}

.btn-primary-arcade {
  background: var(--rose-quartz);
  color: #000;
}

.btn-primary-arcade:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 #000;
}

/* Full Ranking List */
.full-ranking-card {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.ranking-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 2px solid var(--card-border);
}

.ranking-header-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.82rem;
  color: var(--primary-color);
}

.ranking-header-count {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.ranking-item-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0.8rem;
  background: var(--btn-secondary-bg);
  border: 2px solid var(--card-border);
  box-shadow: 2px 2px 0 var(--card-border);
}

.rank-number-box {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85rem;
  min-width: 44px;
  color: var(--primary-color);
}

.rank-thumb-img {
  width: 44px;
  height: 56px;
  object-fit: cover;
  border: 1px solid #000;
}

.rank-member-info {
  flex: 1;
}

.rank-member-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.rank-member-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 1.1rem 1rem;
  text-align: center;
  border-top: 2px solid var(--card-border);
  background: var(--card-bg);
  position: relative;
  z-index: 5;
}

.footer-brand {
  font-size: 0.95rem;
  color: var(--primary-color);
  margin-bottom: 0.4rem;
}

.footer-disclaimer {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #111422;
  color: #fff;
  border: 2px solid var(--rose-quartz);
  box-shadow: 4px 4px 0 var(--rose-quartz);
  padding: 0.8rem 1.4rem;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.72rem;
  z-index: 100;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Responsive Styles */
@media (max-width: 680px) {
  .hero-box {
    margin-bottom: 0.75rem;
  }
  .arcade-badge {
    font-size: 0.5rem;
    padding: 0.22rem 0.5rem;
    margin-bottom: 0.35rem;
  }
  .main-title {
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
  }
  .main-subtitle {
    font-size: 0.82rem;
    line-height: 1.3;
  }
  .setup-compact-card {
    padding: 0.85rem 0.9rem;
    gap: 0.7rem;
    border-width: 2px;
  }
  .compact-label {
    font-size: 0.78rem;
  }
  .compact-input {
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
  }
  .status-tabs-grid {
    gap: 0.25rem;
    padding: 0.2rem;
  }
  .tab-btn {
    padding: 0.45rem 0.2rem;
  }
  .tab-label-main {
    font-size: 0.82rem;
  }
  .tab-label-sub {
    font-size: 0.62rem;
  }
  .team-pills-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.3rem;
  }
  .team-pill {
    padding: 0.38rem 0.25rem;
    font-size: 0.76rem;
  }
  .compact-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
  .setup-footer-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    text-align: center;
  }
  .member-count-badge {
    align-items: center;
  }
  .btn-start-action {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.72rem;
    text-align: center;
  }
  .versus-arena {
    grid-template-columns: 1fr auto 1fr;
    align-items: stretch;
    gap: 0.4rem;
  }
  .member-battle-card {
    padding: 0.5rem;
    height: 100%;
  }
  .member-name {
    font-size: 0.88rem;
    line-height: 1.25;
    min-height: 2.6em;
    margin-top: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .member-gen-badge {
    font-size: 0.55rem;
    padding: 0.15rem 0.35rem;
  }
  .member-status-tag {
    font-size: 0.7rem;
  }
  .vs-badge {
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
  }
  .battle-actions-grid {
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 0.4rem;
  }
  .btn-action {
    padding: 0.7rem 0.3rem;
    font-size: 0.6rem;
  }
  .btn-key-badge {
    display: none;
  }
  .card-photo-wrapper {
    max-height: 240px;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 4;
  }
}

/* PC / Desktop Responsive Optimizations: Full Viewport Battle Screen without scrolling */
@media (min-width: 681px) {
  #screen-battle {
    max-width: 720px;
    margin: 0 auto;
  }

  .battle-header-card {
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
  }

  .versus-arena {
    max-width: 620px;
    margin: 0 auto 0.75rem auto;
    gap: 0.75rem;
    align-items: stretch;
  }

  .member-battle-card {
    padding: 0.75rem 0.75rem 0.6rem;
    max-width: 280px;
    width: 100%;
    margin: 0 auto;
  }

  .card-photo-wrapper {
    align-self: center;
    width: auto;
    max-width: 100%;
    aspect-ratio: 3 / 4;
    height: clamp(160px, 32vh, 270px);
    margin: 0 auto 0.5rem auto;
  }

  .member-name {
    font-size: 1.05rem;
    line-height: 1.25;
    min-height: 2.3em;
    margin: 0.2rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .member-gen-badge {
    font-size: 0.6rem;
    padding: 0.18rem 0.42rem;
  }

  .member-status-tag {
    font-size: 0.75rem;
  }

  .vs-badge {
    padding: 0.6rem 0.65rem;
    font-size: 0.95rem;
  }

  .battle-actions-grid {
    max-width: 620px;
    margin: 0 auto 0.6rem auto;
    gap: 0.6rem;
  }

  .btn-action {
    padding: 0.75rem 0.5rem;
    font-size: 0.68rem;
  }

  .battle-bottom-bar {
    max-width: 620px;
    margin: 0 auto 0.5rem auto;
    gap: 0.6rem;
  }

  .btn-secondary-arcade,
  .btn-finish-early-arcade {
    padding: 0.5rem 0.8rem;
    font-size: 0.65rem;
  }

  .keyboard-tips {
    font-size: 0.75rem;
    margin-top: 0.3rem;
  }
}

/* Compact adjustments for short desktop screens / laptops (height <= 760px) */
@media (min-width: 681px) and (max-height: 760px) {
  .app-header {
    padding: 0.75rem 1rem 0.3rem;
  }

  .main-container {
    padding: 0.4rem 1rem 0.8rem;
  }

  .battle-header-card {
    padding: 0.5rem 0.8rem;
    margin-bottom: 0.5rem;
  }

  .versus-arena {
    margin-bottom: 0.5rem;
    gap: 0.6rem;
  }

  .member-battle-card {
    padding: 0.55rem;
  }

  .card-photo-wrapper {
    height: clamp(140px, 27vh, 210px);
    margin-bottom: 0.35rem;
  }

  .member-name {
    font-size: 0.95rem;
    min-height: 2em;
    margin: 0.15rem 0;
  }

  .vs-badge {
    padding: 0.45rem 0.5rem;
    font-size: 0.85rem;
  }

  .battle-actions-grid {
    margin-bottom: 0.45rem;
    gap: 0.5rem;
  }

  .btn-action {
    padding: 0.6rem 0.4rem;
    font-size: 0.62rem;
  }

  .battle-bottom-bar {
    margin-bottom: 0.35rem;
    gap: 0.5rem;
  }

  .btn-secondary-arcade,
  .btn-finish-early-arcade {
    padding: 0.42rem 0.65rem;
    font-size: 0.6rem;
  }

  .keyboard-tips {
    font-size: 0.7rem;
    margin-top: 0.2rem;
  }
}

/* Custom Aesthetic Retro Modal Dialog */
.custom-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 25, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s cubic-bezier(0.25, 1, 0.5, 1),
              visibility 0.22s cubic-bezier(0.25, 1, 0.5, 1);
}

.custom-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.custom-modal-card {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  box-shadow: 6px 6px 0 var(--card-border);
  padding: 1.6rem 1.4rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  transform: scale(0.92) translateY(14px);
  transition: transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-sizing: border-box;
}

.custom-modal-overlay.active .custom-modal-card {
  transform: scale(1) translateY(0);
}

.modal-badge-container {
  margin-bottom: 0.8rem;
}

.modal-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.62rem;
  background: var(--serenity);
  color: #0b1120;
  padding: 0.35rem 0.7rem;
  border: 2px solid var(--card-border);
  box-shadow: 2px 2px 0 var(--card-border);
  display: inline-block;
  letter-spacing: 0.5px;
}

.modal-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.92rem;
  color: var(--text-main);
  margin-bottom: 0.8rem;
  line-height: 1.4;
}

.modal-message {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 1.5rem;
}

.modal-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.modal-btn {
  width: 100%;
  padding: 0.75rem 0.5rem;
  font-size: 0.7rem;
  text-align: center;
  box-sizing: border-box;
}
