:root {
  --bg-color: #09090b;
  --header-bg: #161c27;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #2dd4bf;
  --glass-bg: rgba(30, 41, 59, 0.5);
  --glass-border: rgba(255, 255, 255, 0.05);
  --input-bg: rgba(15, 23, 42, 0.6);
  --card-back-bg: rgba(15, 23, 42, 0.8);
  --grid-line: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] {
  --bg-color: #f0f4f8;
  --header-bg: #f7f8f8;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #0ea5e9;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.05);
  --input-bg: rgba(255, 255, 255, 0.9);
  --card-back-bg: rgba(241, 245, 249, 0.9);
  --grid-line: rgba(0, 0, 0, 0.03);
}

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: 0.3s;
  background-image:
    radial-gradient(
      circle at 15% 50%,
      rgba(20, 184, 166, 0.1),
      transparent 25%
    ),
    radial-gradient(
      circle at 85% 30%,
      rgba(59, 130, 246, 0.1),
      transparent 25%
    ),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size:
    100% 100%,
    100% 100%,
    30px 30px,
    30px 30px;
}

header {
  padding: max(20px, env(safe-area-inset-top)) 20px 15px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}
.brand {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
}
.brand span {
  color: var(--text-main);
  font-weight: 300;
}
.header-controls {
  display: flex;
  gap: 8px;
}
.icon-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: 0.2s;
  font-weight: bold;
}
.icon-btn:active {
  transform: scale(0.9);
}

.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 100px;
}
.screen.active {
  display: flex;
}

.decks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  margin-top: 20px;
}
.deck-card {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 20px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  transition: 0.2s;
}
.deck-card:active {
  transform: scale(0.95);
}
.deck-name {
  font-size: 1.1rem;
  font-weight: 700;
  z-index: 2;
  color: var(--text-main);
  word-wrap: break-word;
}
.deck-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 5px;
  z-index: 2;
}
.deck-glow {
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0.4;
  z-index: 1;
}

.study-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.card-container {
  perspective: 1000px;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 4/3;
  margin-bottom: 30px;
}
.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-style: preserve-3d;
  cursor: pointer;
}
.flashcard.flipped {
  transform: rotateY(180deg);
}
.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  border-radius: 24px;
  padding: 20px;
  text-align: center;
  word-wrap: break-word;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
.card-front {
  color: var(--text-main);
}
.card-back {
  background: var(--card-back-bg);
  color: var(--accent);
  transform: rotateY(180deg);
}

.mode-switcher {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  width: 100%;
  max-width: 320px;
}
.mode-btn {
  flex: 1;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 10px 4px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
  white-space: nowrap;
  text-align: center;
}
.mode-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(45, 212, 191, 0.3);
}

.btn-main {
  width: 100%;
  display: block;
  max-width: 300px;
  padding: 18px;
  border-radius: 16px;
  font-size: 1.1rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
  transition: 0.2s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  text-align: center;
  text-decoration: none;
}
.btn-main:active {
  transform: scale(0.95);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.1);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.3);
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 15px;
  transition: 0.2s;
}
.btn-danger:active {
  transform: scale(0.95);
  background: #f43f5e;
  color: #fff;
}

.input-group {
  margin-bottom: 15px;
}
input {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--input-bg);
  color: var(--text-main);
  font-size: 1.1rem;
  outline: none;
}
input:focus {
  border-color: var(--accent);
}
.word-list {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.word-item {
  background: var(--glass-bg);
  padding: 15px;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--glass-border);
}
.word-del {
  color: #f43f5e;
  background: rgba(244, 63, 94, 0.1);
  border: none;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.show {
  display: flex;
}
.modal-content {
  background: var(--header-bg);
  border: 1px solid var(--glass-border);
  padding: 25px;
  border-radius: 20px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content h3 {
  color: var(--accent);
  margin-bottom: 15px;
  font-size: 1.4rem;
}
.modal-content p {
  color: var(--text-main);
  margin-bottom: 20px;
  font-size: 0.95rem;
  line-height: 1.5;
}
.donate-box {
  background: rgba(255, 255, 255, 0.05);
  padding: 15px;
  border-radius: 12px;
  margin-bottom: 20px;
  border: 1px dashed var(--glass-border);
}
.donate-card {
  font-family: monospace;
  font-size: 1.3rem;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 10px;
  font-weight: bold;
}
.copy-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 8px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: 0.2s;
}
.copy-btn:active {
  transform: scale(0.95);
}
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}
.modal-actions-row {
  display: flex;
  gap: 10px;
}

.install-banner {
  position: fixed;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 400px;
  background: var(--glass-bg);
  backdrop-filter: blur(15px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: 0.5s;
  z-index: 100;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
}
.install-banner.show {
  bottom: 20px;
}

.toast {
  position: fixed;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #000;
  padding: 12px 25px;
  border-radius: 30px;
  font-weight: bold;
  font-size: 1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
  pointer-events: none;
}
.toast.show {
  bottom: 30px;
}

.onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  background-image:
    radial-gradient(
      circle at 15% 50%,
      rgba(20, 184, 166, 0.1),
      transparent 25%
    ),
    radial-gradient(
      circle at 85% 30%,
      rgba(59, 130, 246, 0.1),
      transparent 25%
    ),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size:
    100% 100%,
    100% 100%,
    30px 30px,
    30px 30px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  transition:
    opacity 0.5s ease,
    visibility 0.5s;
}
.onboarding-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}
.onboarding-step {
  display: none;
  width: 100%;
  max-width: 380px;
  animation: fadeIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.onboarding-step.active {
  display: block;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
#ob-step-1 .btn-main,
#ob-step-2 .btn-main {
  width: 100%;
  max-width: 100%;
  margin-bottom: 15px;
}
