/* ==========================================================================
   STICKMAN SHADOW BLADE - THEME INSPIRED BY IMAGE.PNG
   Palette: Sky Blue (#33c9f6), Leaf Green (#2cd646, #41c75d, #145b23),
            Wood Timber (#d4883b, #9f5822, #56280b), Chunky White (#ffffff),
            and Cartoon Slate-Cyan Outline (#184357).
   Fully Mobile-Optimized for Handheld Landscape Gaming.
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: #33c9f6;
  color: #184357;
  -webkit-tap-highlight-color: transparent;
}

#game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #33c9f6;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #33c9f6;
}

/* ==========================================================================
   UI LAYER & SCREENS (CARTOON SKY & NATURE THEME)
   ========================================================================== */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #33c9f6 0%, #56d3fc 35%, #a8e9ff 70%, #dff7ff 100%);
  color: #184357;
  padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.25s ease;
}

.hidden {
  display: none !important;
}

/* Buttons General (3D Cartoon Style) */
button {
  pointer-events: auto;
  cursor: pointer;
  border: none;
  outline: none;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-radius: 12px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, filter 0.08s ease, box-shadow 0.08s ease;
}

button:active {
  transform: translateY(3px) scale(0.97);
}

/* Primary Button: Leaf Green (like "THE" and cartoon leaves in image.png) */
.btn-primary {
  background: linear-gradient(180deg, #4bd663 0%, #22a845 100%);
  color: #ffffff;
  border: 2.5px solid #145b23;
  padding: 14px 28px;
  font-size: 1.15rem;
  box-shadow: 0 5px 0 #145b23, 0 8px 18px rgba(20, 91, 35, 0.4);
  text-shadow: 1px 1px 2px #104a1c;
}

.btn-primary:active {
  box-shadow: 0 2px 0 #145b23, 0 4px 10px rgba(20, 91, 35, 0.3);
}

/* Secondary Button: Wood Timber (like the wooden plank signboard in image.png) */
.btn-secondary {
  background: linear-gradient(180deg, #e8a054 0%, #c57930 100%);
  color: #ffffff;
  border: 2.5px solid #56280b;
  padding: 12px 24px;
  font-size: 0.95rem;
  box-shadow: 0 5px 0 #56280b, 0 8px 16px rgba(86, 40, 11, 0.35);
  text-shadow: 1px 1px 2px #45200c;
}

.btn-secondary:active {
  box-shadow: 0 2px 0 #56280b, 0 4px 8px rgba(86, 40, 11, 0.3);
}

/* Sub Button: Cloud White with Cartoon Outline */
.btn-sub {
  background: linear-gradient(180deg, #ffffff 0%, #e2f5ff 100%);
  color: #184357;
  border: 2px solid #27627d;
  padding: 10px 18px;
  font-size: 0.85rem;
  box-shadow: 0 4px 0 #27627d, 0 6px 12px rgba(39, 98, 125, 0.2);
}

.btn-sub:active {
  box-shadow: 0 1px 0 #27627d;
}

/* Ad / Gold Button: Warm Honey Amber */
.btn-ad {
  background: linear-gradient(180deg, #ffd338 0%, #f59e0b 100%);
  color: #5d3800;
  border: 2px solid #8c5300;
  font-weight: 900;
  padding: 12px 22px;
  border-radius: 10px;
  box-shadow: 0 4px 0 #8c5300, 0 6px 14px rgba(245, 158, 11, 0.4);
}

.icon-btn {
  background: linear-gradient(180deg, #ffffff 0%, #e2f5ff 100%);
  color: #184357;
  border: 2px solid #d4883b;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  box-shadow: 0 3px 0 #9f5822;
}

/* ==========================================================================
   HUD TOP BAR (WOODEN SIGNBOARD & LEAF GREEN ACCENTS)
   ========================================================================== */
#hud-top {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 20;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-avatar {
  position: relative;
  width: 48px;
  height: 48px;
  background: #ffffff;
  border: 3px solid #d4883b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 0 #9f5822, 0 6px 12px rgba(0, 0, 0, 0.15);
}

.avatar-level {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: #2cd646;
  border: 1.5px solid #145b23;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 2px 5px;
  border-radius: 6px;
  box-shadow: 0 2px 0 #145b23;
}

.bars-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 160px;
}

.bar-frame {
  position: relative;
  height: 16px;
  background: #ffffff;
  border-radius: 9px;
  border: 2px solid #56280b;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.15), 0 2px 0 #9f5822;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.2s ease-out;
}

.hp-fill {
  background: linear-gradient(90deg, #22a845 0%, #4bd663 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.rage-fill {
  background: linear-gradient(90deg, #f59e0b 0%, #ffd338 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  width: 0%;
}

.bar-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 900;
  color: #184357;
  text-shadow: 0 0 3px #ffffff, 0 0 5px #ffffff;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

#hud-stage-name {
  font-size: 0.92rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: -1.5px -1.5px 0 #145b23, 1.5px -1.5px 0 #145b23, -1.5px 1.5px 0 #145b23, 1.5px 1.5px 0 #145b23, 0 3px 0 #145b23;
  letter-spacing: 0.5px;
}

#hud-timer {
  font-size: 0.8rem;
  color: #125626;
  font-weight: 800;
  font-family: monospace;
}

#boss-bar-wrap {
  margin-top: 4px;
  width: 220px;
}

.boss-name-tag {
  font-size: 0.72rem;
  font-weight: 900;
  color: #b91c1c;
  margin-bottom: 2px;
  text-shadow: 0 1px 2px #ffffff;
}

.boss-frame {
  height: 16px;
  border: 2px solid #7f1d1d;
}

.boss-fill {
  background: linear-gradient(90deg, #dc2626 0%, #f87171 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.currency-tag {
  background: #ffffff;
  border: 2px solid #d4883b;
  color: #184357;
  box-shadow: 0 3px 0 #9f5822, 0 4px 8px rgba(0, 0, 0, 0.08);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 800;
}

.gold-tag span { color: #d97706; font-weight: 900; }
.gems-tag span { color: #0284c7; font-weight: 900; }

/* Combo Display */
#combo-display {
  position: absolute;
  top: 70px;
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  animation: pulseScale 0.2s ease-out;
}

#combo-count {
  font-size: 2.8rem;
  font-weight: 900;
  font-style: italic;
  color: #ffd338;
  text-shadow: -2px -2px 0 #184357, 2px -2px 0 #184357, -2px 2px 0 #184357, 2px 2px 0 #184357, 0 5px 0 #184357;
  line-height: 1;
}

#combo-label {
  font-size: 0.9rem;
  font-weight: 900;
  color: #2cd646;
  letter-spacing: 2px;
  text-shadow: -1px -1px 0 #145b23, 1px -1px 0 #145b23, -1px 1px 0 #145b23, 1px 1px 0 #145b23;
}

@keyframes pulseScale {
  0% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* ==========================================================================
   TOUCH CONTROLS (CARTOON SKY BLUE & LEAF GREEN)
   ========================================================================== */
#touch-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60%;
  pointer-events: none;
  z-index: 25;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

#joystick-zone {
  width: 150px;
  height: 150px;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

#joystick-base {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.85) 0%, rgba(52, 201, 247, 0.45) 100%);
  border: 3px solid #34c9f7;
  box-shadow: 0 4px 0 #1b89ab, 0 8px 18px rgba(0, 0, 0, 0.15);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

#joystick-thumb {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(180deg, #4bd663 0%, #22a845 100%);
  border: 2.5px solid #145b23;
  box-shadow: 0 4px 0 #145b23, 0 6px 14px rgba(20, 91, 35, 0.4);
  position: absolute;
  pointer-events: none;
  transform: translate(0, 0);
  transition: transform 0.04s linear;
}

#action-zone {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.skill-row {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.btn-touch {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #184357;
  border: 2.5px solid #d4883b;
  box-shadow: 0 4px 0 #9f5822, 0 6px 14px rgba(0, 0, 0, 0.15);
  touch-action: manipulation;
  transition: transform 0.08s ease, filter 0.08s ease;
}

.btn-touch * {
  pointer-events: none;
  user-select: none;
}

.btn-touch:active, .btn-touch.touch-active {
  transform: translateY(3px) scale(0.93);
}

.btn-skill {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border-color: #d4883b;
  font-size: 1.15rem;
  background: linear-gradient(180deg, #ffffff 0%, #e8f7ff 100%);
  color: #0284c7;
}

.btn-ult {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border-color: #8c5300;
  font-size: 1.35rem;
  background: linear-gradient(180deg, #ffd338 0%, #f59e0b 100%);
  color: #5d3800;
  box-shadow: 0 4px 0 #8c5300, 0 6px 16px rgba(245, 158, 11, 0.5);
}

.btn-ult.ready {
  animation: ultGlow 1s infinite alternate;
}

@keyframes ultGlow {
  0% { box-shadow: 0 4px 0 #8c5300, 0 0 10px #ffd338; }
  100% { box-shadow: 0 4px 0 #8c5300, 0 0 25px #ffd338, 0 0 40px #f59e0b; }
}

.main-action-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.btn-round {
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.btn-dash {
  width: 54px;
  height: 54px;
  background: linear-gradient(180deg, #e8a054 0%, #c57930 100%);
  border-color: #56280b;
  box-shadow: 0 4px 0 #56280b;
  font-size: 0.72rem;
  color: #ffffff;
  text-shadow: 1px 1px 1px #45200c;
}

.btn-jump {
  width: 60px;
  height: 60px;
  background: linear-gradient(180deg, #75ddff 0%, #34c9f7 100%);
  border-color: #1b89ab;
  box-shadow: 0 4px 0 #1b89ab;
  font-size: 0.75rem;
  color: #ffffff;
  text-shadow: 1px 1px 2px #104a5e;
}

.btn-attack {
  width: 78px;
  height: 78px;
  background: linear-gradient(180deg, #4bd663 0%, #22a845 100%);
  border: 3px solid #145b23;
  color: #ffffff;
  font-size: 1.8rem;
  box-shadow: 0 6px 0 #145b23, 0 10px 22px rgba(20, 91, 35, 0.45);
  text-shadow: 1px 1px 2px #104a1c;
}

.btn-cooldown {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(24, 67, 87, 0.75);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 900;
  color: #ffffff;
  pointer-events: none;
}

/* ==========================================================================
   SCREEN: MAIN MENU (TYPOGRAPHY & RESPONSIVE LAYOUT)
   ========================================================================== */
#screen-main-menu {
  position: relative;
  align-items: center;
  justify-content: space-between;
}

.menu-top-bar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 15;
}

.btn-fs-pill {
  background: linear-gradient(180deg, #ffffff 0%, #e8f7ff 100%);
  border: 2px solid #2cd646;
  color: #145b23;
  font-size: 0.78rem;
  padding: 6px 14px;
  border-radius: 20px;
  box-shadow: 0 3px 0 #145b23;
}

.main-title-container {
  text-align: center;
  margin-top: 4px;
}

/* Small Subtitle (like "THE" in image.png) */
.title-sub {
  font-size: 1.25rem;
  color: #2cd646;
  letter-spacing: 4px;
  margin-bottom: 2px;
  font-weight: 900;
  text-shadow: -1.5px -1.5px 0 #145b23, 1.5px -1.5px 0 #145b23, -1.5px 1.5px 0 #145b23, 1.5px 1.5px 0 #145b23, 0 3px 0 #145b23;
}

/* Main Big Title (like "WORD FILTER" chunky 3D white letters in image.png) */
.title-main {
  font-size: 2.6rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow:
    -2.5px -2.5px 0 #184357,
     2.5px -2.5px 0 #184357,
    -2.5px  2.5px 0 #184357,
     2.5px  2.5px 0 #184357,
     0px    5px   0 #184357,
     0px    8px   0 #184357,
     0px   12px 18px rgba(0, 0, 0, 0.3);
}

/* Sub-description (like "FULL GAME DESIGN" in image.png) */
.title-desc {
  font-size: 0.95rem;
  color: #125626;
  margin-top: 4px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.menu-body-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex: 1;
  justify-content: center;
}

.hero-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px 0;
}

#previewHeroCanvas {
  filter: drop-shadow(0 6px 16px rgba(24, 67, 87, 0.3));
}

.hero-stats-preview {
  text-align: center;
  margin-top: 5px;
}

.preview-name {
  font-size: 1.15rem;
  font-weight: 900;
  color: #184357;
}

.preview-stat {
  font-size: 0.88rem;
  color: #125626;
  font-weight: 700;
}

.preview-stat span {
  color: #d4883b;
  font-weight: 900;
}

.menu-button-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}

.menu-button-list button {
  width: 100%;
}

.menu-sub-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.menu-sub-row button {
  flex: 1;
}

.menu-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: #125626;
  font-weight: 700;
}

.kbd-hint {
  color: #d4883b;
  font-weight: 800;
}

/* ==========================================================================
   SCREEN: CHAPTER & LEVEL SELECT (WOODEN SIGNBOARD CARDS)
   ========================================================================== */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  width: 100%;
}

.modal-header h2 {
  font-size: 1.35rem;
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: -2px -2px 0 #184357, 2px -2px 0 #184357, -2px 2px 0 #184357, 2px 2px 0 #184357, 0 4px 0 #184357;
}

.chapter-carousel {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 6px 4px 14px 4px;
  margin-bottom: 12px;
}

.chapter-card {
  min-width: 220px;
  background: #ffffff;
  border: 3px solid #d4883b;
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 5px 0 #9f5822, 0 8px 20px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.chapter-card:hover {
  transform: translateY(-2px);
}

.chapter-card.active {
  border-color: #2cd646;
  box-shadow: 0 6px 0 #145b23, 0 10px 24px rgba(44, 214, 70, 0.35);
  transform: translateY(-4px);
}

.chapter-num {
  font-size: 0.78rem;
  color: #d4883b;
  font-weight: 900;
}

.chapter-title {
  font-size: 1.05rem;
  font-weight: 900;
  margin: 4px 0;
  color: #184357;
}

.chapter-progress {
  font-size: 0.8rem;
  color: #125626;
  font-weight: 700;
}

.level-grid-container {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.stage-btn {
  background: #ffffff;
  border: 2.5px solid #d4883b;
  border-radius: 12px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #184357;
  box-shadow: 0 4px 0 #9f5822, 0 6px 12px rgba(0, 0, 0, 0.08);
}

.stage-btn.locked {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
}

.stage-btn.boss-stage {
  border-color: #ff4757;
  background: linear-gradient(180deg, #fff5f5 0%, #fed7d7 100%);
  box-shadow: 0 4px 0 #c53030;
}

.stage-num {
  font-size: 1.15rem;
  font-weight: 900;
  color: #184357;
}

.stage-stars {
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: #ffd338;
}

/* ==========================================================================
   SCREEN: MODALS (INVENTORY, SKILLS, SHOP)
   ========================================================================== */
.modal-style {
  background: linear-gradient(180deg, #33c9f6 0%, #56d3fc 35%, #a8e9ff 70%, #dff7ff 100%);
  color: #184357;
}

.inventory-body {
  display: flex;
  gap: 16px;
  flex: 1;
}

.equip-display {
  flex: 1;
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  border: 3px solid #d4883b;
  box-shadow: 0 6px 0 #9f5822, 0 10px 24px rgba(0, 0, 0, 0.12);
}

.weapon-storage {
  flex: 1.4;
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  border: 3px solid #d4883b;
  box-shadow: 0 6px 0 #9f5822, 0 10px 24px rgba(0, 0, 0, 0.12);
  overflow-y: auto;
}

.weapon-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.weapon-card {
  background: linear-gradient(180deg, #ffffff 0%, #f4fbff 100%);
  border: 2.5px solid #d4883b;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 0 #9f5822, 0 6px 12px rgba(0, 0, 0, 0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.weapon-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #9f5822, 0 8px 16px rgba(0, 0, 0, 0.12);
}

.weapon-card.rarity-Common { border-color: #78909c; }
.weapon-card.rarity-Rare { border-color: #34c9f7; }
.weapon-card.rarity-Epic { border-color: #2cd646; }
.weapon-card.rarity-Legendary { border-color: #ffd338; }

.weapon-card.equipped {
  box-shadow: 0 4px 0 #145b23, 0 0 16px rgba(44, 214, 70, 0.5);
  border-color: #2cd646;
}

.weapon-name {
  font-weight: 900;
  font-size: 0.95rem;
  color: #184357;
}

.weapon-desc {
  font-size: 0.78rem;
  color: #125626;
  font-weight: 600;
}

.hero-stats-panel {
  margin-top: 14px;
  border-top: 2px solid #e0f2fe;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  color: #184357;
  font-weight: 600;
}

/* Skill Tree */
.skilltree-branches {
  display: flex;
  gap: 14px;
  flex: 1;
}

.talent-branch {
  flex: 1;
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  border: 3px solid #d4883b;
  box-shadow: 0 6px 0 #9f5822, 0 10px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.talent-branch h3 {
  font-size: 1.05rem;
  font-weight: 900;
  color: #184357;
  border-bottom: 2px solid #e0f2fe;
  padding-bottom: 6px;
}

.talent-node {
  background: linear-gradient(180deg, #ffffff 0%, #f4fbff 100%);
  border: 2px solid #d4883b;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 3px 0 #9f5822;
}

.talent-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.talent-name {
  font-weight: 800;
  font-size: 0.88rem;
  color: #184357;
}

.talent-effect {
  font-size: 0.72rem;
  color: #125626;
  font-weight: 600;
}

.talent-rank {
  font-size: 0.82rem;
  font-weight: 900;
  color: #d4883b;
}

.btn-talent-up {
  background: linear-gradient(180deg, #4bd663 0%, #22a845 100%);
  color: #ffffff;
  border: 1.5px solid #145b23;
  padding: 6px 12px;
  font-size: 0.76rem;
  border-radius: 8px;
  box-shadow: 0 3px 0 #145b23;
}

/* Shop */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.shop-item-card {
  background: #ffffff;
  border: 3px solid #d4883b;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  box-shadow: 0 6px 0 #9f5822, 0 10px 24px rgba(0, 0, 0, 0.12);
}

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

.shop-item-name {
  font-weight: 900;
  font-size: 0.95rem;
  color: #184357;
}

.shop-item-price {
  font-size: 0.88rem;
  font-weight: 900;
  color: #d97706;
}

/* ==========================================================================
   MODALS: VICTORY & DEFEAT (CARTOON NOTICEBOARD STYLE)
   ========================================================================== */
.modal-overlay {
  align-items: center;
  justify-content: center;
  background: rgba(51, 201, 246, 0.75);
  backdrop-filter: blur(8px);
}

.victory-card, .defeat-card, .pause-card {
  background: #ffffff;
  border: 4px solid #d4883b;
  border-radius: 20px;
  padding: 24px 34px;
  width: 90%;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 8px 0 #9f5822, 0 18px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: #184357;
}

.defeat-card {
  border-color: #ff4757;
  box-shadow: 0 8px 0 #c53030, 0 18px 40px rgba(0, 0, 0, 0.25);
}

.victory-title {
  color: #2cd646;
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: -2px -2px 0 #145b23, 2px -2px 0 #145b23, -2px 2px 0 #145b23, 2px 2px 0 #145b23, 0 4px 0 #145b23;
}

.defeat-title {
  color: #ff4757;
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: -2px -2px 0 #7f1d1d, 2px -2px 0 #7f1d1d, -2px 2px 0 #7f1d1d, 2px 2px 0 #7f1d1d, 0 4px 0 #7f1d1d;
}

.stars-earned {
  font-size: 2.2rem;
  letter-spacing: 6px;
  color: #ffd338;
  text-shadow: 0 3px 0 #8c5300;
}

.victory-objectives {
  text-align: left;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #f0fdf4;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid #bbf7d0;
  color: #145b23;
}

.rewards-summary {
  font-size: 0.95rem;
  font-weight: 900;
  color: #d97706;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

/* ==========================================================================
   ROTATE PHONE OVERLAY FOR PORTRAIT MODE
   ========================================================================== */
#rotate-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(180deg, #184357 0%, #0f2b38 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 24px;
  text-align: center;
}

.rotate-card {
  background: #ffffff;
  color: #184357;
  border: 4px solid #d4883b;
  border-radius: 24px;
  padding: 30px 22px;
  max-width: 350px;
  width: 90%;
  box-shadow: 0 8px 0 #9f5822, 0 20px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.rotate-phone-anim {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  gap: 12px;
}

.phone-icon {
  animation: phoneTilt 1.8s infinite ease-in-out;
  display: inline-block;
}

.arrow-rotate {
  animation: spinCycle 2.5s infinite linear;
  display: inline-block;
  font-size: 2rem;
}

@keyframes phoneTilt {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

@keyframes spinCycle {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.rotate-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: #184357;
  line-height: 1.2;
}

.rotate-desc {
  font-size: 0.85rem;
  color: #475569;
  font-weight: 600;
  line-height: 1.4;
}

.rotate-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.rotate-actions button {
  width: 100%;
}

/* ==========================================================================
   MULTIPLAYER: LOBBY, ROOM BROWSER, 10-SLOT GRID & CHARACTER PICKER
   ========================================================================== */

/* Main Menu Multiplayer Button with Special Glow */
.btn-multiplayer-glow {
  background: linear-gradient(180deg, #33c9f6 0%, #0284c7 100%) !important;
  box-shadow: 0 5px 0 #0369a1, 0 6px 14px rgba(2, 132, 199, 0.4) !important;
  border: 2px solid #ffffff !important;
  animation: mpButtonPulse 2.8s ease-in-out infinite;
}

@keyframes mpButtonPulse {
  0%, 100% {
    box-shadow: 0 5px 0 #0369a1, 0 6px 14px rgba(2, 132, 199, 0.4);
  }
  50% {
    box-shadow: 0 5px 0 #0369a1, 0 8px 22px rgba(51, 201, 246, 0.7);
  }
}

.mp-lobby-screen {
  display: flex;
  flex-direction: column;
  padding: 18px 24px;
  overflow-y: auto;
}

.mp-profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mp-profile-name {
  font-weight: 900;
  color: #184357;
  font-size: 1rem;
  background: #ffffff;
  padding: 6px 14px;
  border-radius: 20px;
  border: 2px solid #2cd646;
  box-shadow: 0 2px 0 #145b23;
}

.btn-skin-badge {
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
  border: 2px solid #2cd646;
  color: #184357;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  box-shadow: 0 2px 0 #145b23;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn-skin-badge:hover {
  transform: translateY(-1px);
  background: #dcfce7;
}

.mp-view-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.mp-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.85);
  padding: 12px 18px;
  border-radius: 14px;
  border: 2.5px solid #d4883b;
  box-shadow: 0 4px 0 #9f5822;
}

.mp-code-join-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.mp-code-join-wrap input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 2px solid #184357;
  font-weight: 700;
  font-size: 0.9rem;
  color: #184357;
  background: #ffffff;
  width: 170px;
}

.mp-info-banner {
  background: linear-gradient(90deg, #dcfce7 0%, #e0f2fe 100%);
  border: 2px solid #2cd646;
  color: #14532d;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 2px 0 #166534;
}

/* Room Grid & Cards */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  width: 100%;
}

.room-card {
  background: #ffffff;
  border: 3px solid #d4883b;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 5px 0 #9f5822, 0 8px 16px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease;
}

.room-card:hover {
  transform: translateY(-2px);
}

.room-card.room-full {
  border-color: #f87171;
  background: #fff5f5;
  box-shadow: 0 5px 0 #b91c1c;
}

.room-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-id-tag {
  background: #184357;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.room-mode-tag {
  font-size: 0.74rem;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 8px;
}

.mode-vsbot {
  background: #fef2f2;
  color: #b91c1c;
  border: 1.5px solid #ef4444;
}

.mode-coop {
  background: #f0fdf4;
  color: #15803d;
  border: 1.5px solid #22c55e;
}

.badge-mode-toggle {
  background: #fffbeb;
  border: 2px solid #f59e0b;
  color: #b45309;
  border-radius: 12px;
  padding: 5px 12px;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 0 #d97706;
  transition: transform 0.15s ease, background 0.15s ease;
}

.badge-mode-toggle:hover {
  background: #fef3c7;
  transform: translateY(-1px);
}

.room-cap-tag {
  font-size: 0.85rem;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 12px;
}

.cap-open {
  background: #dcfce7;
  color: #15803d;
  border: 1.5px solid #22c55e;
}

.cap-full {
  background: #fee2e2;
  color: #b91c1c;
  border: 1.5px solid #ef4444;
}

.room-card-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: #184357;
}

.room-card-meta {
  font-size: 0.85rem;
  color: #475569;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.room-card-footer {
  margin-top: auto;
}

.btn-join-room {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.95rem;
}

.btn-disabled {
  background: #cbd5e1 !important;
  color: #64748b !important;
  border: 2px solid #94a3b8 !important;
  box-shadow: none !important;
  cursor: not-allowed;
}

/* Waiting Room View */
.room-header-bar {
  background: #ffffff;
  border: 3px solid #d4883b;
  border-radius: 16px;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: 0 5px 0 #9f5822;
}

.room-title-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.room-title-info h3 {
  font-size: 1.3rem;
  font-weight: 900;
  color: #184357;
  margin: 0;
}

.room-code-badge {
  background: #184357;
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 900;
  font-size: 0.85rem;
}

.room-map-badge {
  background: #f0fdf4;
  color: #166534;
  border: 1.5px solid #22c55e;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.85rem;
}

.room-count-badge {
  background: #e0f2fe;
  color: #0369a1;
  border: 1.5px solid #38bdf8;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.85rem;
}

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

.btn-pulse {
  animation: pulseButton 2s infinite;
}

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

.room-slot-hint {
  font-size: 0.88rem;
  color: #184357;
  background: #fffbeb;
  border: 2px solid #f59e0b;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
}

/* 10 Player Slots Grid */
.slots-grid-10 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  width: 100%;
}

.player-slot-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.player-slot-card.filled {
  border: 2.5px solid #d4883b;
  box-shadow: 0 4px 0 #9f5822, 0 4px 10px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.player-slot-card.filled:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #9f5822, 0 8px 14px rgba(0, 0, 0, 0.12);
}

.player-slot-card.slot-self {
  border-color: #2cd646;
  background: #f0fdf4;
  box-shadow: 0 4px 0 #16a34a, 0 4px 10px rgba(34, 197, 94, 0.15);
}

.player-slot-card.empty {
  border: 2px dashed #94a3b8;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: none;
  opacity: 0.75;
}

.slot-badge-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 6px;
  align-items: center;
}

.slot-num {
  font-size: 0.75rem;
  font-weight: 900;
  color: #64748b;
}

.badge-host {
  background: #fef08a;
  color: #854d0e;
  border: 1px solid #eab308;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.65rem;
  font-weight: 900;
}

.badge-self {
  background: #bbf7d0;
  color: #166534;
  border: 1px solid #22c55e;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.65rem;
  font-weight: 900;
}

.badge-bot-enemy {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #ef4444;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.65rem;
  font-weight: 900;
}

.badge-bot-ally {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #22c55e;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.65rem;
  font-weight: 900;
}

.player-slot-card.slot-enemy-bot {
  border-color: #f87171 !important;
  background: #fff8f8 !important;
  box-shadow: 0 4px 0 #dc2626, 0 4px 10px rgba(239, 68, 68, 0.12) !important;
}

.slot-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 3px solid #184357;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  margin-bottom: 6px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.avatar-emoji {
  font-size: 1.6rem;
}

.slot-player-name {
  font-weight: 900;
  font-size: 0.9rem;
  color: #184357;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-skin-name {
  font-size: 0.75rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.slot-ping {
  font-size: 0.7rem;
  font-weight: 700;
  color: #16a34a;
  margin-bottom: 6px;
}

.btn-inspect-player {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  color: #1e293b;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.68rem;
  font-weight: 800;
  width: 100%;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-inspect-player:hover {
  background: #e2e8f0;
}

.empty-slot-icon {
  font-size: 1.8rem;
  color: #94a3b8;
  margin: 12px 0 6px 0;
}

.empty-slot-text {
  font-size: 0.85rem;
  font-weight: 800;
  color: #64748b;
}

.empty-slot-sub {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-bottom: 12px;
}

/* Modals: Character & Skin Picker */
.picker-card, .create-room-card, .inspect-card {
  background: #ffffff;
  border-radius: 20px;
  border: 4px solid #d4883b;
  box-shadow: 0 8px 0 #9f5822, 0 16px 36px rgba(0, 0, 0, 0.25);
  max-width: 820px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.player-nickname-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
}

.player-nickname-bar label {
  font-weight: 900;
  color: #184357;
  font-size: 0.95rem;
}

.player-nickname-bar input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 2px solid #184357;
  font-weight: 800;
  font-size: 0.95rem;
  color: #184357;
  flex: 1;
}

.skin-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  width: 100%;
}

.skin-card {
  background: #ffffff;
  border: 3px solid #cbd5e1;
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.06);
  transition: transform 0.15s ease;
}

.skin-card:hover {
  transform: translateY(-2px);
}

.skin-card.active-skin {
  border-width: 3.5px;
  box-shadow: 0 0 14px rgba(44, 214, 70, 0.4), 0 4px 0 #16a34a;
  background: #f0fdf4;
}

.skin-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.skin-avatar-preview {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #184357;
}

.skin-emoji {
  font-size: 1.6rem;
}

.skin-card-name {
  font-size: 1rem;
  font-weight: 900;
}

.skin-card-role {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 700;
}

.skin-card-desc {
  font-size: 0.8rem;
  color: #334155;
  line-height: 1.3;
  margin: 0;
}

.skin-stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}

.stat-chip {
  background: #e2e8f0;
  color: #1e293b;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 0.7rem;
  font-weight: 800;
}

.btn-select-skin {
  margin-top: auto;
  width: 100%;
  padding: 7px 10px;
  font-size: 0.85rem;
}

/* Modal: Create Room Form */
.create-room-card {
  max-width: 520px;
}

.create-room-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.create-room-form label {
  font-weight: 900;
  color: #184357;
  font-size: 0.95rem;
}

.create-room-form input,
.create-room-form select {
  padding: 10px 14px;
  border-radius: 10px;
  border: 2.5px solid #184357;
  font-size: 0.95rem;
  font-weight: 800;
  color: #184357;
  background: #ffffff;
}

.form-info-tag {
  background: #e0f2fe;
  border: 2px solid #0284c7;
  color: #0369a1;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Modal: Inspect Player */
.inspect-card {
  max-width: 520px;
}

.inspect-hero-header {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #f8fafc;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid #e2e8f0;
}

.inspect-avatar-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.inspect-name {
  font-size: 1.2rem;
  font-weight: 900;
  color: #184357;
}

.inspect-skin-title {
  font-size: 0.88rem;
  font-weight: 800;
}

.inspect-latency {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 2px;
}

.inspect-section-title {
  font-size: 0.95rem;
  font-weight: 900;
  color: #184357;
  margin-top: 6px;
}

.inspect-equip-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fffbeb;
  border: 2px solid #f59e0b;
  border-radius: 10px;
  padding: 10px 14px;
}

.equip-icon {
  font-size: 1.8rem;
}

.equip-name {
  font-weight: 900;
  font-size: 1rem;
  color: #184357;
}

.equip-desc {
  font-size: 0.8rem;
  color: #475569;
}

.inspect-stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
}

.inspect-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  color: #334155;
}

.inspect-stat-row strong {
  color: #184357;
}

.inspect-perk-box {
  background: #f0fdf4;
  border: 2px solid #2cd646;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #166534;
}

/* ==========================================================================
   MEDIA QUERIES: MOBILE LANDSCAPE OPTIMIZATIONS (HEIGHT <= 520px)
   ========================================================================== */
@media (max-height: 520px) {
  #screen-main-menu {
    padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    justify-content: space-between;
  }

  .main-title-container {
    margin-top: 0;
    margin-bottom: 2px;
  }

  .title-sub {
    font-size: 0.85rem;
    letter-spacing: 2px;
  }

  .title-main {
    font-size: 1.6rem;
    letter-spacing: 1px;
    text-shadow:
      -1.5px -1.5px 0 #184357,
       1.5px -1.5px 0 #184357,
      -1.5px  1.5px 0 #184357,
       1.5px  1.5px 0 #184357,
       0px    3px   0 #184357,
       0px    5px   0 #184357,
       0px    8px 12px rgba(0, 0, 0, 0.25);
  }

  .title-desc {
    display: none;
  }

  .menu-body-grid {
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 860px;
    flex: 1;
  }

  .hero-preview-box {
    margin: 0;
  }

  #previewHeroCanvas {
    width: 110px;
    height: 130px;
  }

  .hero-stats-preview {
    margin-top: 2px;
  }

  .preview-name {
    font-size: 0.95rem;
  }

  .preview-stat {
    font-size: 0.75rem;
  }

  .menu-button-list {
    max-width: 380px;
    gap: 6px;
  }

  .btn-primary {
    padding: 10px 18px;
    font-size: 0.95rem;
    box-shadow: 0 4px 0 #145b23;
  }

  .btn-secondary {
    padding: 8px 16px;
    font-size: 0.85rem;
    box-shadow: 0 4px 0 #56280b;
  }

  .menu-sub-row {
    gap: 6px;
  }

  .menu-sub-row button {
    padding: 6px 8px;
    font-size: 0.72rem;
    box-shadow: 0 3px 0 #27627d;
  }

  .menu-footer {
    font-size: 0.65rem;
    margin-top: 2px;
  }

  .kbd-hint {
    display: none;
  }

  /* In-Game HUD adjustments for mobile landscape */
  #hud-top {
    top: max(6px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
  }

  .hero-avatar {
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
  }

  .bars-container {
    width: 130px;
    gap: 3px;
  }

  .bar-frame {
    height: 14px;
  }

  .bar-text {
    font-size: 0.58rem;
  }

  #boss-bar-wrap {
    width: 180px;
  }

  .currency-tag {
    padding: 2px 8px;
    font-size: 0.75rem;
  }

  /* Touch Controls for mobile landscape */
  #touch-controls {
    height: 70%;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  #joystick-zone {
    width: 130px;
    height: 130px;
  }

  #joystick-base {
    width: 110px;
    height: 110px;
  }

  #joystick-thumb {
    width: 44px;
    height: 44px;
  }

  .main-action-cluster {
    gap: 8px;
  }

  .btn-attack {
    width: 68px;
    height: 68px;
    font-size: 1.5rem;
  }

  .btn-dash {
    width: 48px;
    height: 48px;
    font-size: 0.65rem;
  }

  .btn-jump {
    width: 54px;
    height: 54px;
    font-size: 0.7rem;
  }

  .skill-row {
    gap: 8px;
  }

  .btn-skill {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }

  .btn-ult {
    width: 46px;
    height: 46px;
    font-size: 1.15rem;
  }

  /* Modals in landscape mobile */
  .victory-card, .defeat-card, .pause-card {
    padding: 14px 22px;
    gap: 8px;
    max-height: 94vh;
    overflow-y: auto;
  }

  .victory-title, .defeat-title {
    font-size: 1.4rem;
  }

  .stars-earned {
    font-size: 1.8rem;
    letter-spacing: 4px;
  }

  .modal-actions {
    gap: 6px;
  }

  .modal-actions button {
    padding: 8px 16px;
    font-size: 0.85rem;
  }

  .chapter-carousel {
    padding: 4px 2px 10px 2px;
    margin-bottom: 8px;
    gap: 10px;
  }

  .chapter-card {
    min-width: 170px;
    padding: 10px;
  }

  .level-grid-container {
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
  }

  .stage-btn {
    padding: 6px 4px;
    gap: 2px;
  }

  .stage-num {
    font-size: 1rem;
  }

  .inventory-body {
    gap: 12px;
  }

  .equip-display, .weapon-storage, .talent-branch, .shop-item-card {
    padding: 12px;
  }

  /* Multiplayer in landscape mobile */
  .mp-lobby-screen {
    padding: 10px 16px;
  }

  .mp-actions-bar {
    padding: 8px 12px;
    gap: 8px;
  }

  .slots-grid-10 {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .player-slot-card {
    padding: 6px 4px;
  }

  .slot-avatar {
    width: 36px;
    height: 36px;
    margin-bottom: 2px;
  }

  .avatar-emoji {
    font-size: 1.15rem;
  }

  .slot-player-name {
    font-size: 0.76rem;
  }

  .slot-skin-name {
    font-size: 0.64rem;
  }

  .slot-ping {
    font-size: 0.6rem;
    margin-bottom: 3px;
  }

  .btn-inspect-player {
    font-size: 0.58rem;
    padding: 2px 4px;
  }

  .picker-card, .create-room-card, .inspect-card {
    padding: 12px 16px;
    gap: 8px;
  }

  .skin-cards-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .skin-card {
    padding: 8px;
    gap: 4px;
  }

  .skin-card-desc {
    font-size: 0.72rem;
  }

  .stat-chip {
    font-size: 0.62rem;
    padding: 2px 4px;
  }
}
