* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #0d1117;
  --bg-panel: #1e2a3a;
  --accent: #ff6b6b;
  --accent2: #00b06f;
  --gold: #ffcc00;
  --roblox-blue: #00a2ff;
  --text: #f0f0f0;
  --text-dim: #b0b8c4;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

html:fullscreen,
html:-webkit-full-screen,
html.mobile-fullscreen {
  width: 100%;
  height: 100%;
  height: 100dvh;
}

html:fullscreen body,
html:-webkit-full-screen body,
html.mobile-fullscreen body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
}

/* Start Screen */
#start-screen {
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #6eb5ff 0%, #b8e0ff 35%, #00b06f 100%);
  z-index: 50;
  pointer-events: auto;
}

.start-content {
  text-align: center;
  padding: 2rem;
  max-width: 600px;
}

.start-content h1 {
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
  text-shadow: 3px 3px 0 #000, -1px -1px 0 #000;
  color: #fff;
  font-weight: 900;
  letter-spacing: 1px;
}

.subtitle {
  color: var(--text-dim);
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

.animal-select h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--gold);
}

.animal-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.animal-card {
  background: rgba(255,255,255,0.25);
  border: 3px solid #333;
  border-radius: 8px;
  padding: 1rem 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 4px 0 #333;
  font: inherit;
  color: inherit;
  width: 100%;
  pointer-events: auto;
  touch-action: manipulation;
}

.animal-card:hover {
  background: rgba(255,255,255,0.35);
  transform: translateY(-2px);
}

.animal-card.selected {
  border-color: var(--gold);
  background: rgba(255,204,0,0.35);
  box-shadow: 0 4px 0 #b8860b, 0 0 20px rgba(255,204,0,0.5);
}

.animal-card .emoji {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.3rem;
}

