/* ================================================
   DEVIL REVENGE — Stylesheet
   1930s dark carnival / underworld theme
   ================================================ */

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

body {
  background: #0a0005;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bangers', cursive;
}

/* --- Game wrapper: fixed 800×500 logical size, scaled by JS transform --- */
#game-wrap {
  position: fixed;
  top: 0;      /* JS will override; defaults keep layout stable before JS runs */
  left: 0;
  width: 800px;
  height: 500px;
  transform-origin: top left;
}

/* --- Canvas fills the wrapper exactly --- */
#gameCanvas {
  position: absolute;
  top: 0; left: 0;
  width: 800px;
  height: 500px;
  display: block;
}

/* --- UI overlay sits above canvas inside the same wrapper --- */
#ui {
  position: absolute;
  top: 0; left: 0;
  width: 800px;
  height: 500px;
  pointer-events: none;
  z-index: 10;
}

/* --- Screens --- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  pointer-events: none;
}
.screen.active {
  display: flex;
  pointer-events: auto;
}

/* ===================== MAIN MENU ===================== */

.menu-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,0.85);
  border: 3px solid #c8860a;
  border-radius: 8px;
  padding: 32px 48px;
  box-shadow: 0 0 40px rgba(200,134,10,0.4), 0 0 80px rgba(200,0,0,0.2);
  max-width: 520px;
  width: 90vw;
}

.deco-row {
  font-size: 28px;
  letter-spacing: 12px;
  animation: flicker 2s infinite;
}

.game-title {
  font-family: 'Bangers', cursive;
  font-size: clamp(48px, 8vw, 80px);
  line-height: 0.9;
  text-align: center;
  text-shadow: 4px 4px 0 #000, 6px 6px 0 rgba(0,0,0,0.5);
  letter-spacing: 4px;
}

