* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #1a0e2e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'Lilita One', 'Bungee', sans-serif;
  overflow: hidden;
  user-select: none;
}

#game-wrapper {
  position: relative;
  width: 100%;
  max-width: 450px;
  aspect-ratio: 9/16;
  max-height: 95vh;
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

#top-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
  pointer-events: auto;
}

#timer {
  font-family: 'Bungee', sans-serif;
  font-size: 24px;
  color: #ffd700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8), 0 0 10px rgba(255,215,0,0.3);
  background: linear-gradient(180deg, #3d2200, #1a0e00);
  border: 2px solid #ffd700;
  border-radius: 8px;
  padding: 2px 16px;
  min-width: 80px;
  text-align: center;
}

.crown-display {
  font-size: 18px;
  color: #ffd700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.crown-display span {
  font-family: 'Bungee', sans-serif;
  font-size: 20px;
}

#double-elixir-banner {
  text-align: center;
  font-family: 'Bungee', sans-serif;
  font-size: 14px;
  color: #ff4ecf;
  text-shadow: 0 0 10px #ff4ecf;
  animation: pulse 1s ease-in-out infinite;
  padding: 2px;
}

#double-elixir-banner.hidden {
  display: none;
}

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

#bottom-bar {
  pointer-events: auto;
  background: linear-gradient(0deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.6) 70%, transparent 100%);
  padding: 4px 6px 6px;
}

#elixir-container {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  padding: 0 4px;
}

#elixir-bar-bg {
  flex: 1;
  height: 16px;
  background: #2a0a3a;
  border-radius: 8px;
  border: 2px solid #6b3fa0;
  overflow: hidden;
  position: relative;
}

#elixir-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(180deg, #e94ecf, #a020f0, #7b18b5);
  border-radius: 6px;
  transition: width 0.15s linear;
  position: relative;
  box-shadow: 0 0 8px rgba(233, 78, 207, 0.6);
}

#elixir-count {
  font-family: 'Bungee', sans-serif;
  font-size: 20px;
  color: #e94ecf;
  text-shadow: 0 0 8px rgba(233, 78, 207, 0.6);
  min-width: 28px;
  text-align: center;
}

#card-hand {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
}

#next-card-label {
  font-size: 8px;
  color: #aaa;
  text-align: center;
  position: absolute;
  top: -12px;
  width: 100%;
}

#next-card {
  position: relative;
  width: 48px;
  height: 62px;
  font-size: 10px;
  opacity: 0.6;
  margin-right: 4px;
}

#cards-container {
  display: flex;
  gap: 4px;
}

.card {
  width: 68px;
  height: 85px;
  background: linear-gradient(180deg, #f5e6c8, #d4b98a);
  border: 2px solid #8b6914;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  box-shadow: 0 3px 6px rgba(0,0,0,0.4);
}

.card:active {
  transform: scale(0.95);
}

.card.affordable {
  border-color: #ffd700;
  box-shadow: 0 0 12px rgba(255,215,0,0.5), 0 3px 6px rgba(0,0,0,0.4);
}

.card.selected {
  border-color: #00ff88;
  box-shadow: 0 0 16px rgba(0,255,136,0.7), 0 3px 6px rgba(0,0,0,0.4);
  transform: translateY(-4px);
}

.card.unaffordable {
  opacity: 0.5;
  filter: grayscale(0.4);
}

.card-icon {
  font-size: 24px;
  line-height: 1;
}

.card-name {
  font-size: 8px;
  color: #3d2200;
  margin-top: 2px;
  font-family: 'Lilita One', sans-serif;
  text-align: center;
  line-height: 1.1;
}

.card-cost {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: linear-gradient(180deg, #e94ecf, #a020f0);
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-family: 'Bungee', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

#result-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.75);
  z-index: 10;
}

#result-screen.hidden {
  display: none;
}

#result-box {
  background: linear-gradient(180deg, #2d1b4e, #1a0e2e);
  border: 3px solid #ffd700;
  border-radius: 16px;
  padding: 30px 40px;
  text-align: center;
  box-shadow: 0 0 40px rgba(255,215,0,0.3);
}

#result-title {
  font-family: 'Bungee Shade', sans-serif;
  font-size: 28px;
  color: #ffd700;
  margin-bottom: 12px;
  text-shadow: 0 0 20px rgba(255,215,0,0.5);
}

#result-crowns {
  font-size: 24px;
  color: #fff;
  margin-bottom: 20px;
}

#play-again-btn {
  font-family: 'Lilita One', sans-serif;
  font-size: 20px;
  background: linear-gradient(180deg, #ffd700, #e6a800);
  color: #3d2200;
  border: none;
  border-radius: 12px;
  padding: 12px 32px;
  cursor: pointer;
  transition: transform 0.1s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

#play-again-btn:hover {
  transform: scale(1.05);
}

#play-again-btn:active {
  transform: scale(0.95);
}

footer {
  color: #666;
  font-size: 12px;
  padding: 8px;
  font-family: 'Lilita One', sans-serif;
}

footer a {
  color: #ffd700;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  #game-wrapper {
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  #canvas {
    border-radius: 0;
  }
  .card {
    width: 60px;
    height: 76px;
  }
  #next-card {
    width: 42px;
    height: 54px;
  }
  .card-icon {
    font-size: 20px;
  }
  #timer {
    font-size: 18px;
  }
}