:root {
  --bg-top: #fff5cf;
  --bg-bottom: #d9f7ff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --ink: #14324a;
  --muted: #52718a;
  --line: rgba(20, 50, 74, 0.1);
  --yellow: #ffd447;
  --yellow-deep: #f4b400;
  --orange: #ff8a4c;
  --sky: #78d8ff;
  --mint: #7ce2b0;
  --pink: #ffb8d7;
  --danger: #ea5a5a;
  --shadow: 0 24px 60px rgba(20, 50, 74, 0.16);
  --radius-xl: 36px;
  --radius-lg: 26px;
  --radius-md: 20px;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Avenir Next", "Pretendard", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 212, 71, 0.55), transparent 28%),
    radial-gradient(circle at top right, rgba(120, 216, 255, 0.4), transparent 24%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  min-height: 100vh;
  overscroll-behavior: none;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
  padding: max(6px, env(safe-area-inset-top)) 18px max(8px, env(safe-area-inset-bottom));
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 6px;
}

.play-preset-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.play-preset-check {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.play-preset-check input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.play-preset-check span {
  min-width: 56px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(20, 50, 74, 0.12);
  font-weight: 800;
  box-shadow: 0 10px 18px rgba(20, 50, 74, 0.08);
}

.play-preset-check input:checked + span {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  border-color: rgba(244, 180, 0, 0.2);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  line-height: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-pill {
  min-width: 108px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  text-align: center;
  font-size: 0.96rem;
  font-weight: 700;
}

.icon-button,
.close-button,
.primary-button,
.secondary-button,
.ghost-button {
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.icon-button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  font-size: 1.45rem;
}

.nav-button[disabled] {
  opacity: 0.35;
  pointer-events: none;
}

.playground {
  min-height: calc(100vh - 74px);
}

.play-card,
.empty-panel,
.settings-sheet,
.search-sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.play-card {
  min-height: calc(100vh - 84px);
  padding: 10px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  user-select: none;
  touch-action: none;
}

.play-card.revealed {
  animation: card-bounce 420ms ease;
}

.play-card.flip-burst .word-stack {
  animation: flip-burst 560ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.play-card.card-swoop {
  animation: card-swoop 620ms cubic-bezier(0.16, 0.9, 0.24, 1);
}

.play-card.card-swoop-back {
  animation: card-swoop-back 620ms cubic-bezier(0.16, 0.9, 0.24, 1);
}

.card-stage {
  position: relative;
  overflow: hidden;
  border-radius: 30px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.68)),
    linear-gradient(135deg, rgba(255, 184, 215, 0.45), rgba(124, 226, 176, 0.4));
  min-height: 29vh;
  display: grid;
  place-items: center;
  touch-action: none;
  cursor: pointer;
}

.card-stage::after {
  content: "";
  position: absolute;
  inset: auto -12% -35% auto;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(255, 212, 71, 0.34);
  filter: blur(8px);
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 35vh;
  z-index: 1;
}

.image-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.card-copy {
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
  touch-action: none;
  cursor: pointer;
}

.guide-text,
.tap-hint,
.helper-text {
  color: var(--muted);
}

.guide-text {
  font-size: 1.02rem;
  font-weight: 600;
}

.word-stack {
  position: relative;
  width: min(680px, 92vw);
  min-height: 96px;
  transform-style: preserve-3d;
  transition: transform 480ms cubic-bezier(0.2, 0.8, 0.2, 1);
  perspective: 1200px;
}

.play-card.revealed .word-stack {
  transform: rotateY(180deg);
}

.word-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px 18px;
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.8)),
    rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(20, 50, 74, 0.08);
  box-shadow: 0 18px 34px rgba(20, 50, 74, 0.1);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.word-face-back {
  transform: rotateY(180deg);
}

