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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #062c43 0%, #034168 50%, #011e33 100%);
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* Game-Container */
#game-container {
  position: relative;
  width: 400px;
  height: 600px;
  max-width: 100vw;
  max-height: 100vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  overflow: hidden;
  background: #0a6b8a;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #1fa8c7 0%, #0f7a9c 45%, #053855 100%);
}

/* Overlays (Menüs) */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 32, 39, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
  animation: fadeIn 0.3s ease-out;
}

.overlay.hidden {
  display: none;
}

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

/* Arthur-Foto-Medaillon (Startscreen) */
.arthur-medallion {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: medallionFloat 4s ease-in-out infinite;
}

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

.medallion-glow {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(110, 200, 255, 0.55) 0%, rgba(110, 200, 255, 0) 70%);
  filter: blur(6px);
  animation: medallionPulse 3s ease-in-out infinite;
}

@keyframes medallionPulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.08); }
}

.medallion-photo {
  position: relative;
  z-index: 2;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #fff;
  box-shadow: 0 0 0 3px #2ea6d4, 0 8px 24px rgba(0, 0, 0, 0.5);
}

.medallion-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  z-index: 3;
  pointer-events: none;
  animation: ringSpin 18s linear infinite;
}

@keyframes ringSpin {
  to { transform: rotate(360deg); }
}

.medallion-bubbles {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.medallion-bubbles .bub {
  position: absolute;
  background: radial-gradient(circle at 30% 30%, #fff, rgba(180, 220, 255, 0.4) 60%, rgba(180, 220, 255, 0) 100%);
  border-radius: 50%;
  opacity: 0.85;
}

.medallion-bubbles .b1 {
  width: 10px; height: 10px;
  top: -6px; left: 18px;
  animation: bubbleRise 3.2s ease-in-out infinite;
}
.medallion-bubbles .b2 {
  width: 6px; height: 6px;
  top: 6px; right: 10px;
  animation: bubbleRise 2.6s ease-in-out 0.6s infinite;
}
.medallion-bubbles .b3 {
  width: 8px; height: 8px;
  bottom: 8px; left: -4px;
  animation: bubbleRise 3.6s ease-in-out 1.2s infinite;
}

@keyframes bubbleRise {
  0%   { transform: translateY(4px) scale(0.7); opacity: 0; }
  20%  { opacity: 0.9; }
  80%  { opacity: 0.7; }
  100% { transform: translateY(-22px) scale(1.1); opacity: 0; }
}

.medallion-caption {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #f4a261, #c77a0a);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 12px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  z-index: 5;
}

/* Typografie */
h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 8px;
  text-shadow: 0 4px 0 #f4a261, 0 6px 20px rgba(0,0,0,0.3);
  letter-spacing: 1px;
}

h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 20px;
  text-shadow: 0 3px 0 #f4a261;
}

.subtitle {
  font-size: 1rem;
  opacity: 0.85;
  margin-bottom: 32px;
}

/* Buttons */
.primary-btn, .secondary-btn {
  border: none;
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  margin: 6px 0;
  min-width: 220px;
  transition: transform 0.1s, box-shadow 0.1s;
  font-family: inherit;
}

.primary-btn {
  background: linear-gradient(180deg, #f4a261 0%, #e76f51 100%);
  color: white;
  box-shadow: 0 4px 0 #a84a2e, 0 6px 12px rgba(0,0,0,0.2);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #a84a2e, 0 8px 16px rgba(0,0,0,0.25);
}

.primary-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #a84a2e, 0 3px 6px rgba(0,0,0,0.2);
}

.secondary-btn {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 2px solid rgba(255,255,255,0.3);
}

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

/* Schwierigkeits-Auswahl */
.difficulty-select {
  margin-bottom: 24px;
  text-align: center;
}

.difficulty-select label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.9rem;
  opacity: 0.8;
}

.difficulty-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.diff-btn {
  padding: 10px 18px;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.08);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s;
  font-family: inherit;
}

.diff-btn:hover {
  background: rgba(255,255,255,0.15);
}

