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

body {
  background: #1a1a2e;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Courier New', monospace;
  overflow: hidden;
}

#game-container {
  position: relative;
  width: 720px;
  height: 528px;
  border: 4px solid #333;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 40px rgba(0,0,0,0.8);
}

#game-canvas {
  width: 720px;
  height: 528px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#hud {
  position: absolute;
  top: 4px; left: 4px; right: 4px;
  display: flex;
  gap: 12px;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 30;
  pointer-events: none;
}

.hidden { display: none !important; }

#title-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(180deg, #1a3a6a 0%, #2a5a9a 40%, #4a8aca 70%, #7abaea 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.title-content { text-align: center; }

.title-logo {
  font-size: 64px;
  font-weight: bold;
  color: #ffcb05;
  text-shadow: 3px 3px 0 #2a75bb, -1px -1px 0 #2a75bb, 1px -1px 0 #2a75bb, -1px 1px 0 #2a75bb, 0 4px 8px rgba(0,0,0,0.5);
  letter-spacing: 4px;
  animation: titlePulse 2s ease-in-out infinite;
}

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

.title-subtitle {
  font-size: 18px;
  color: #fff;
  margin-top: 8px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.title-prompt {
  font-size: 20px;
  color: #fff;
  margin-top: 40px;
  animation: blink 1.2s step-end infinite;
}

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

.title-controls {
  margin-top: 30px;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  line-height: 1.8;
}

.dialogue-box {
  position: absolute;
  bottom: 8px; left: 8px; right: 8px;
  background: #f8f8f0;
  border: 3px solid #404040;
  border-radius: 8px;
  padding: 16px 20px;
  min-height: 80px;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.dialogue-text {
  font-size: 16px;
  color: #303030;
  line-height: 1.5;
  white-space: pre-wrap;
}

.dialogue-arrow {
  position: absolute;
  bottom: 8px; right: 12px;
  font-size: 14px;
  color: #606060;
  animation: bounce 0.8s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

.menu-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 60;
}

.menu-panel {
  background: #f8f8f0;
  border: 3px solid #404040;
  border-radius: 8px;
  padding: 12px;
  min-width: 280px;
  max-width: 500px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.menu-title {
  font-size: 14px;
  font-weight: bold;
  color: #404040;
  padding: 4px 8px 8px;
  border-bottom: 2px solid #c0c0b0;
  margin-bottom: 8px;
}

.menu-item {
  padding: 6px 12px;
  font-size: 15px;
  color: #303030;
  cursor: pointer;
  border-radius: 4px;
  white-space: pre;
}

.menu-item.selected {
  background: #d0e8ff;
  color: #1a4a8a;
  font-weight: bold;
}

.menu-item.disabled {
  color: #a0a0a0;
  cursor: default;
}

.battle-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.battle-scene {
  position: relative;
  flex: 1;
  background: linear-gradient(180deg, #a8d8f0 0%, #c8e8f8 50%, #90c868 50%, #78b850 100%);
  overflow: hidden;
}

.battle-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 50%;
  background: linear-gradient(180deg, #88c8e8 0%, #b8e0f0 100%);
}

.enemy-platform {
  position: absolute;
  top: 38%; right: 8%;
  width: 160px; height: 40px;
  background: radial-gradient(ellipse, #90c868 0%, #78b850 60%, transparent 70%);
  border-radius: 50%;
}

.player-platform {
  position: absolute;
  bottom: 8%; left: 5%;
  width: 200px; height: 50px;
  background: radial-gradient(ellipse, #90c868 0%, #78b850 60%, transparent 70%);
  border-radius: 50%;
}

.enemy-sprite-wrap {
  position: absolute;
  top: 12%; right: 12%;
}

.player-sprite-wrap {
  position: absolute;
  bottom: 12%; left: 10%;
}

.enemy-sprite, .player-sprite {
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transition: transform 0.1s;
}

.player-sprite {
  transform: scaleX(1);
}

.enemy-sprite.attacking { animation: attackRight 0.3s ease-out; }
.player-sprite.attacking { animation: attackLeft 0.3s ease-out; }

@keyframes attackRight {
  0% { transform: translateX(0); }
  50% { transform: translateX(30px); }
  100% { transform: translateX(0); }
}

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

.enemy-sprite.hit, .player-sprite.hit {
  animation: hitFlash 0.4s;
}

@keyframes hitFlash {
  0%, 100% { opacity: 1; filter: none; }
  25% { opacity: 0.3; filter: brightness(3); }
  50% { opacity: 1; filter: none; }
  75% { opacity: 0.3; filter: brightness(3); }
}

.enemy-sprite.fainting, .player-sprite.fainting {
  animation: faintAnim 0.6s forwards;
}

@keyframes faintAnim {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(60px); opacity: 0; }
}

.enemy-info, .player-info {
  position: absolute;
  background: #f8f8e8;
  border: 3px solid #505050;
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 200px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.enemy-info { top: 8%; left: 5%; }
.player-info { bottom: 5%; right: 5%; }

.info-name {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: bold;
  color: #303030;
  margin-bottom: 4px;
}

.hp-bar-wrap {
  background: #505050;
  border-radius: 4px;
  padding: 2px;
  margin-bottom: 2px;
}

.hp-bar {
  height: 8px;
  background: #303030;
  border-radius: 3px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease-out;
}

.hp-high { background: #40c040; }
.hp-mid { background: #e0c020; }
.hp-low { background: #e04040; }

.hp-text {
  font-size: 12px;
  color: #505050;
  text-align: right;
}

.exp-bar-wrap {
  background: #303030;
  border-radius: 2px;
  height: 4px;
  margin-top: 4px;
  overflow: hidden;
}

.exp-fill {
  height: 100%;
  background: #40a0e0;
  transition: width 0.3s;
}

.battle-ui {
  height: 160px;
  background: #f8f8f0;
  border-top: 3px solid #404040;
  display: flex;
  position: relative;
}

.battle-text {
  flex: 1;
  padding: 16px 20px;
  font-size: 16px;
  color: #303030;
  line-height: 1.5;
}

.battle-menu {
  position: absolute;
  right: 8px; top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: #f8f8f0;
  border: 3px solid #404040;
  border-radius: 8px;
  padding: 8px;
}

.battle-menu-item {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: bold;
  color: #303030;
  cursor: pointer;
  border-radius: 4px;
  text-align: center;
}

.battle-menu-item:hover, .battle-menu-item.selected {
  background: #d0e8ff;
  color: #1a4a8a;
}

.move-menu {
  position: absolute;
  left: 8px; top: 8px; right: 8px; bottom: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: #f8f8f0;
  border: 3px solid #404040;
  border-radius: 8px;
  padding: 8px;
}

.move-item {
  padding: 8px 12px;
  font-size: 13px;
  color: #303030;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.move-item:hover, .move-item.selected {
  background: #d0e8ff;
}

.move-name { font-weight: bold; }
.move-pp { font-size: 11px; color: #707070; }
.move-type {
  font-size: 10px;
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px;
}

.bag-menu, .party-menu {
  position: absolute;
  left: 8px; top: 8px; right: 8px; bottom: 8px;
  background: #f8f8f0;
  border: 3px solid #404040;
  border-radius: 8px;
  padding: 8px;
  overflow-y: auto;
}

.bag-item, .party-item {
  padding: 8px 12px;
  font-size: 14px;
  color: #303030;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bag-item:hover, .party-item:hover { background: #d0e8ff; }
.bag-cancel, .party-cancel { color: #a04040; font-weight: bold; }
.bag-empty { padding: 16px; text-align: center; color: #808080; }

.party-item.fainted { opacity: 0.5; }
.party-info { display: flex; gap: 12px; }
.party-name { font-weight: bold; }
.party-level { color: #606060; }
.party-hp-bar {
  width: 80px; height: 6px;
  background: #303030;
  border-radius: 3px;
  overflow: hidden;
}
.party-hp-fill { height: 100%; border-radius: 3px; }
.party-hp-text { font-size: 11px; color: #606060; }

.pokeball-anim {
  position: absolute;
  top: 30%; left: 50%;
  font-size: 32px;
  color: #e04040;
  transform: translateX(-50%);
  z-index: 10;
}

.shake-left { animation: shakeL 0.4s; }
.shake-right { animation: shakeR 0.4s; }

@keyframes shakeL {
  0%, 100% { transform: translateX(-50%) rotate(0); }
  50% { transform: translateX(-70%) rotate(-20deg); }
}

@keyframes shakeR {
  0%, 100% { transform: translateX(-50%) rotate(0); }
  50% { transform: translateX(-30%) rotate(20deg); }
}

@media (max-width: 740px) {
  #game-container { width: 100vw; height: 73.3vw; }
  #game-canvas { width: 100%; height: 100%; }
}
