:root {
  --coral: #f18d72;
  --coral-dark: #e07a5f;
  --coral-light: #fde8e2;
  --text: #333333;
  --text-light: #666666;
  --white: #ffffff;
  --green: #4caf50;
  --red: #e53935;
  --shadow: 0 8px 32px rgba(241, 141, 114, 0.25);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, var(--white) 0%, var(--coral-light) 100%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 8px;
}

#game-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: calc(100vh - 16px);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--white);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  z-index: 10;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-logo {
  width: 80px;
  height: 80px;
  border-radius: 0px;
  margin-bottom: 12px;
  object-fit: cover;
}

.overlay-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--coral);
  margin-bottom: 4px;
  line-height: 1.2;
}

.overlay-subtitle {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 20px;
  line-height: 1.4;
}

.overlay-record {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 16px;
  font-weight: 600;
}

.overlay-record span {
  color: var(--coral);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 36px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  background: var(--coral);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  min-width: 180px;
}

.btn:hover {
  background: var(--coral-dark);
  transform: scale(1.03);
}

.btn:active {
  transform: scale(0.97);
}

.btn-secondary {
  background: transparent;
  color: var(--coral);
  border: 2px solid var(--coral);
  margin-top: 12px;
  font-size: 0.95rem;
  padding: 10px 24px;
  min-width: auto;
}

.btn-secondary:hover {
  background: var(--coral-light);
}

.overlay-instructions {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.5;
}

.overlay-score {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--coral);
  margin-bottom: 4px;
}

.overlay-rank {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.overlay-message {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 20px;
  font-style: italic;
}

.overlay-new-record {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 12px;
  animation: pulse 0.6s ease infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.7; transform: scale(1); }
  to { opacity: 1; transform: scale(1.05); }
}

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

.hud-block {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  backdrop-filter: blur(4px);
}

.hud-score {
  color: var(--coral);
  font-size: 1rem;
}

.hud-lives {
  letter-spacing: 2px;
}

.hud-combo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--coral);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-shadow: 0 2px 8px rgba(241, 141, 114, 0.4);
  pointer-events: none;
}

.hud-combo.visible {
  opacity: 1;
  transform: translate(-50%, -60%) scale(1.1);
}

.flash-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.flash-overlay.green {
  background: rgba(76, 175, 80, 0.25);
}

.flash-overlay.red {
  background: rgba(229, 57, 53, 0.25);
}

.flash-overlay.active {
  opacity: 1;
}