.diff-btn.active {
  background: linear-gradient(180deg, #f4a261 0%, #e76f51 100%);
  border-color: transparent;
  box-shadow: 0 3px 0 #a84a2e;
}

/* Controls-Hinweise */
.controls-hint {
  margin-top: 28px;
  font-size: 0.85rem;
  opacity: 0.7;
  text-align: center;
  line-height: 1.6;
}

/* Score-Summary (Game Over) */
.score-summary {
  background: rgba(0,0,0,0.3);
  padding: 20px 32px;
  border-radius: 12px;
  margin-bottom: 24px;
  min-width: 220px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 0;
  font-size: 1.1rem;
}

.score-row span:last-child {
  font-weight: 800;
  font-size: 1.4rem;
  color: #f4a261;
}

/* Credits */
.credits-box {
  background:
    radial-gradient(ellipse at top, rgba(79, 192, 255, 0.15), transparent 70%),
    linear-gradient(180deg, rgba(6, 44, 67, 0.8), rgba(1, 30, 51, 0.9));
  border: 1px solid rgba(255, 214, 130, 0.25);
  border-radius: 14px;
  padding: 24px 22px;
  margin-bottom: 22px;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), inset 0 0 30px rgba(79, 192, 255, 0.06);
}
.credits-box .credits-line {
  margin: 8px 0;
  line-height: 1.5;
}
.credits-box .credits-dev {
  display: block;
  font-size: 0.85rem;
  color: rgba(234, 244, 251, 0.65);
  font-style: italic;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}
.credits-box .credits-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffe3a0;
  text-shadow: 0 0 10px rgba(255, 214, 130, 0.4);
  letter-spacing: 0.02em;
}
.credits-box .credits-dots {
  color: rgba(79, 192, 255, 0.6);
  letter-spacing: 0.15em;
  font-weight: 700;
}
.credits-box .credits-for .credits-dots {
  color: rgba(255, 214, 130, 0.6);
  display: inline-block;
  margin: 0 4px;
}
.credits-box .credits-hero {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-top: 6px;
  background: linear-gradient(90deg, #ffd782 0%, #fff 50%, #ffd782 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(255, 214, 130, 0.55);
}
.credits-box .credits-sub {
  margin-top: 14px;
  font-size: 0.8rem;
  color: rgba(234, 244, 251, 0.55);
  font-style: italic;
}

.new-record {
  text-align: center;
  margin-top: 12px;
  padding: 8px;
  background: linear-gradient(90deg, #ffd700, #f4a261);
  color: #000;
  font-weight: 800;
  border-radius: 6px;
  animation: pulse 1s ease-in-out infinite;
}

.new-record.hidden {
  display: none;
}

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

/* HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px;
  z-index: 5;
  pointer-events: none;
}

#hud.hidden {
  display: none;
}

#score-display {
  font-size: 3rem;
  font-weight: 800;
  color: white;
  text-shadow: 0 4px 0 #a84a2e, 0 6px 16px rgba(0,0,0,0.4);
  flex: 1;
  text-align: center;
  margin-top: 8px;
}

.icon-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.4);
  color: white;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 2px;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: rgba(0,0,0,0.6);
}

/* Music-Toggle (global, oben links) */
.music-toggle {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s;
  font-family: inherit;
}

.music-toggle:hover {
  background: rgba(0,0,0,0.55);
}

.music-toggle.muted {
  opacity: 0.5;
  text-decoration: line-through;
}

/* Highscore-Liste */
.highscore-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.hs-tab {
  padding: 8px 16px;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: inherit;
}

.hs-tab.active {
  background: linear-gradient(180deg, #f4a261 0%, #e76f51 100%);
  border-color: transparent;
}

.highscore-list {
  list-style: none;
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
  padding: 16px 24px;
  min-width: 260px;
  margin-bottom: 20px;
}

.highscore-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 1rem;
}

.highscore-list li:last-child {
  border-bottom: none;
}

.highscore-list .rank {
  font-weight: 700;
  color: #f4a261;
  min-width: 32px;
}

.highscore-list .empty {
  opacity: 0.5;
  text-align: center;
  justify-content: center;
}

/* Responsiv für kleine Screens */
@media (max-width: 420px), (max-height: 620px) {
  #game-container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.6rem; }

  .primary-btn, .secondary-btn {
    min-width: 200px;
    padding: 12px 24px;
  }

  .arthur-medallion { width: 110px; height: 110px; margin-bottom: 10px; }
  .medallion-photo  { width: 100px; height: 100px; border-width: 3px; }
  .medallion-caption { font-size: 0.65rem; padding: 2px 10px; bottom: -10px; }
}
