:root {
  --ink: #18322d;
  --muted: #6e7f79;
  --cream: #f6f1e7;
  --paper: #fffdf8;
  --green: #1f6f5c;
  --green-dark: #174f43;
  --lime: #d6e96f;
  --orange: #ee845f;
  --line: rgba(24, 50, 45, 0.12);
  --shadow: 0 24px 60px rgba(44, 63, 53, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(214, 233, 111, 0.32), transparent 24rem),
    radial-gradient(circle at 100% 65%, rgba(238, 132, 95, 0.14), transparent 25rem),
    var(--cream);
  font-family: "DM Sans", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.app-shell {
  width: min(100%, 72rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: 1.25rem 1rem 7.5rem;
}

.search-section {
  position: relative;
  z-index: 10;
}

.search-box {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
  min-height: 3.65rem;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: 0 8px 30px rgba(44, 63, 53, 0.06);
  backdrop-filter: blur(12px);
}

.search-box:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 111, 92, 0.12);
}

.search-box svg {
  width: 1.25rem;
  fill: none;
  stroke: var(--green);
  stroke-linecap: round;
  stroke-width: 2;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 0.92rem;
}

.search-box input::placeholder {
  color: #89948f;
}

.clear-search {
  display: none;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

.clear-search.visible {
  display: block;
}

.search-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  left: 0;
  display: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.search-results.visible {
  display: block;
}

.search-result {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover,
.search-result:focus-visible {
  background: rgba(214, 233, 111, 0.18);
  outline: 0;
}

.result-portuguese {
  font-weight: 700;
}

.result-english {
  color: var(--muted);
  font-size: 0.88rem;
}

.no-results {
  margin: 0;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.study-section {
  padding-top: clamp(2.5rem, 8vh, 5rem);
}

.study-heading {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.progress {
  color: var(--muted);
  font-size: 0.75rem;
}

.progress strong {
  color: var(--ink);
  font-size: 1rem;
}

.flashcard {
  position: relative;
  isolation: isolate;
  display: block;
  overflow: hidden;
  width: 100%;
  min-height: clamp(18rem, 46vh, 24rem);
  padding: 2rem;
  border: 0;
  border-radius: 1.75rem;
  color: var(--paper);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 45%),
    var(--green);
  box-shadow: var(--shadow);
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 220ms ease, background-color 220ms ease;
}

.flashcard:hover {
  transform: translateY(-3px);
}

.flashcard.flipping {
  transform: scale(0.97) rotateY(5deg);
}

.flashcard.english-side {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 45%),
    var(--green-dark);
}

.card-glow {
  position: absolute;
  z-index: -1;
  top: -6rem;
  right: -4rem;
  width: 16rem;
  height: 16rem;
  border-radius: 50%;
  background: rgba(214, 233, 111, 0.23);
}

.card-glow::after {
  position: absolute;
  right: 8rem;
  bottom: -19rem;
  width: 17rem;
  height: 17rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  content: "";
}

.card-content {
  display: flex;
  min-height: calc(clamp(18rem, 46vh, 24rem) - 4rem);
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.language-pill {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  padding: 0.38rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 2rem;
  color: var(--lime);
  background: rgba(0, 0, 0, 0.08);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.13em;
}

.word {
  max-width: 100%;
  font-family: "Fraunces", serif;
  font-size: clamp(2.75rem, 14vw, 5.75rem);
  font-weight: 600;
  line-height: 1;
  overflow-wrap: anywhere;
}

.pronunciation {
  margin-top: 0.75rem;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

.hint {
  position: absolute;
  bottom: 1.5rem;
  display: flex;
  gap: 0.45rem;
  align-items: center;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.73rem;
}

.hint svg,
.card-actions svg {
  width: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.card-actions {
  display: grid;
  grid-template-columns: 2.8rem 1fr 2.8rem;
  gap: 0.75rem;
  margin-top: 1rem;
}

.card-actions button {
  min-height: 2.8rem;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.72);
  cursor: pointer;
}

.card-actions button:hover {
  border-color: rgba(31, 111, 92, 0.35);
  background: var(--paper);
}

.circle-button {
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.circle-button svg {
  width: 1.2rem;
}

.shuffle-button {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  border-radius: 2rem;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.keyboard-dock {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 0 0.75rem max(0.75rem, env(safe-area-inset-bottom));
  pointer-events: none;
}

.keyboard-controls,
.keyboard-panel {
  width: min(100%, 34rem);
  margin: 0 auto;
  pointer-events: auto;
}

.keyboard-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 1.25rem;
  background: rgba(24, 50, 45, 0.94);
  box-shadow: 0 12px 35px rgba(24, 50, 45, 0.24);
  backdrop-filter: blur(14px);
}

.keyboard-toggle {
  min-height: 3.15rem;
  border: 0;
  border-radius: 0.85rem;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
}

.keyboard-toggle.active {
  color: var(--ink);
  background: var(--lime);
}

.flag {
  margin-right: 0.35rem;
}

.keyboard-panel {
  display: none;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.28rem;
  margin-bottom: 0.45rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 253, 248, 0.97);
  box-shadow: 0 12px 35px rgba(24, 50, 45, 0.18);
}

.keyboard-panel.visible {
  display: grid;
}

.key {
  min-width: 0;
  height: 2.15rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  color: var(--ink);
  background: white;
  box-shadow: 0 2px 0 var(--line);
  cursor: pointer;
  font-size: clamp(0.58rem, 2.4vw, 0.8rem);
  font-weight: 600;
}

.key:active {
  box-shadow: none;
  transform: translateY(2px);
}

.key.space {
  grid-column: span 6;
}

.key.backspace {
  grid-column: span 2;
}

.key.search-key {
  grid-column: span 2;
  color: white;
  background: var(--green);
}

@media (min-width: 48rem) {
  .app-shell {
    padding: 1.75rem 2rem 8rem;
  }

  main {
    width: min(100%, 41rem);
    margin: 0 auto;
  }

  .search-box {
    min-height: 4rem;
  }

  .flashcard {
    border-radius: 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
