@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Outfit:wght@400;600;800;900&display=swap');

:root {
  --neon-yellow: #ffe600;
  --pop-pink: #ff007f;
  --pop-blue: #00e5ff;
  --pop-orange: #ff5e00;
  --pop-purple: #8b00ff;
  --pop-green: #00ffaa;
  
  --dark-black: #121212;
  --light-white: #ffffff;
  --screen-bg: #ffd000;
  
  --font-heading: 'Bangers', cursive;
  --font-body: 'Outfit', sans-serif;
  
  --border-thick: 4px solid #121212;
  --border-medium: 3px solid #121212;
  --border-thin: 2px solid #121212;
  
  --console-shadow: 12px 12px 0px #121212;
  --neo-shadow: 6px 6px 0px #121212;
  --neo-shadow-small: 3px 3px 0px #121212;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: #ff5e00;
  background-image: radial-gradient(rgba(0, 0, 0, 0.15) 15%, transparent 16%),
                    radial-gradient(rgba(0, 0, 0, 0.15) 15%, transparent 16%);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  color: var(--dark-black);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

/* --- H5 Retro Console Mockup --- */
.h5-console {
  background: #f1ede4;
  border: var(--border-thick);
  box-shadow: var(--console-shadow);
  width: 100%;
  max-width: 420px;
  height: 92vh;
  max-height: 770px;
  border-radius: 32px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Console Header details */
.console-top-bar {
  background: #2a2a2a;
  color: var(--light-white);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: var(--border-thick);
  height: 45px;
}

.speaker-grill {
  width: 40px;
  height: 6px;
  background: repeating-linear-gradient(90deg, #666 0px, #666 2px, transparent 2px, transparent 4px);
  border-radius: 3px;
}

.console-logo {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  letter-spacing: 1.5px;
  color: var(--neon-yellow);
  text-shadow: 2px 2px 0px #000;
}

.battery-indicator {
  font-size: 0.7rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 4px;
  color: #aaa;
}

.battery-dot {
  width: 8px;
  height: 8px;
  background: #00ff00;
  border-radius: 50%;
  box-shadow: 0 0 6px #00ff00;
  display: inline-block;
  animation: blinkBattery 1s infinite alternate;
}

/* Console Screen Area */
.console-screen {
  flex-grow: 1;
  background: var(--screen-bg);
  background-image: radial-gradient(rgba(0, 0, 0, 0.05) 15%, transparent 16%),
                    radial-gradient(rgba(0, 0, 0, 0.05) 15%, transparent 16%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  padding: 12px;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Tab Screens Switching */
.screen-tab {
  display: none;
  flex-direction: column;
  height: 100%;
  flex-grow: 1;
}

.screen-tab.active {
  display: flex;
}

/* --- Dual HP Roster Dashboard --- */
.h5-hud-rpg {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  height: 42px;
}

.hud-character-panel {
  flex: 1;
  background: var(--light-white);
  border: var(--border-thin);
  box-shadow: var(--neo-shadow-small);
  border-radius: 8px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.char-details {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  font-weight: 900;
}

.hp-border-rpg {
  height: 10px;
  background: #eaeaea;
  border: 1.5px solid #121212;
  border-radius: 5px;
  overflow: hidden;
}

.hp-fill-rpg {
  height: 100%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-fill {
  background: var(--pop-blue);
}

.boss-fill {
  background: var(--pop-pink);
}

.hud-vs-badge {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--light-white);
  background: var(--dark-black);
  padding: 2px 5px;
  border-radius: 4px;
  transform: rotate(8deg);
  border: 1.5px solid var(--neon-yellow);
}

/* Gold Bar HUD indicators */
.hud-gold-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  height: 28px;
}

.gold-badge {
  background: var(--neon-yellow);
  border: var(--border-thin);
  box-shadow: var(--neo-shadow-small);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.78rem;
}

.monster-remain-badge {
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--light-white);
  border: var(--border-thin);
  border-radius: 6px;
  padding: 2px 8px;
}

.combo-badge-rpg {
  background: var(--pop-pink);
  color: var(--light-white);
  border: var(--border-thin);
  border-radius: 6px;
  padding: 2px 8px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  animation: shakeCombo 1.5s infinite ease-in-out;
  display: none;
}

/* --- Monster Stage --- */
.h5-stage {
  height: 180px; /* Perfectly sized for the large SVG monster */
  background: transparent; /* No card box - monster floats in the open console arena! */
  border: none;
  box-shadow: none;
  position: relative;
  overflow: visible; /* Let spikes, wings, and drop shadows pop out! */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0;
  margin-bottom: -16px; /* Stick directly on top of the dialogue bubble! */
  z-index: 5; /* Render above the bubble's top arrow for 3D depth */
}

.stage-halftone {
  display: none; /* Redundant now that the background is transparent */
}

.monster-wrapper {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.monster-ring {
  width: 110px;
  height: 24px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  position: absolute;
  bottom: -4px;
  z-index: 1;
}

.monster-char {
  z-index: 2;
  transform-origin: bottom center;
  animation: monsterIdle 2.5s infinite ease-in-out;
  transition: transform 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
}

.monster-char svg {
  width: 165px; /* Extremely large, dominant boss graphic! */
  height: 165px;
  display: block;
  overflow: visible; /* Ensure spiky edges and flat drop-shadows render perfectly! */
}

.monster-char.hurt {
  animation: monsterHurt 0.4s ease;
}

.monster-char.laugh {
  animation: monsterLaugh 0.5s ease;
}

/* --- H5 Equipment Inventory Slots --- */
.h5-inventory {
  background: var(--light-white);
  border: var(--border-medium);
  box-shadow: var(--neo-shadow-small);
  border-radius: 12px;
  padding: 6px 10px;
  margin-bottom: 6px;
}

.inventory-title {
  font-size: 0.65rem;
  font-weight: 900;
  color: #555;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.inventory-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.inv-slot {
  background: #fafafa;
  border: var(--border-thin);
  border-radius: 8px;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: default;
  position: relative;
  outline: none;
}

.inv-slot.active-item {
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.inv-slot.active-item:active {
  transform: scale(0.95);
}

.inv-slot.equipped {
  background: var(--neon-yellow);
  border-color: var(--pop-purple);
}

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

.slot-count {
  font-size: 0.65rem;
  font-weight: 800;
  background: #eaeaea;
  border-radius: 8px;
  padding: 1px 6px;
  margin-top: 1px;
}

.slot-tag {
  font-size: 0.5rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
  transform: scale(0.9);
}

.slot-tag.passive {
  background: #eee;
  color: #666;
}

.slot-tag.use {
  background: var(--pop-blue);
  color: var(--dark-black);
}

/* --- Comic Clue Speech Bubble --- */
.h5-bubble-container {
  margin: 5px 0;
  display: flex;
  justify-content: center;
}

.comic-bubble {
  background: var(--light-white);
  border: var(--border-thick);
  box-shadow: var(--neo-shadow);
  border-radius: 16px;
  padding: 8px 12px;
  width: 100%;
  position: relative;
  text-align: center;
}

.comic-bubble .bubble-arrow {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 15px 15px;
  border-style: solid;
  border-color: var(--dark-black) transparent;
  width: 0;
}

.comic-bubble .bubble-arrow::after {
  content: '';
  position: absolute;
  top: 3px;
  left: -12px;
  border-width: 0 12px 12px;
  border-style: solid;
  border-color: var(--light-white) transparent;
  width: 0;
}

#prompt-chinese {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--dark-black);
}

/* --- Interactive Spelling Box --- */
.h5-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.h5-input {
  width: 100%;
  background: var(--light-white);
  border: var(--border-thick);
  box-shadow: var(--neo-shadow);
  border-radius: 12px;
  padding: 10px;
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
  outline: none;
  font-family: var(--font-body);
}

.h5-input:focus {
  border-color: var(--pop-purple);
}

.controls-actions {
  display: flex;
  gap: 8px;
}

.btn-action {
  flex: 1;
  border: var(--border-medium);
  box-shadow: var(--neo-shadow-small);
  border-radius: 8px;
  padding: 8px 0;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  transition: transform 0.05s, box-shadow 0.05s;
}

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

.btn-pronounce {
  background: var(--pop-blue);
}

.btn-fire {
  background: var(--pop-pink);
  color: var(--light-white);
}

/* --- Feedback Panel --- */
.h5-feedback {
  background: var(--light-white);
  border: var(--border-medium);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 8px;
  display: none;
  flex-direction: column;
  gap: 3px;
  font-size: 0.82rem;
  box-shadow: var(--neo-shadow-small);
}

.h5-feedback.correct {
  border-color: var(--pop-green);
  background: rgba(0, 255, 170, 0.08);
}

.h5-feedback.incorrect {
  border-color: var(--pop-pink);
  background: rgba(255, 0, 127, 0.08);
}

.feedback-head {
  font-weight: 900;
  font-size: 0.9rem;
}

.audio-trigger {
  cursor: pointer;
  background: #eaeaea;
  border: 1px solid #aaa;
  border-radius: 3px;
  padding: 0 4px;
  font-size: 0.72rem;
  font-weight: 800;
  margin-left: 5px;
}

/* --- PAGE 2: RETRO MAGIC SHOP SCREEN --- */
.shop-gold-hud {
  background: var(--light-white);
  border: var(--border-medium);
  box-shadow: var(--neo-shadow-small);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
  font-weight: 800;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.gold-highlight {
  font-size: 1.15rem;
  color: var(--pop-orange);
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  overflow-y: auto;
  flex-grow: 1;
  padding-bottom: 10px;
}

.shop-item-card {
  background: var(--light-white);
  border: var(--border-medium);
  box-shadow: var(--neo-shadow-small);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
}

.shop-item-icon {
  font-size: 1.8rem;
}

.shop-item-name {
  font-weight: 900;
  font-size: 0.8rem;
}

.shop-item-desc {
  font-size: 0.58rem;
  color: #555;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.3;
}

.btn-buy {
  width: 100%;
  background: var(--neon-yellow);
  border: var(--border-thin);
  border-radius: 6px;
  padding: 5px;
  font-weight: 800;
  font-size: 0.72rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3px;
  transition: transform 0.05s;
}

.btn-buy:active {
  transform: scale(0.95);
}

.price-lbl {
  font-weight: 900;
}

/* --- PAGE 3: ERROR MISTAKES SCREEN --- */
.tab-header {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.tab-subtitle {
  font-size: 0.7rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 8px;
}

.error-deck {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.error-card-item {
  background: var(--light-white);
  border: var(--border-medium);
  box-shadow: var(--neo-shadow-small);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.error-desc {
  display: flex;
  flex-direction: column;
}

.error-desc-eng {
  font-weight: 800;
  font-size: 0.9rem;
}

.error-desc-chn {
  font-size: 0.72rem;
  color: #666;
}

.error-tries {
  background: var(--pop-pink);
  color: var(--light-white);
  border: var(--border-thin);
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 5px;
}

.empty-deck {
  text-align: center;
  padding: 30px;
  color: #777;
  font-size: 0.8rem;
  font-style: italic;
}

/* --- PAGE 4: CONFIG DICTIONARY SCREEN --- */
.summon-form {
  background: var(--light-white);
  border: var(--border-medium);
  box-shadow: var(--neo-shadow-small);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.summon-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.summon-row label {
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
}

.summon-row input {
  border: var(--border-thin);
  border-radius: 6px;
  padding: 5px 8px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  outline: none;
}

.btn-summon {
  background: var(--pop-purple);
  color: var(--light-white);
  border: var(--border-thin);
  padding: 6px;
  font-weight: 800;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  margin-top: 4px;
}

.summon-subtitle {
  font-size: 0.82rem;
  font-weight: 900;
  margin-bottom: 4px;
}

.dictionary-scroll {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-item-dict {
  background: var(--light-white);
  border: var(--border-thin);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dict-word-info {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.dict-w-eng {
  font-weight: 800;
  font-size: 0.82rem;
  font-family: monospace;
}

.dict-w-chn {
  font-size: 0.72rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-bin {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--pop-pink);
  font-size: 0.95rem;
}

/* --- Console Navigation Tabs Bar --- */
.console-nav {
  height: 55px;
  background: #2a2a2a;
  border-top: var(--border-thick);
  display: flex;
}

.nav-item {
  flex: 1;
  background: transparent;
  border: none;
  color: #aaa;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  padding: 3px 0;
}

.nav-item.active {
  color: var(--neon-yellow);
  background: #1a1a1a;
  border-top: 4px solid var(--neon-yellow);
}

.nav-icon {
  font-size: 1.1rem;
  margin-bottom: 1px;
}

.nav-text {
  font-size: 0.6rem;
  font-weight: 900;
  text-transform: uppercase;
}

/* --- Floating Burst Stickers --- */
.sticker-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 10;
}

.sticker-pop {
  position: absolute;
  font-family: var(--font-heading);
  color: var(--light-white);
  border: var(--border-thick);
  padding: 3px 12px;
  border-radius: 6px;
  transform: translate(-50%, -50%);
  animation: burstOut 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  pointer-events: none;
}

.sticker-pop.correct {
  background: var(--pop-green);
  font-size: 2rem;
  text-shadow: 2px 2px 0px #000;
}

.sticker-pop.incorrect {
  background: var(--pop-pink);
  font-size: 1.6rem;
  text-shadow: 2px 2px 0px #000;
}

/* --- Victory/Gameover Dashboard Modal --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(18, 18, 18, 0.85);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 15px;
}

.victory-card {
  background: var(--light-white);
  border: var(--border-thick);
  box-shadow: var(--console-shadow);
  border-radius: 24px;
  max-width: 370px;
  width: 100%;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 90vh;
  overflow-y: auto;
}

.victory-headline {
  font-family: var(--font-heading);
  font-size: 2.3rem;
  color: var(--pop-orange);
  text-shadow: 3px 3px 0px #000;
  text-align: center;
  transform: rotate(-1deg);
}

.victory-sub {
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
  margin-top: -6px;
}

.rpg-gameover-avatar {
  font-size: 3.5rem;
  animation: bobbingMonster 0.8s infinite alternate ease-in-out;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  border: var(--border-thin);
  border-radius: 12px;
  padding: 6px;
  background: #fafafa;
}

.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  opacity: 0.25;
  transition: opacity 0.3s;
}

.badge-item.unlocked {
  opacity: 1;
}

.badge-bubble {
  width: 32px;
  height: 32px;
  background: var(--neon-yellow);
  border: var(--border-thin);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.1rem;
}

.badge-title {
  font-size: 0.52rem;
  font-weight: 800;
  text-align: center;
}

.victory-table-container {
  border: var(--border-thin);
  border-radius: 10px;
  overflow: hidden;
  max-height: 160px;
  overflow-y: auto;
}

.victory-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.72rem;
}

.victory-table th, .victory-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #ddd;
}

.victory-table th {
  background: #eee;
  font-weight: 800;
}

.victory-table tr:nth-child(even) td {
  background: #f9f9f9;
}

.victory-actions {
  display: flex;
  gap: 8px;
}

.btn-victory-restart, .btn-victory-close {
  flex: 1;
  border: var(--border-medium);
  border-radius: 8px;
  padding: 8px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

.btn-victory-restart {
  background: var(--pop-pink);
  color: var(--light-white);
}

.btn-victory-close {
  background: var(--pop-blue);
}

/* --- Game Keyframes --- */
@keyframes blinkBattery {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

@keyframes monsterIdle {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-6px) scaleY(0.96) scaleX(1.02); }
}

@keyframes monsterHurt {
  0%, 100% { transform: translateX(0); filter: invert(0); }
  25%, 75% { transform: translateX(-8px); filter: invert(0.4) sepia(1) saturate(5) hue-rotate(300deg); }
  50% { transform: translateX(8px); filter: invert(0.4) sepia(1) saturate(5) hue-rotate(300deg); }
}

@keyframes monsterLaugh {
  0%, 100% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-8px) scale(1.12) rotate(4deg); }
  75% { transform: translateY(-8px) scale(1.12) rotate(-4deg); }
}

@keyframes shakeCombo {
  0%, 100% { transform: rotate(-3deg) scale(1); }
  50% { transform: rotate(3deg) scale(1.06); }
}

@keyframes burstOut {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(-20deg); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.2) rotate(10deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.9) translateY(-25px) rotate(-3deg); opacity: 0; }
}

@keyframes bobbingMonster {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

/* Custom Scrollbars */
.screen-tab::-webkit-scrollbar,
.error-deck::-webkit-scrollbar,
.dictionary-scroll::-webkit-scrollbar,
.victory-table-container::-webkit-scrollbar {
  width: 6px;
}
.screen-tab::-webkit-scrollbar-track,
.error-deck::-webkit-scrollbar-track,
.dictionary-scroll::-webkit-scrollbar-track,
.victory-table-container::-webkit-scrollbar-track {
  background: transparent;
}
.screen-tab::-webkit-scrollbar-thumb,
.error-deck::-webkit-scrollbar-thumb,
.dictionary-scroll::-webkit-scrollbar-thumb,
.victory-table-container::-webkit-scrollbar-thumb {
  background: var(--dark-black);
  border-radius: 3px;
}