.animal-card .name {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.btn-primary {
  background: var(--accent2);
  color: white;
  border: 3px solid #006b42;
  padding: 1rem 2.5rem;
  font-size: 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 900;
  box-shadow: 0 5px 0 #006b42;
  text-transform: uppercase;
}

.btn-primary:hover:not(:disabled) {
  background: #00d084;
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #006b42;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.25);
}

.hint {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Game Screen */
#game-screen {
  flex-direction: column;
  background: #000;
  position: relative;
  overflow: hidden;
}

.world-loading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.world-loading.hidden {
  display: none;
}

.loading-box {
  text-align: center;
  background: var(--bg-panel);
  border: 4px solid #333;
  border-radius: 12px;
  padding: 2rem 3rem;
  box-shadow: 0 8px 0 #111;
}

.loading-title {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.loading-text {
  color: var(--text-dim);
  font-size: 1rem;
}

#game-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 0;
}

#minimap-canvas {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 140px;
  height: 112px;
  border: 3px solid rgba(255,255,255,0.4);
  border-radius: 6px;
  z-index: 10;
  pointer-events: none;
  background: rgba(0,0,0,0.5);
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
  pointer-events: none;
  z-index: 10;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.sound-btn {
  pointer-events: auto;
  background: rgba(0,0,0,0.55);
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 10px;
  padding: 0.2rem 0.55rem;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sound-btn.muted {
  opacity: 0.45;
}

.stat {
  font-size: 0.95rem;
  font-weight: 600;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

.hp-display {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hp-label {
  font-size: 1rem;
}

.hp-bar {
  width: 100px;
  height: 12px;
  background: rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  overflow: hidden;
}

.hp-bar.regenerating {
  border-color: #2ecc71;
  box-shadow: 0 0 8px rgba(46,204,113,0.6);
}

#hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #e74c3c, #ff6b6b);
  border-radius: 4px;
  transition: width 0.3s;
}

.hp-bar.regenerating #hp-fill {
  background: linear-gradient(90deg, #27ae60, #2ecc71);
}

.hp-text {
  font-size: 0.85rem;
  min-width: 52px;
}

.coin-display {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(0,0,0,0.75);
  border: 3px solid var(--gold);
  border-radius: 14px;
  padding: 0.5rem 1.2rem;
  z-index: 15;
  pointer-events: none;
  box-shadow: 0 4px 0 #b8860b, 0 0 20px rgba(255,204,0,0.3);
}

.coin-big-icon {
  font-size: 2rem;
}

.coin-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.coin-label {
  font-size: 0.7rem;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 1px;
}

.coin-count {
  font-size: 1.8rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 2px 2px 0 #b8860b;
}

.coin-popup {
  position: absolute;
  top: -8px;
  right: -16px;
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--gold);
  opacity: 0;
  transform: translateY(0);
  transition: opacity 0.2s, transform 0.5s;
  pointer-events: none;
}

.coin-popup.show {
  opacity: 1;
  transform: translateY(-20px);
}

.xp-bar {
  width: 80px;
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  overflow: hidden;
}

#xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4a90d9, #63b3ed);
  border-radius: 4px;
  transition: width 0.3s;
}

.accessories-bar {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.4rem;
  z-index: 10;
  pointer-events: none;
}

.accessory-badge {
  background: rgba(0,0,0,0.6);
  padding: 0.3rem 0.6rem;
  border-radius: 12px;
  font-size: 1.2rem;
  border: 1px solid rgba(255,215,0,0.4);
}

.action-hint {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  padding: 0.5rem 1.2rem;
  border-radius: 20px;
  font-size: 0.9rem;
  z-index: 10;
  animation: pulse 1.5s infinite;
  border: 1px solid var(--gold);
}

.action-hint.hidden {
  display: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.hidden {
  display: none;
}

.overlay-panel {
  background: var(--bg-panel);
  border: 4px solid #333;
  border-radius: 10px;
  padding: 1.5rem;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 0 #111, 0 15px 40px rgba(0,0,0,0.5);
}

.overlay-panel h2 {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

/* Combat */
.combat-panel {
  width: 520px;
  max-width: 95vw;
  position: relative;
  overflow: visible;
  background: linear-gradient(145deg, #1a2a3a 0%, #243b55 50%, #1a2a3a 100%);
  border-color: #4a6fa5;
}

.combat-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 101;
  transition: opacity 0.08s;
}

.combat-flash.hit-player { background: rgba(231,76,60,0.45); opacity: 1; }
.combat-flash.hit-enemy  { background: rgba(241,196,15,0.35); opacity: 1; }
.combat-flash.heal       { background: rgba(46,204,113,0.35); opacity: 1; }

.combat-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.fx-particle {
  position: absolute;
  font-size: 2rem;
  animation: fx-pop 0.55s ease-out forwards;
  pointer-events: none;
}

.fx-hit   { top: 30%; right: 22%; }
.fx-heal  { top: 35%; left: 22%; }
.fx-block { top: 40%; left: 30%; }

@keyframes fx-pop {
  0%   { transform: scale(0.3); opacity: 0; }
  40%  { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(1) translateY(-30px); opacity: 0; }
}

#combat-overlay.screen-shake {
  animation: screen-shake 0.35s ease;
}

@keyframes screen-shake {
  0%, 100% { transform: translate(0,0); }
  20% { transform: translate(-8px, 4px); }
  40% { transform: translate(8px, -4px); }
  60% { transform: translate(-6px, -2px); }
  80% { transform: translate(6px, 2px); }
}

.combatant.attack-lunge-player {
  animation: lunge-player 0.42s ease;
}

.combatant.attack-lunge-enemy {
  animation: lunge-enemy 0.42s ease;
}

.combatant.heal-glow {
  animation: heal-glow 0.55s ease;
}

.combatant.hit-flash {
  animation: hit-flash 0.35s ease;
}

@keyframes lunge-player {
  0%   { transform: translateX(0) scale(1); }
  45%  { transform: translateX(28px) scale(1.12); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes lunge-enemy {
  0%   { transform: translateX(0) scale(1); }
  45%  { transform: translateX(-28px) scale(1.12); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes heal-glow {
  0%, 100% { filter: none; }
  50% { filter: drop-shadow(0 0 12px #2ecc71); transform: scale(1.08); }
}

@keyframes hit-flash {
  0%, 100% { filter: none; }
  30% { filter: brightness(2) saturate(2); transform: scale(0.92); }
}

.combatants {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin: 1.5rem 0;
}

.combatant {
  text-align: center;
  flex: 1;
}

.combat-emoji {
  font-size: 3.5rem;
  margin-bottom: 0.3rem;
}

.combat-name {
  font-weight: bold;
  margin-bottom: 0.5rem;
}

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

.combat-hp-bar > div {
  height: 100%;
  background: #e74c3c;
  border-radius: 6px;
  transition: width 0.3s;
}

.vs {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent);
  padding: 0 0.5rem;
}

.combat-log {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 0.8rem;
  min-height: 60px;
  max-height: 100px;
  overflow-y: auto;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.combat-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.btn-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 58px;
  padding: 0.5rem 0.3rem;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  font-size: 1.3rem;
  cursor: pointer;
  background: rgba(255,255,255,0.1);
  color: white;
  transition: all 0.15s;
  touch-action: manipulation;
}

.btn-action .atk-name {
  font-size: 0.65rem;
  font-weight: bold;
  text-transform: uppercase;
}

.btn-action .atk-cd {
  font-size: 0.6rem;
  color: var(--gold);
}

.btn-action:hover:not(:disabled), .btn-action:active:not(:disabled) {
  background: var(--accent2);
  transform: scale(0.96);
}

.btn-action:disabled {
  opacity: 0.35;
}

/* Shop */
.shop-panel {
  width: 420px;
}

.shop-greeting {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.shop-coins {
  text-align: center;
  color: var(--gold);
  font-weight: bold;
  margin-bottom: 1rem;
}

.shop-items {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: rgba(255,255,255,0.05);
  padding: 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
}

.shop-item.owned {
  opacity: 0.5;
}

.shop-item .item-emoji {
  font-size: 2rem;
}

.shop-item .item-info {
  flex: 1;
}

.shop-item .item-name {
  font-weight: bold;
}

.shop-item .item-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.shop-item .item-price {
  color: var(--gold);
  font-weight: bold;
}

.shop-item button {
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: var(--accent2);
  color: white;
  font-size: 0.85rem;
}

.shop-item button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Village */
.village-panel {
  width: 400px;
}

.village-npcs {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.npc-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: rgba(255,255,255,0.05);
  padding: 0.8rem;
  border-radius: 10px;
}

.npc-card .npc-emoji {
  font-size: 2rem;
}

.npc-card .npc-text {
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Level Up */
.levelup-panel {
  text-align: center;
  width: 320px;
}

.levelup-panel p {
  margin-bottom: 0.8rem;
  font-size: 1.1rem;
}

.levelup-panel .btn-primary {
  margin-top: 0.5rem;
}

/* Querformat-Hinweis */
.rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  background: #0d1117;
  z-index: 99999;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.rotate-box {
  max-width: 280px;
}

.rotate-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 1rem;
  animation: rotate-pulse 2s infinite;
}

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

.rotate-box p {
  font-size: 1.2rem;
  line-height: 1.5;
}

.rotate-sub {
  font-size: 0.95rem !important;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

.btn-fullscreen {
  margin-top: 1.5rem;
  font-size: 1rem;
  padding: 0.85rem 1.8rem;
  touch-action: manipulation;
}

.rotate-hint.hidden {
  display: none !important;
}

@media (orientation: portrait) and (max-width: 900px) {
  .rotate-hint:not(.hidden) { display: flex; }
  #app { visibility: hidden; pointer-events: none; }
}

/* Mobile Controls – Fortnite-Style */
.look-zone {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  bottom: 100px;
  z-index: 18;
  pointer-events: auto;
  touch-action: none;
}

#mobile-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 25;
  display: none;
  pointer-events: none;
  padding: 0.5rem 1rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  justify-content: space-between;
  align-items: flex-end;
}

.mobile-left, .mobile-right {
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.joystick-zone {
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.joystick-base {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, rgba(0,0,0,0.45) 70%);
  border: 3px solid rgba(255,255,255,0.35);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), inset 0 0 30px rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.joystick-stick {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255,255,255,0.9), rgba(200,220,255,0.7));
  border: 3px solid rgba(255,255,255,0.6);
  box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 16px rgba(100,180,255,0.35);
  position: absolute;
  transition: transform 0.05s ease-out;
  pointer-events: none;
}

.fn-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.5);
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  font: inherit;
  transition: transform 0.1s, box-shadow 0.1s;
}

.fn-btn .fn-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.fn-btn .fn-label {
  font-size: 0.55rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

.fn-btn:active {
  transform: scale(0.9);
}

.jump-btn {
  background: linear-gradient(145deg, #3d9eff, #1a6fd4);
  box-shadow: 0 4px 0 #0d4a8f, 0 0 20px rgba(61,158,255,0.5);
}

.jump-btn:active {
  box-shadow: 0 2px 0 #0d4a8f, 0 0 12px rgba(61,158,255,0.4);
}

.action-btn {
  width: 80px !important;
  height: 80px !important;
  background: linear-gradient(145deg, #ff5e7a, #e63956);
  box-shadow: 0 4px 0 #a01f35, 0 0 22px rgba(255,94,122,0.45);
}

.action-btn:active {
  box-shadow: 0 2px 0 #a01f35, 0 0 14px rgba(255,94,122,0.35);
}

/* Touch-Geräte */
@media (pointer: coarse), (max-height: 500px) {
  .look-zone {
    display: block;
  }

  #mobile-controls {
    display: flex;
  }

  .animal-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .start-content {
    padding: 1rem;
    max-width: 100%;
  }

  .start-content h1 {
    font-size: 1.6rem;
  }

  .animal-card .emoji {
    font-size: 1.8rem;
  }

  #hud {
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
  }

  #hud .hud-right {
    padding-right: 0;
  }

  .coin-display {
    top: max(5px, env(safe-area-inset-top));
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translateX(-50%);
    padding: 0.3rem 0.75rem;
    z-index: 16;
  }

  .coin-big-icon { font-size: 1.25rem; }
  .coin-count { font-size: 1.15rem; }
  .coin-label { font-size: 0.5rem; }

  #minimap-canvas {
    top: 40px;
    right: max(6px, env(safe-area-inset-right));
    bottom: auto;
    left: auto;
    width: 74px;
    height: 58px;
    z-index: 12;
  }

  .accessories-bar {
    top: 42px;
    left: max(8px, env(safe-area-inset-left));
    bottom: auto;
    transform: none;
  }

  .action-hint {
    top: 42%;
    bottom: auto;
    font-size: 0.8rem;
    padding: 0.4rem 0.9rem;
  }

  .sound-btn {
    padding: 0.15rem 0.4rem;
    font-size: 0.95rem;
  }

  .combat-panel {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    padding: 0.8rem;
  }

  .combat-actions {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
  }

  .btn-action {
    min-height: 52px;
    font-size: 1.1rem;
  }

  .overlay-panel {
    max-height: 90vh;
  }
}

/* Querformat Handy */
@media (orientation: landscape) and (max-height: 500px) {
  #hud {
    padding: 0.25rem 0.45rem;
  }

  .hp-bar { width: 65px; height: 9px; }
  .xp-bar { width: 55px; }
  .stat { font-size: 0.8rem; }

  .coin-display {
    top: max(3px, env(safe-area-inset-top));
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translateX(-50%);
    flex-direction: row;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
  }

  .coin-big-icon { font-size: 1.1rem; }
  .coin-count { font-size: 1rem; }

  #minimap-canvas {
    top: 34px;
    right: max(5px, env(safe-area-inset-right));
    bottom: auto;
    left: auto;
    width: 62px;
    height: 50px;
  }

  #mobile-controls {
    padding: 0.3rem 0.6rem;
    padding-bottom: max(0.3rem, env(safe-area-inset-bottom));
  }

  .joystick-zone {
    width: 96px;
    height: 96px;
  }

  .joystick-base {
    width: 84px;
    height: 84px;
  }

  .joystick-stick {
    width: 38px;
    height: 38px;
  }

  .fn-btn {
    width: 58px;
    height: 58px;
  }

  .fn-btn .fn-icon { font-size: 1.25rem; }
  .fn-btn .fn-label { font-size: 0.48rem; }

  .action-btn {
    width: 64px !important;
    height: 64px !important;
  }

  .look-zone {
    bottom: 82px;
  }

  .accessories-bar {
    top: 34px;
    left: max(5px, env(safe-area-inset-left));
  }

  .combat-panel {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem;
    width: 95vw;
  }

  .combat-panel h2 {
    width: 100%;
    margin: 0;
    font-size: 1.1rem;
  }

  .combatants {
    flex: 1;
    min-width: 200px;
    margin: 0;
  }

  .combat-emoji { font-size: 2.2rem; }

  .combat-log {
    flex: 1;
    min-width: 140px;
    min-height: 40px;
    max-height: 70px;
    margin: 0;
    font-size: 0.75rem;
  }

  .combat-actions {
    width: 100%;
    grid-template-columns: repeat(5, 1fr);
  }

  .btn-action {
    min-height: 46px;
    font-size: 1rem;
  }

  .btn-action .atk-name { font-size: 0.55rem; }
}

@media (max-width: 400px) and (orientation: portrait) {
  .animal-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}