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

body {
  background: #0a0a1a;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#game {
  width: 800px;
  height: 560px;
  display: flex;
  flex-direction: column;
  border: 2px solid #333;
  border-radius: 8px;
  background: #111122;
  position: relative;
}

/* Header */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid #333;
  font-size: 16px;
}

#round-label { color: #888; }

.score {
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-label { color: #aaa; font-size: 14px; }

.pip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #555;
  display: inline-block;
}

.pip.filled { background: #f0c040; border-color: #f0c040; }

/* Arena */
#arena {
  flex: 1;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 20px;
  position: relative;
}

.player-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 160px;
  position: relative;
}

.avatar {
  width: 80px;
  height: 100px;
  border: 3px solid #444;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  background: #1a1a2e;
  transition: background 0.1s;
}

.player-col.attacker .avatar { border-color: #e04040; }
.player-col.defender .avatar { border-color: #4080e0; }

.player-col.attacker { box-shadow: 0 0 20px rgba(224, 64, 64, 0.4); }
.player-col.defender { box-shadow: 0 0 20px rgba(64, 128, 224, 0.4); }
.player-col.inactive { opacity: 0.4; transition: opacity 0.3s; }
.spell-panel.inactive { opacity: 0.4; transition: opacity 0.3s; }

.player-name { font-size: 14px; color: #aaa; }
.player-role { font-size: 12px; font-weight: bold; text-transform: uppercase; }
.player-col.attacker .player-role { color: #e04040; }
.player-col.defender .player-role { color: #4080e0; }

/* Centre area */
#centre {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  text-align: center;
}

#spell-banner {
  font-size: 32px;
  font-weight: bold;
  color: #f0c040;
  min-height: 40px;
  letter-spacing: 2px;
}

#phase-label {
  font-size: 18px;
  color: #ccc;
}

#countdown-container {
  width: 200px;
  height: 16px;
  background: #222;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #444;
}

#countdown-bar {
  height: 100%;
  width: 100%;
  background: #40c040;
  border-radius: 8px;
  transition: background-color 0.3s;
}

#countdown-text {
  font-size: 14px;
  color: #888;
  min-height: 20px;
}

/* Outcome overlay */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#overlay.visible { opacity: 1; pointer-events: auto; }

#overlay-text {
  font-size: 48px;
  font-weight: bold;
}

#overlay-sub {
  font-size: 18px;
  color: #aaa;
  margin-top: 8px;
}

/* Spell Panels */
#spell-panels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid #333;
  font-size: 15px;
  position: relative;
  z-index: 15;
}

.spell-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spell-slot {
  padding: 4px 10px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #1a1a2e;
  color: #ccc;
  transition: background 0.3s, border-color 0.3s;
}

.spell-slot .key {
  color: #f0c040;
  font-weight: bold;
}

.spell-slot.chaos {
  background: #1a0a2e;
  border-color: #8040c0;
  color: #c090ff;
}

.spell-slot.active {
  border-color: #f0c040;
  background: #2a2a1e;
}

#spell-info {
  font-size: 12px;
  color: #666;
  text-align: center;
  max-width: 200px;
}

/* Morph feedback */
.spell-slot .morph-label {
  font-size: 14px;
  font-weight: bold;
  margin-left: 6px;
  animation: morph-fade 1.5s ease-out forwards;
}

.morph-label.degrade { color: #e04040; }
.morph-label.restore { color: #40e040; }

@keyframes morph-fade {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes morph-flash-red {
  0% { background: #3a1020; border-color: #e04040; }
  100% { background: #1a1a2e; }
}

@keyframes morph-flash-green {
  0% { background: #103a20; border-color: #40e040; }
  100% { background: #1a1a2e; }
}

.spell-slot.morph-degrade { animation: morph-flash-red 1.5s ease-out; }
.spell-slot.morph-restore { animation: morph-flash-green 1.5s ease-out; }
.spell-slot.chaos.morph-degrade { animation: morph-flash-red 1.5s ease-out; }
.spell-slot.chaos.morph-restore { animation: morph-flash-green 1.5s ease-out; }

/* Backfire & fizzle */
.fizzle-label, .backfire-label {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: bold;
  white-space: nowrap;
  animation: float-up 0.8s ease-out forwards;
  pointer-events: none;
  z-index: 16;
}

.fizzle-label { color: #888; }
.fizzle-label.warning { color: #e0a020; }
.backfire-label { color: #e04040; font-size: 16px; }

@keyframes float-up {
  0% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-30px); }
}

@keyframes flash-backfire {
  0% { box-shadow: 0 0 30px rgba(224, 64, 64, 0.8); }
  100% { box-shadow: none; }
}

.player-col.flash-backfire { animation: flash-backfire 0.6s ease-out; }

/* Commitment ceremony */
@keyframes flash-commit {
  0% { box-shadow: 0 0 25px rgba(240, 192, 64, 0.8); }
  100% { box-shadow: none; }
}

.player-col.flash-commit { animation: flash-commit 0.3s ease-out; }

.commit-label {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: bold;
  color: #f0c040;
  white-space: nowrap;
  animation: float-up 0.5s ease-out forwards;
  pointer-events: none;
  z-index: 16;
}

/* Pip shatter */
@keyframes pip-shatter {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.5; }
  100% { transform: scale(0); opacity: 0; }
}

.pip.shatter { animation: pip-shatter 0.4s ease-out forwards; }

@keyframes flash-column-red {
  0% { background: rgba(224, 64, 64, 0.2); }
  100% { background: transparent; }
}

.player-col.flash-hit { animation: flash-column-red 0.5s ease-out; }

/* Hit flash animation */
@keyframes flash-red {
  0% { background: #e04040; }
  100% { background: #1a1a2e; }
}

.avatar.flash { animation: flash-red 0.4s ease-out; }

/* Instruction bar */
#instruction-bar {
  text-align: center;
  padding: 8px 16px;
  font-size: 16px;
  color: #ccc;
  border-top: 1px solid #333;
  min-height: 36px;
  position: relative;
  z-index: 15;
}

/* RPS Legend */
#rps-legend {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 11px;
  color: #555;
  z-index: 15;
}

/* Paused overlay */
#paused {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 20;
  font-size: 36px;
  color: #f0c040;
  letter-spacing: 4px;
}

#paused.visible { display: flex; }
