/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #ff6b6b;
  --secondary-color: #4ecdc4;
  --accent-color: #ffe66d;
  --dark-color: #2d3047;
  --light-color: #ffffff;
  --shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  --border-radius: 20px;
}

body {
  font-family:
    "Segoe UI",
    -apple-system,
    BlinkMacSystemFont,
    "Roboto",
    "Helvetica Neue",
    Arial,
    sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-x: hidden;
}

/* Container */
.container {
  background: var(--light-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  max-width: 1200px;
  width: 100%;
  padding: 28px;
  position: relative;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 20px;
}

.title {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--primary-color);
  text-shadow: 3px 3px 0px var(--dark-color);
  letter-spacing: 1px;
  margin-bottom: 6px;
  animation: bounce 2s ease-in-out infinite;
}

.subtitle {
  font-size: 1.05rem;
  color: var(--dark-color);
  font-weight: 600;
}

/* Screen Management */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.5s ease-in-out;
}

/* Selection Screen */
.instruction {
  text-align: center;
  margin-bottom: 16px;
}

#instruction-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark-color);
  animation: pulse 2s ease-in-out infinite;
}

/* Map Container */
.map-container {
  max-width: 620px;
  margin: 0 auto;
}

/* Loading indicator */
.map-loading {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--dark-color);
  padding: 40px 0;
  animation: pulse 1.4s ease-in-out infinite;
}

/* Bundesländer group */
.states {
  filter: drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.18));
}

/* Individual state paths */
.state {
  stroke: #2d3047;
  stroke-width: 1.5;
  stroke-linejoin: round;
  transition: fill 0.2s ease;
}

.state:hover {
  fill: #ffd54f !important;
}

/* Invisible SVG before map loads */
#germany-map {
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* City pulse ring */
.city-pulse {
  fill: rgba(255, 107, 107, 0.18);
  stroke: var(--primary-color);
  stroke-width: 2;
  animation: cityRingPulse 2s ease-in-out infinite;
}

@keyframes cityRingPulse {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.75;
  }
}

/* Dim / locked states for city selection */
.city.dim {
  opacity: 0.35;
  transition: opacity 0.3s ease;
}

.city.locked {
  pointer-events: none;
}

/* Cities */
.city {
  cursor: pointer;
  transition: all 0.3s ease;
}

.city-dot {
  fill: var(--primary-color);
  stroke: var(--dark-color);
  stroke-width: 3;
  transition: all 0.3s ease;
}

.city:hover .city-dot {
  fill: var(--secondary-color);
  r: 25;
  animation: cityPulse 0.6s ease-in-out infinite;
}

.city.selected .city-dot {
  fill: var(--accent-color);
  stroke: var(--dark-color);
  stroke-width: 4;
  animation: citySelected 0.5s ease-in-out;
}

.city.disabled {
  pointer-events: none;
  opacity: 0.3;
}

.city-label {
  fill: var(--dark-color);
  font-size: 14px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

/* Battle Screen */
.battle-header {
  text-align: center;
  margin-bottom: 24px;
}

#battle-title {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--primary-color);
  text-shadow: 3px 3px 0px var(--dark-color);
}

/* Thermometers */
.thermometers {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  gap: 32px;
  margin: 24px auto;
  max-width: 900px;
}

.thermometer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.city-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--dark-color);
  margin-bottom: 12px;
  text-align: center;
  text-shadow: 2px 2px 0px var(--accent-color);
}

.thermometer {
  position: relative;
  width: 70px;
  height: 300px;
  margin: 10px 0;
}

.thermometer-bulb {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 50px;
  background: var(--primary-color);
  border-radius: 50%;
  border: 5px solid var(--dark-color);
  box-shadow: inset 0 -10px 20px rgba(0, 0, 0, 0.3);
  z-index: 2;
}

.thermometer-tube {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 252px;
  background: rgba(255, 255, 255, 0.9);
  border: 5px solid var(--dark-color);
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.1);
}

.thermometer-mercury {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, var(--primary-color), #ff8e53);
  border-radius: 0 0 15px 15px;
  transition: height 2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
}

.thermometer-scale {
  position: absolute;
  right: -52px;
  top: 0;
  height: 100%;
}

.scale-mark {
  position: absolute;
  width: 100%;
  display: flex;
  align-items: center;
}

.scale-mark::before {
  content: "";
  width: 15px;
  height: 3px;
  background: var(--dark-color);
  margin-right: 5px;
}

.scale-mark span {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark-color);
}

.temperature-display {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--primary-color);
  text-shadow: 2px 2px 0px var(--dark-color);
  margin-top: 12px;
}

/* VS Container */
.vs-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.vs {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--dark-color);
  text-shadow: 3px 3px 0px var(--accent-color);
  animation: rotate 3s ease-in-out infinite;
}

