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

:root {
  --background: #a7c7e7;
  --card: #fcfdfe;
  --border: #7faed6;
  --button: #dcecf8;
  --text: #24313d;
  --text-secondary: #66707a;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--background);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  transition: background 300ms ease;
}

[hidden] {
  display: none !important;
}

main {
  width: min(520px, 100%);
}

#card-counter {
  display: flex;
  align-items: center;
  width: fit-content;
  justify-content: center;

  margin-left: auto;
  margin-right: auto;

  min-width: 72px;

  padding: 6px 14px;

  margin-bottom: 18px;

  border: 1px solid var(--border);
  border-radius: 999px;

  background: rgba(255, 255, 255, 0.45);

  font-size: 14px;
  font-weight: 600;

  color: #555;

  backdrop-filter: blur(8px);
}

#flashcard {
  height: 75vh;
  min-height: 520px;
  max-height: 760px;
  position: relative;

  border: 3px solid var(--border);
  border-radius: 24px;
  background: transparent;

  perspective: 1200px;

  cursor: pointer;
}

#card-inner {
  position: relative;

  width: 100%;
  height: 100%;

  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);

  transform-style: preserve-3d;
}

#card-front,
#card-back {
  position: absolute;

  width: 100%;
  height: 100%;

  background: var(--card);

  border-radius: 24px;

  padding: 36px;

  backface-visibility: hidden;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  text-align: center;

  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
}

#card-back {
  transform: rotateY(180deg);
}

#card-front h2 {
  font-size: 30px;
  color: var(--text);

  margin-bottom: 24px;
}

#card-front h3 {
  font-size: 20px;
  font-weight: 400;

  color: var(--text-secondary);
}

#card-back {
  color: var(--text);
  font-size: 18px;
  line-height: 1.6;
}

#next-button {
  background: var(--border);
}

#next-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

#next-button:active {
  transform: scale(0.97);
}

#card-inner.flipped {
  transform: rotateY(180deg);
}

#answer-container {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
}

#answer {
  color: var(--text);
  line-height: 1.75;
  font-size: 15px;
  font-weight: 400;
  width: 100%;
  overflow-y: auto;
  text-align: justify;
  hyphens: auto;
}

#answer h1,
#answer h2,
#answer h3 {
  margin: 22px 0 12px;
  font-weight: 600;
  color: #2f3b46;
}

#answer p {
  margin-bottom: 16px;
  text-align: justify;
  line-height: 1.7;
  margin: 0 0 16px;
}

#answer ul,
#answer ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

#answer li {
  margin-bottom: 8px;
}

#answer table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 15px;
}

#answer th,
#answer td {
  border: 1px solid var(--border);
  padding: 10px;
  text-align: left;
}

#answer th {
  background: var(--button);
}

#answer code {
  background: #f4f4f4;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: Consolas, monospace;
}

#answer pre {
  background: #f4f4f4;
  padding: 16px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 16px 0;
}

#answer a {
  color: var(--border);
}

#question-en {
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.4;
}

#question-ua {
  margin-top: 14px;
  font-size: 1rem;
  opacity: 0.7;
}

#answer table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.35);
}

#answer thead {
  background: var(--button);
}

#answer th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
}

#answer td {
  padding: 12px;
  font-size: 14px;
  vertical-align: top;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

#answer tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.22);
}

.buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
}

.buttons button {
  /* min-width: 150px; */
  width: 100%;
  padding: 14px 28px;
  border: none;
  border-radius: 18px;
  background: var(--button);
  color: black;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    filter 0.2s ease,
    background-color 0.2s ease;
}

.buttons button:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.03);
}

.buttons button:active:not(:disabled) {
  transform: translateY(0);
  filter: brightness(0.97);
}

#previous-button {
  background: var(--button);
  color: #333;
  opacity: 0.9;
}

#previous-button span,
#next-button span {
  display: inline-block;
  transform: translateY(-1px);
}

.buttons button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

#answer ul,
#answer ol {
  margin: 16px 0;
  padding-left: 24px;
  text-align: left;
}

#answer li {
  margin: 8px 0;
  line-height: 1.6;
}

#answer li::marker {
  color: var(--border);
}

#answer::-webkit-scrollbar {
  width: 8px;
}

#answer::-webkit-scrollbar-track {
  background: transparent;
}

#answer::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

#answer::-webkit-scrollbar-thumb:hover {
  background: #6f8fb5;
}

#keyboard-hint {
  margin-top: 12px;

  text-align: center;

  font-size: 13px;

  color: rgba(0, 0, 0, 0.45);

  user-select: none;
}

kbd {
  display: inline-block;

  min-width: 20px;

  padding: 2px 8px;

  margin: 0 2px;

  border: 1px solid rgba(0, 0, 0, 0.12);

  border-radius: 6px;

  background: rgba(255, 255, 255, 0.55);

  font-size: 12px;

  font-family: inherit;

  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

#completion-screen:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  min-height: 500px;

  text-align: center;

  gap: 20px;
}

#completion-screen h2 {
  font-size: 56px;
  margin: 0;
}

#completion-screen h3 {
  margin: 0;

  font-size: 28px;

  font-weight: 600;

  line-height: 1.4;
}

#restart-button {
  padding: 14px 32px;

  border: none;

  border-radius: 14px;

  cursor: pointer;

  background: var(--button);

  font-size: 16px;

  font-weight: 600;

  transition: 0.25s;
}

#restart-button:hover {
  transform: translateY(-2px);

  filter: brightness(0.97);
}

#restart-button:active {
  transform: scale(0.97);
}