.t-red   { color: #ff3322; }
.t-gold  { color: #ffd700; }
.t-purple{ color: #bb44ff; }

.subtitle {
  font-family: 'Bangers', cursive;
  font-size: 17px;
  color: #c8a050;
  letter-spacing: 3px;
}

.lore-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #aaa;
  text-align: center;
  line-height: 1.9;
}

/* --- Buttons --- */
.big-btn {
  font-family: 'Bangers', cursive;
  font-size: 28px;
  letter-spacing: 3px;
  padding: 12px 40px;
  border: 3px solid #ffd700;
  border-radius: 6px;
  background: linear-gradient(180deg, #cc2200, #880000);
  color: #ffd700;
  cursor: pointer;
  box-shadow: 4px 4px 0 #000, 0 0 16px rgba(255,50,0,0.4);
  transition: transform 0.1s, box-shadow 0.1s;
}
.big-btn:hover  { transform: scale(1.04); box-shadow: 4px 4px 0 #000, 0 0 30px rgba(255,100,0,0.7); }
.big-btn:active { transform: scale(0.97); }

.red-big   { background: linear-gradient(180deg, #cc2200, #880000); }
.gold-big  { background: linear-gradient(180deg, #c8860a, #7a5200); border-color: #fff; color: #fff; }

.pulse { animation: pulse-glow 1.5s ease-in-out infinite; }
@keyframes pulse-glow {
  0%,100% { box-shadow: 4px 4px 0 #000, 0 0 16px rgba(255,50,0,0.4); }
  50%      { box-shadow: 4px 4px 0 #000, 0 0 40px rgba(255,100,0,0.9); }
}

.key-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #666;
}

kbd {
  background: #333; border: 1px solid #666; border-radius: 3px;
  padding: 1px 5px; font-size: 7px; color: #ccc;
}

.level-row {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #888;
}

/* ===================== CHARACTER SELECT ===================== */

.sec-title {
  font-family: 'Bangers', cursive;
  font-size: 40px;
  color: #ffd700;
  text-shadow: 3px 3px 0 #000;
  letter-spacing: 4px;
  margin-bottom: 16px;
}

.char-row {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.char-card {
  background: rgba(0,0,0,0.85);
  border: 3px solid rgba(255,215,0,0.3);
  border-radius: 8px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 230px;
  transition: border-color 0.2s, transform 0.2s;
  cursor: pointer;
}
.char-card:hover {
  border-color: #ffd700;
  transform: translateY(-4px);
}

.char-card canvas { border-radius: 6px; background: rgba(255,255,255,0.04); }

.char-name {
  font-family: 'Bangers', cursive;
  font-size: 26px;
  letter-spacing: 3px;
}

.stat { display: flex; align-items: center; gap: 8px; width: 100%; font-family: 'Press Start 2P', monospace; font-size: 7px; color: #888; }
.bar  { flex: 1; height: 9px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; border: 1px solid rgba(255,255,255,0.15); }
.f    { height: 100%; border-radius: 4px; }

.char-bio {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #777;
  text-align: center;
  line-height: 1.7;
}

.pick-btn {
  font-family: 'Bangers', cursive;
  font-size: 20px;
  letter-spacing: 2px;
  padding: 8px 20px;
  border-radius: 5px;
  border: 2px solid #ffd700;
  cursor: pointer;
  box-shadow: 3px 3px 0 #000;
  transition: transform 0.1s;
}
.pick-btn:hover { transform: scale(1.05); }
.red-btn    { background: linear-gradient(180deg,#cc2200,#880000); color: #ffd700; }
.purple-btn { background: linear-gradient(180deg,#7700cc,#440088); color: #ffd700; }

.vs-circle {
  font-family: 'Bangers', cursive;
  font-size: 32px;
  color: #ffd700;
  background: rgba(0,0,0,0.6);
  border: 3px solid #ffd700;
  border-radius: 50%;
  width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 20px rgba(255,215,0,0.4);
}

.back-btn {
  margin-top: 16px;
  font-family: 'Bangers', cursive;
  font-size: 18px;
  letter-spacing: 2px;
  padding: 6px 18px;
  background: transparent;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.2s;
}
.back-btn:hover { border-color: white; color: white; }

/* ===================== HUD ===================== */

#screen-hud { flex-direction: row; align-items: flex-start; justify-content: space-between; padding: 10px 16px; pointer-events: none; }

.hud-left, .hud-right {
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(0,0,0,0.6);
  border: 2px solid rgba(255,215,0,0.3);
  border-radius: 6px;
  padding: 8px 12px;
  min-width: 200px;
}

.hud-label {
  font-family: 'Bangers', cursive;
  font-size: 16px;
  color: #ffd700;
  letter-spacing: 2px;
}
.boss-label { color: #ff8844; }

.hpbar-wrap { width: 100%; }
.hpbar-bg {
  width: 100%; height: 14px;
  background: rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 4px; overflow: hidden;
}
.hpbar-fill {
  height: 100%; transition: width 0.2s; border-radius: 2px;
}
.red-fill  { background: linear-gradient(90deg, #cc2200, #ff5533); }
.gold-fill { background: linear-gradient(90deg, #c8860a, #ffd700); }

.lives-row { font-size: 14px; }
.phase-tag {
  font-family: 'Press Start 2P', monospace; font-size: 7px; color: #888;
}

.hud-mid {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: none;
}
.level-tag {
  font-family: 'Bangers', cursive; font-size: 22px;
  color: white; letter-spacing: 3px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
}
.score-tag {
  font-family: 'Bangers', cursive; font-size: 18px; color: #ffd700;
}

.controls-tip {
  position: absolute;
  bottom: 16px; left: 50%; transform: translateX(-50%);
  font-family: 'Press Start 2P', monospace; font-size: 8px; color: rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.5); padding: 6px 14px; border-radius: 4px;
  animation: fade-out 5s forwards;
}
@keyframes fade-out { 0%,60%{opacity:1} 100%{opacity:0} }

/* ===================== RESULT SCREENS ===================== */

.result-box {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: rgba(0,0,0,0.88);
  border: 4px solid rgba(255,215,0,0.5);
  border-radius: 10px;
  padding: 40px 56px;
  min-width: 380px;
  text-align: center;
  box-shadow: 0 0 40px rgba(255,215,0,0.3), 0 0 80px rgba(0,0,0,0.8);
}
.dark-box { border-color: rgba(255,50,0,0.5); box-shadow: 0 0 40px rgba(255,50,0,0.3); }
.gold-box  { border-color: #ffd700; box-shadow: 0 0 60px rgba(255,215,0,0.6); }

.big-icon { font-size: 64px; animation: bob 2s ease-in-out infinite; }
.spin-icon { animation: spin 3s linear infinite; }
@keyframes bob  { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
@keyframes spin { from{transform:rotate(0)} to{transform:rotate(360deg)} }

.result-title {
  font-family: 'Bangers', cursive; font-size: 52px; letter-spacing: 4px;
  text-shadow: 4px 4px 0 rgba(0,0,0,0.5);
}
.result-boss {
  font-family: 'Bangers', cursive; font-size: 22px; color: #ff8844; letter-spacing: 3px;
}
.pts-earned {
  font-family: 'Bangers', cursive; font-size: 28px; color: #ffd700;
}
.result-sub {
  font-family: 'Press Start 2P', monospace; font-size: 8px; color: #888; line-height: 1.7;
}

.go-quote { font-family: 'Press Start 2P', monospace; font-size: 8px; color: #cc4433; line-height: 1.8; }
.go-stats { font-family: 'Bangers', cursive; font-size: 20px; color: #aaa; display:flex;flex-direction:column;gap:4px; }
.go-btns  { display:flex;flex-direction:column;gap:8px;align-items:center; }

.victory-text { font-family: 'Press Start 2P', monospace; font-size: 8px; color: #ccc; line-height: 1.9; }
.stars   { font-size: 36px; letter-spacing: 8px; animation: star-pulse 1s ease-in-out infinite alternate; }
@keyframes star-pulse { from{transform:scale(1)} to{transform:scale(1.15)} }
.final-score { font-family: 'Bangers', cursive; font-size: 24px; color: #ffd700; letter-spacing: 3px; }

/* ===================== MISC ===================== */
@keyframes flicker { 0%,100%{opacity:1} 50%{opacity:0.7} 92%{opacity:0.5} 94%{opacity:1} }

/* ===================== TOUCH CONTROLS ===================== */
#touch-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 16px 20px;
  pointer-events: none;
}

#touch-left-pad {
  display: flex;
  gap: 6px;
  align-items: center;
  pointer-events: auto;
}

#touch-right-pad {
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: auto;
}

.touch-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid rgba(255,215,0,0.6);
  background: rgba(0,0,0,0.55);
  color: #ffd700;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: background 0.08s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn:active,
.touch-btn.pressed {
  background: rgba(200,134,10,0.5);
  transform: scale(0.92);
}

.touch-jump {
  width: 76px;
  height: 76px;
  background: rgba(0,80,160,0.55);
  border-color: rgba(100,180,255,0.7);
  color: #88ddff;
  font-size: 28px;
}

.touch-shoot {
  width: 84px;
  height: 84px;
  background: rgba(160,20,0,0.6);
  border-color: rgba(255,80,0,0.8);
  font-size: 32px;
  box-shadow: 0 4px 16px rgba(255,80,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}

/* Hide controls tip on touch devices */
@media (pointer: coarse) {
  #ctrls { display: none !important; }
}

/* On desktop hide touch controls */
@media (pointer: fine) {
  #touch-controls { display: none !important; }
}

/* Responsive HUD for small screens */
@media (max-width: 600px) {
  .hud-left, .hud-right { min-width: 120px; padding: 6px 8px; }
  .hud-label { font-size: 12px; }
  .hpbar-bg  { height: 10px; }
  .hud-mid   { display: none; }
  #screen-hud { padding: 6px 8px; }
  .char-row  { flex-direction: column; gap: 12px; }
  .vs-circle { display: none; }
  .char-card { width: 90vw; max-width: 340px; }
  .result-box { padding: 24px 20px; min-width: 0; width: 90vw; }
  .howto-grid { grid-template-columns: 1fr; }
  .boss-list  { grid-template-columns: 1fr; }
  .menu-inner { padding: 24px 20px; }
}

/* ===================== MENU BUTTONS ===================== */
.menu-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.outline-btn {
  background: transparent !important;
  border-color: rgba(255,215,0,0.4) !important;
  color: rgba(255,215,0,0.7) !important;
  font-size: 22px !important;
  padding: 10px 40px !important;
}
.outline-btn:hover {
  border-color: #ffd700 !important;
  color: #ffd700 !important;
  background: rgba(255,215,0,0.05) !important;
}

/* ===================== HOW TO PLAY ===================== */
#screen-howto {
  overflow-y: auto;
  padding: 20px;
}

.howto-box {
  background: rgba(0,0,0,0.92);
  border: 3px solid #c8860a;
  border-radius: 10px;
  padding: 28px 36px;
  max-width: 720px;
  width: 95vw;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 0 50px rgba(200,134,10,0.35), 0 0 100px rgba(200,0,0,0.15);
}

.howto-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.howto-section {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,215,0,0.15);
  border-radius: 7px;
  padding: 14px 16px;
}

.howto-heading {
  font-family: 'Bangers', cursive;
  font-size: 22px;
  color: #ffd700;
  letter-spacing: 3px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255,215,0,0.2);
  padding-bottom: 4px;
}

.ctrl-table { display: flex; flex-direction: column; gap: 6px; }
.ctrl-row   { display: flex; align-items: center; gap: 10px; }
.ctrl-key   {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  padding: 3px 7px;
  color: #ffd700;
  white-space: nowrap;
  min-width: 90px;
  text-align: center;
}
.ctrl-desc  {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #aaa;
}

.howto-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
}
.howto-list li {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #aaa;
  line-height: 1.7;
  padding-left: 12px;
  position: relative;
}
.howto-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: #cc2200;
}
.howto-list li b { color: #ffd700; }

.char-tips { display: flex; flex-direction: column; gap: 10px; }
.char-tip   {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: rgba(255,255,255,0.03);
  border-radius: 5px;
}
.char-tip span {
  font-family: 'Bangers', cursive;
  font-size: 18px;
  letter-spacing: 2px;
}
.char-tip p {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #888;
  line-height: 1.6;
}

.howto-bosses {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,215,0,0.15);
  border-radius: 7px;
  padding: 14px 16px;
}

.boss-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.boss-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.boss-num {
  font-family: 'Bangers', cursive;
  font-size: 28px;
  color: #cc2200;
  line-height: 1;
  min-width: 20px;
}

.boss-entry b {
  font-family: 'Bangers', cursive;
  font-size: 17px;
  letter-spacing: 1px;
}

.boss-entry small {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: #777;
  line-height: 1.7;
  display: block;
  margin-top: 2px;
}
