:root {
  --bg-dark: #0d1117;
  --bg-light: #161b22;
  --game-bg: #0f1419;
  --accent: #00d4ff;
  --accent2: #ff6b6b;
  --text-primary: #e0e0e0;
  --text-secondary: #888;
  --border: #333;
  --success: #51cf66;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-dark: #f5f7fa;
    --bg-light: #eff2f7;
    --game-bg: #ffffff;
    --accent: #0099cc;
    --accent2: #d63031;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --border: #ddd;
    --success: #2f9e44;
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-light) 100%);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

#app {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: max(env(safe-area-inset-top), 0.5rem) max(env(safe-area-inset-right), 0.5rem) max(env(safe-area-inset-bottom), 0.5rem) max(env(safe-area-inset-left), 0.5rem);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  gap: 1rem;
}

h1 {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 0;
  text-shadow: 0 2px 10px rgba(0, 212, 255, 0.3);
}

#back-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s;
}

#back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

#menu-screen, #game-screen, #game-over-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  gap: 2rem;
}

#game-screen {
  display: none;
}

#game-over-screen {
  display: none;
}

.menu-card {
  background: linear-gradient(135deg, rgba(22, 27, 34, 0.98), rgba(13, 17, 23, 0.98));
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.menu-card h2 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  color: var(--accent);
}

.difficulty-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.5rem 0;
}

.btn {
  padding: 1rem;
  border: 0;
  border-radius: 0.5rem;
  font-weight: 900;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent), #0099cc);
  color: #000;
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 212, 255, 0.35);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-primary);
  transform: translateY(-1px);
}

#game-canvas {
  width: 100%;
  max-width: 500px;
  aspect-ratio: 9/16;
  background: var(--game-bg);
  border: 2px solid var(--accent);
  border-radius: 0.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.game-controls {
  display: flex;
  gap: 1rem;
  width: 100%;
  max-width: 500px;
}

#draw-btn {
  flex: 1;
  padding: 0.75rem;
  background: var(--accent2);
  border: 0;
  border-radius: 0.5rem;
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: none;
}

#draw-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

#game-status {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  min-height: 2rem;
}

#suit-selector {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(13, 17, 23, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  padding: 2rem;
}

.suit-selector-card {
  background: linear-gradient(135deg, rgba(22, 27, 34, 0.98), rgba(13, 17, 23, 0.98));
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  max-width: 300px;
}

.suit-selector-card h3 {
  margin: 0 0 1.5rem;
  color: var(--accent);
  font-size: 1.3rem;
}

.suit-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.suit-btn {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.suit-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.05);
}

.game-over-card {
  background: linear-gradient(135deg, rgba(22, 27, 34, 0.98), rgba(13, 17, 23, 0.98));
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  width: 100%;
  max-width: 400px;
}

.game-over-card h2 {
  font-size: 2rem;
  color: var(--success);
  margin: 0 0 1rem;
}

#result-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2rem;
}

.game-over-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.5rem;
  }

  .menu-card {
    padding: 1.5rem;
  }

  #game-canvas {
    aspect-ratio: 1/1.4;
  }
}