.english-word,
.korean-word {
  font-size: clamp(2.1rem, 4.8vw, 3.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.list-search-field {
  margin-top: 14px;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.tap-hint {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 10px;
}

.tap-hint.hidden {
  display: none !important;
}


.empty-panel {
  min-height: calc(100vh - 84px);
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
  gap: 12px;
}

.empty-illustration {
  font-size: 4rem;
}

.start-button {
  min-width: min(320px, 82vw);
  min-height: 72px;
  padding: 18px 28px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  box-shadow: 0 20px 34px rgba(255, 138, 76, 0.26);
  font-size: 1.35rem;
  font-weight: 900;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 50, 74, 0.34);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.settings-sheet,
.search-sheet {
  width: min(1380px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 28px;
}

.sheet-header,
.section-title-row,
.search-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sheet-header {
  margin-bottom: 18px;
}

.sheet-header.compact {
  margin-bottom: 14px;
}

.password-panel,
.editor-panel,
.list-panel {
  background: rgba(255, 255, 255, 0.74);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 20px;
}

.password-panel {
  display: grid;
  gap: 14px;
  max-width: 420px;
}

.settings-body {
  display: grid;
  grid-template-columns: minmax(340px, 0.8fr) minmax(0, 1.45fr);
  gap: 20px;
}

.editor-form,
.field,
.search-grid,
.card-list {
  display: grid;
}

.editor-form,
.field {
  gap: 10px;
}

.field span {
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(20, 50, 74, 0.12);
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.94);
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(120, 216, 255, 0.35);
  border-color: #5bbff0;
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.45;
}

.image-tools,
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button,
.close-button {
  min-height: 54px;
  padding: 14px 20px;
  border-radius: 18px;
  font-weight: 800;
}

.primary-button {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  box-shadow: 0 18px 30px rgba(255, 138, 76, 0.28);
}

.secondary-button {
  background: linear-gradient(135deg, #a5ecff, #d2fbff);
}

.ghost-button,
.close-button {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
}

.danger-button {
  color: #a43838;
  border-color: rgba(234, 90, 90, 0.22);
  background: rgba(255, 241, 241, 0.98);
}

.preview-panel {
  min-height: 220px;
  border-radius: 24px;
  border: 2px dashed rgba(20, 50, 74, 0.14);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.75), rgba(210, 251, 255, 0.6));
}

.bulk-panel {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed rgba(20, 50, 74, 0.14);
  display: grid;
  gap: 14px;
}

.bulk-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
  gap: 12px;
}

.compact-row {
  align-items: flex-start;
}

.preview-image {
  width: 100%;
  height: 220px;
  object-fit: contain;
}

.preview-placeholder {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--muted);
}

.card-list {
  gap: 12px;
  margin-top: 16px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  padding-right: 6px;
}

.preset-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.cache-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.summary-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--ink);
}

.preset-chip {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  font-weight: 800;
}

.preset-chip.active {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  box-shadow: 0 12px 22px rgba(255, 138, 76, 0.2);
}

.saved-card {
  display: grid;
  grid-template-columns: 110px minmax(0, 1.2fr) minmax(280px, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.86);
}

.saved-card img {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 18px;
  background: #f2f7fb;
}

.saved-card h4 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.saved-card p {
  color: var(--muted);
}

.cache-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(124, 226, 176, 0.18);
  color: #1c6d4b;
  font-size: 0.82rem;
  font-weight: 800;
}

.cache-badge.pending {
  background: rgba(255, 212, 71, 0.2);
  color: #8a6200;
}

.voice-mode-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(120, 216, 255, 0.18);
  color: #165b76;
  font-size: 0.82rem;
  font-weight: 800;
}

.voice-mode-badge.pending {
  background: rgba(255, 212, 71, 0.2);
  color: #8a6200;
}

.voice-mode-badge.device {
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
}

.saved-card-copy {
  display: grid;
  gap: 10px;
}

.saved-card-controls {
  display: grid;
  gap: 12px;
}

.voice-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.voice-control {
  display: grid;
  gap: 6px;
}

.voice-control span {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--muted);
}

.preset-checks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(120, 216, 255, 0.12);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.preset-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
}

.saved-card-actions {
  display: grid;
  gap: 8px;
}

.preview-voice-button {
  background: linear-gradient(135deg, #a5ecff, #d2fbff);
}

.mini-button {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  font-weight: 700;
}

.search-toolbar {
  margin-bottom: 12px;
}

.search-toolbar input {
  flex: 1;
}

.search-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.search-card {
  background: rgba(255, 255, 255, 0.82);
  border-radius: 22px;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.search-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 18px;
}

.search-card p {
  min-height: 44px;
  color: var(--muted);
  font-size: 0.94rem;
}

.danger-text {
  color: var(--danger);
}

.pulse {
  animation: pulse 0.7s ease;
}

@keyframes card-bounce {
  0% {
    transform: scale(0.98);
  }
  45% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes flip-burst {
  0% {
    transform: rotateY(0deg) scale(1);
  }
  45% {
    transform: rotateY(10deg) scale(1.05);
  }
  100% {
    transform: rotateY(0deg) scale(1);
  }
}

@keyframes card-swoop {
  0% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
  35% {
    transform: translateX(18px) scale(0.98);
    opacity: 0.82;
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

@keyframes card-swoop-back {
  0% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
  35% {
    transform: translateX(-18px) scale(0.98);
    opacity: 0.82;
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

.icon-button:active,
.card-stage:active,
.card-copy:active,
.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.close-button:active,
.mini-button:active {
  transform: scale(0.97);
}

@media (max-width: 1024px) {
  .settings-body {
    grid-template-columns: 1fr;
  }

  .bulk-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .top-bar {
    align-items: flex-start;
    gap: 10px;
  }

  .play-preset-bar {
    gap: 6px;
  }

  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .play-card,
  .empty-panel {
    min-height: calc(100vh - 82px);
  }

  .card-stage {
    min-height: 34vh;
  }

  .card-actions {
    flex-direction: column;
  }

  .saved-card {
    grid-template-columns: 80px minmax(0, 1fr);
  }

  .saved-card-controls,
  .saved-card .saved-card-actions {
    grid-column: 1 / -1;
  }

  .voice-control-grid {
    grid-template-columns: 1fr;
  }
}