/* Winner Announcement */
.winner-announcement {
  text-align: center;
  margin: 24px 0;
  position: relative;
}

.winner-announcement.hidden {
  display: none;
}

.winner-text {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--secondary-color);
  text-shadow: 4px 4px 0px var(--dark-color);
  animation: winnerBounce 0.8s ease-in-out;
}

.confetti {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
}

.confetti::before,
.confetti::after {
  content: "🎉";
  position: absolute;
  font-size: 3rem;
  animation: confettiFall 2s ease-in-out infinite;
}

.confetti::before {
  left: 20%;
  animation-delay: 0.2s;
}

.confetti::after {
  right: 20%;
  animation-delay: 0.5s;
}

/* Winner / loser thermometer states */
.thermometer-container.winner {
  transform: scale(1.06);
  transition: transform 0.5s ease;
}

.thermometer-container.winner .city-name {
  color: var(--secondary-color);
}

.thermometer-container.loser {
  opacity: 0.55;
  transition: opacity 0.5s ease;
}

/* Restart Button */
.restart-btn {
  display: block;
  margin: 20px auto 0;
  padding: 14px 36px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--light-color);
  background: var(--primary-color);
  border: 5px solid var(--dark-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  box-shadow: 5px 5px 0px var(--dark-color);
  transition: all 0.2s ease;
}

.restart-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 3px 3px 0px var(--dark-color);
}

.restart-btn:active {
  transform: translate(5px, 5px);
  box-shadow: 0px 0px 0px var(--dark-color);
}

.restart-btn.hidden {
  display: none;
}

/* Animations */
@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

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

@keyframes citySelected {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.5);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

@keyframes winnerBounce {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes confettiFall {
  0% {
    transform: translateY(-100px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(400px) rotate(360deg);
    opacity: 0;
  }
}

/* ─── Tablet (≤ 768px) ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .container {
    padding: 20px;
  }

  .title {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  #instruction-text {
    font-size: 1.25rem;
  }

  .thermometers {
    gap: 20px;
    margin: 16px auto;
  }

  .thermometer {
    height: 260px;
  }

  .thermometer-tube {
    height: 212px;
  }

  #battle-title {
    font-size: 1.8rem;
  }

  .city-name {
    font-size: 1.25rem;
  }

  .temperature-display {
    font-size: 1.8rem;
  }

  .restart-btn {
    font-size: 1.1rem;
    padding: 12px 28px;
  }
}

/* ─── Mobile / Smartphone (≤ 480px) ─────────────────────────────────────────── */
@media (max-width: 480px) {
  body {
    padding: 8px;
    align-items: flex-start;
  }

  .container {
    padding: 14px 12px;
    border-radius: 14px;
  }

  header {
    margin-bottom: 10px;
  }

  .title {
    font-size: 1.6rem;
    letter-spacing: 0;
  }

  .subtitle {
    font-size: 0.8rem;
  }

  .instruction {
    margin-bottom: 10px;
  }

  #instruction-text {
    font-size: 1rem;
  }

  .map-container {
    max-width: 100%;
  }

  .city-label {
    font-size: 11px;
  }

  /* Battle screen */
  .battle-header {
    margin-bottom: 12px;
  }

  #battle-title {
    font-size: 1.4rem;
  }

  /* Keep thermometers side-by-side on phones */
  .thermometers {
    gap: 6px;
    margin: 10px auto;
    align-items: flex-end;
  }

  .thermometer-container {
    flex: 1;
  }

  .city-name {
    font-size: 0.9rem;
    margin-bottom: 6px;
  }

  .thermometer {
    width: 50px;
    height: 180px;
    margin: 6px 0;
  }

  .thermometer-tube {
    width: 24px;
    height: 140px;
    bottom: 20px;
  }

  .thermometer-bulb {
    width: 36px;
    height: 36px;
    bottom: -14px;
    border-width: 4px;
  }

  .thermometer-scale {
    right: -38px;
  }

  .scale-mark::before {
    width: 10px;
  }

  .scale-mark {
    font-size: 10px;
  }

  .temperature-display {
    font-size: 1.35rem;
    margin-top: 8px;
    text-shadow: 1px 1px 0px var(--dark-color);
  }

  .vs {
    font-size: 1.6rem;
  }

  .winner-announcement {
    margin: 14px 0;
  }

  .winner-text {
    font-size: 1.4rem;
    text-shadow: 2px 2px 0px var(--dark-color);
  }

  .restart-btn {
    font-size: 0.95rem;
    padding: 10px 20px;
    margin-top: 14px;
    border-width: 3px;
    box-shadow: 3px 3px 0px var(--dark-color);
  }
}
