:root {
  color-scheme: light;
  --ink: #18191f;
  --muted: #626675;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --line: #d9dce4;
  --violet: #5342b7;
  --coral: #df5b45;
  --mint: #0f8f74;
  --amber: #f2b84b;
  --blue: #227f88;
  --shadow: 0 20px 55px rgba(24, 25, 31, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(83, 66, 183, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(15, 143, 116, 0.08) 1px, transparent 1px),
    var(--paper);
  background-size: 42px 42px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

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

.eyebrow,
.mini-label,
.score-label,
.card-topline,
.flip-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 4.2rem);
  line-height: 0.94;
}

h2 {
  font-size: 1.45rem;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(440px, 100%);
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(24, 25, 31, 0.08);
}

.mode-tab {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.mode-tab.is-active {
  color: #ffffff;
  background: var(--violet);
}

.game-view,
.cards-view,
.phrases-view {
  display: none;
}

.game-view.is-visible,
.cards-view.is-visible,
.phrases-view.is-visible {
  display: block;
}

.score-strip,
.phrase-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.score-strip > div,
.phrase-stats > div {
  min-height: 86px;
  padding: 16px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 5px 5px 0 var(--amber);
}

.score-strip strong,
.phrase-stats strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(1.2rem, 3vw, 2rem);
  line-height: 1.05;
}

.play-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: stretch;
}

.question-card,
.round-list,
.deck-panel,
.phrase-stage,
.phrase-list {
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.question-card {
  min-height: 520px;
  padding: clamp(20px, 5vw, 42px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.romani-word {
  width: 100%;
  min-height: 118px;
  margin: 28px 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: clamp(3.2rem, 12vw, 7.8rem);
  font-weight: 950;
  line-height: 0.95;
}

.word-note {
  min-height: 30px;
  margin: 0 0 22px;
  color: var(--violet);
  font-size: 1.02rem;
  font-weight: 900;
  text-align: center;
}

.answer-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
}

.answer-form input {
  min-width: 0;
  min-height: 58px;
  padding: 0 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #f7f8fb;
  color: var(--ink);
  font-size: 1.1rem;
  outline: none;
}

.answer-form input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 4px rgba(83, 66, 183, 0.18);
}

.primary-button,
.ghost-button {
  min-height: 46px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  min-width: 138px;
  padding: 0 22px;
  color: #ffffff;
  background: var(--coral);
  box-shadow: 4px 4px 0 var(--ink);
}

.primary-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.ghost-button {
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
}

.feedback {
  min-height: 32px;
  margin: 18px 0 0;
  font-size: 1.05rem;
  font-weight: 850;
}

.feedback.is-good {
  color: var(--mint);
}

.feedback.is-bad {
  color: var(--coral);
}

.round-list {
  min-height: 520px;
  padding: 18px;
  overflow: hidden;
}

.round-list ol {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.round-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8fb;
  color: var(--muted);
  font-weight: 800;
}

.round-list .marker {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.82rem;
}

.round-list li.is-current {
  border-color: var(--violet);
  color: var(--ink);
  background: rgba(83, 66, 183, 0.1);
}

.round-list li.is-correct .marker {
  color: #ffffff;
  background: var(--mint);
}

.round-list li.is-wrong .marker {
  color: #ffffff;
  background: var(--coral);
}

.deck-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  margin-bottom: 16px;
}

.deck-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.flashcard {
  position: relative;
  display: block;
  width: min(560px, 100%);
  height: 330px;
  margin: 0 auto 22px;
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 1100px;
}

.flashcard-face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 20px;
  padding: 28px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 10px 10px 0 var(--ink);
  backface-visibility: hidden;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.flashcard-front {
  color: #ffffff;
  background:
    radial-gradient(circle at 18% 20%, rgba(242, 184, 75, 0.95) 0 7%, transparent 7.5%),
    radial-gradient(circle at 82% 76%, rgba(223, 91, 69, 0.9) 0 8%, transparent 8.5%),
    linear-gradient(135deg, var(--violet), #227f88);
}

.flashcard-back {
  color: var(--ink);
  background:
    repeating-linear-gradient(45deg, rgba(15, 143, 116, 0.13) 0 12px, transparent 12px 24px),
    #ffffff;
  transform: rotateY(180deg);
}

.flashcard.is-flipped .flashcard-front {
  transform: rotateY(180deg);
}

.flashcard.is-flipped .flashcard-back {
  transform: rotateY(360deg);
}

.flashcard strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: clamp(2.6rem, 8vw, 5rem);
  line-height: 0.98;
}

.flash-note {
  min-height: 20px;
  color: inherit;
  font-size: 0.92rem;
  font-weight: 900;
  opacity: 0.76;
}

.flashcard-front .mini-label,
.flashcard-front .flip-note,
.flashcard-front .flash-note {
  color: rgba(255, 255, 255, 0.82);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.mini-card {
  min-height: 128px;
  padding: 13px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 4px 4px 0 rgba(24, 25, 31, 0.16);
}

.mini-card span,
.mini-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.mini-card span {
  color: var(--violet);
  font-size: 1.05rem;
  font-weight: 950;
}

.mini-card strong {
  margin-top: 10px;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.25;
}

.mini-note,
.round-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.15;
}

.phrase-stage {
  min-height: auto;
  padding: 14px;
  margin-bottom: 14px;
}

.phrase-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.phrase-card {
  position: relative;
  display: block;
  width: 100%;
  min-height: 220px;
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 1100px;
}

.phrase-face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: clamp(18px, 4vw, 32px);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 9px 9px 0 var(--ink);
  backface-visibility: hidden;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.phrase-front {
  color: #ffffff;
  background:
    radial-gradient(circle at 14% 22%, rgba(242, 184, 75, 0.95) 0 8%, transparent 8.5%),
    linear-gradient(135deg, var(--blue), var(--violet));
}

.phrase-front .flip-note {
  color: rgba(255, 255, 255, 0.82);
}

.phrase-back {
  color: var(--ink);
  background:
    repeating-linear-gradient(-45deg, rgba(242, 184, 75, 0.2) 0 12px, transparent 12px 24px),
    #ffffff;
  transform: rotateY(180deg);
}

.phrase-card.is-flipped .phrase-front {
  transform: rotateY(180deg);
}

.phrase-card.is-flipped .phrase-back {
  transform: rotateY(360deg);
}

.phrase-card strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: clamp(1.65rem, 4vw, 3.5rem);
  line-height: 1.03;
}

.phrase-card.is-long strong {
  font-size: clamp(1.12rem, 2.55vw, 2.1rem);
}

.phrase-card.is-extra-long strong {
  font-size: clamp(0.9rem, 1.95vw, 1.5rem);
}

.phrase-front .mini-label,
.phrase-front .phrase-note {
  color: rgba(255, 255, 255, 0.82);
}

.phrase-note {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 900;
  text-align: center;
}

.phrase-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.know-button,
.learn-button {
  min-height: 54px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: #ffffff;
  font-weight: 950;
  box-shadow: 4px 4px 0 var(--ink);
}

.know-button {
  background: var(--mint);
}

.learn-button {
  background: var(--coral);
}

.know-button:disabled,
.learn-button:disabled {
  cursor: default;
  opacity: 0.5;
  box-shadow: none;
}

.phrase-feedback {
  min-height: 34px;
  margin-bottom: 0;
  text-align: center;
}

.phrase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.phrase-tile {
  position: relative;
  display: block;
  min-height: 178px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  perspective: 900px;
}

.phrase-tile-face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 4px 4px 0 rgba(24, 25, 31, 0.18);
  backface-visibility: hidden;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
}

.phrase-tile-front {
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue), var(--violet));
}

.phrase-tile-back {
  color: var(--ink);
  background: #ffffff;
  transform: rotateY(180deg);
}

.phrase-tile.is-flipped .phrase-tile-front {
  transform: rotateY(180deg);
}

.phrase-tile.is-flipped .phrase-tile-back {
  transform: rotateY(360deg);
}

.phrase-tile strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: 1.18rem;
  line-height: 1.13;
}

.phrase-tile.is-long strong {
  font-size: 1rem;
}

.phrase-tile.is-extra-long strong {
  font-size: 0.88rem;
}

.phrase-tile-front .mini-label,
.phrase-tile-front .phrase-note,
.phrase-tile-front .flip-note {
  color: rgba(255, 255, 255, 0.82);
}

.phrase-tile.is-current .phrase-tile-face {
  border-color: var(--amber);
  box-shadow: 4px 4px 0 var(--amber);
}

.phrase-tile.is-known .phrase-tile-face {
  border-color: var(--mint);
}

.phrase-tile.is-learning .phrase-tile-face {
  border-color: var(--coral);
}

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

@media (max-width: 820px) {
  .top-bar,
  .deck-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-tabs {
    width: 100%;
  }

  .score-strip,
  .phrase-stats,
  .play-area {
    grid-template-columns: 1fr;
  }

  .question-card,
  .round-list,
  .phrase-stage {
    min-height: auto;
  }

  .round-list ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .score-strip,
  .phrase-stats {
    gap: 8px;
  }

  .score-strip > div,
  .phrase-stats > div {
    min-height: 74px;
    padding: 12px;
  }

  .answer-form {
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
  }

  .round-list ol {
    grid-template-columns: 1fr;
  }

  .flashcard,
  .phrase-card {
    height: 260px;
  }

  .phrase-card {
    min-height: 240px;
  }

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

  .deck-controls {
    justify-content: stretch;
  }

  .deck-controls .ghost-button {
    flex: 1 1 120px;
  }
}

/* rom4e.com arcade polish layer */
:root {
  --ink: #16121f;
  --paper: #fff4d6;
  --surface: #fff8df;
  --line: rgba(22, 18, 31, 0.24);
  --violet: #6732c7;
  --coral: #ef3e4a;
  --mint: #21a968;
  --amber: #ffd45f;
  --blue: #1377f2;
  --shadow: 0 9px 0 rgba(18, 12, 28, 0.46), 0 26px 56px rgba(0, 0, 0, 0.28);
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 212, 95, 0.36), transparent 18%),
    radial-gradient(circle at 88% 8%, rgba(55, 221, 255, 0.28), transparent 20%),
    radial-gradient(circle at 72% 94%, rgba(33, 169, 104, 0.25), transparent 24%),
    linear-gradient(180deg, #17327a 0%, #1a1230 58%, #0d0918 100%);
}

.site-back-link {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 20;
  padding: 9px 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: linear-gradient(180deg, #fff16e, #ffb83f);
  box-shadow: 0 5px 0 rgba(18, 12, 28, 0.48);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 950;
}

.app-shell {
  padding-top: max(52px, env(safe-area-inset-top));
}

.top-bar {
  padding: clamp(18px, 4vw, 34px);
  border: 5px solid var(--ink);
  border-radius: 20px;
  color: #fff9df;
  background:
    linear-gradient(180deg, rgba(19, 119, 242, 0.98) 0%, rgba(55, 221, 255, 0.88) 50%, rgba(45, 196, 102, 0.92) 51%, rgba(28, 125, 66, 0.98) 100%);
  box-shadow: var(--shadow);
}

.top-bar h1 {
  color: var(--amber);
  -webkit-text-stroke: 1.4px var(--ink);
  text-shadow: 0 3px 0 var(--coral), 0 7px 0 #761d2e, 0 16px 24px rgba(0, 0, 0, 0.35);
}

.top-bar .eyebrow {
  color: rgba(255, 249, 223, 0.9);
}

.mode-tabs,
.score-strip > div,
.phrase-stats > div,
.question-card,
.round-list,
.deck-panel,
.phrase-stage,
.mini-card,
.phrase-tile-face {
  border-width: 3px;
  box-shadow: var(--shadow);
}

.mode-tabs {
  padding: 6px;
  border: 3px solid var(--ink);
  background: rgba(255, 248, 223, 0.96);
}

.mode-tab {
  border-radius: 8px;
}

.mode-tab.is-active {
  background: linear-gradient(180deg, #7b58ff, #4421a8);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.28), 0 4px 0 rgba(18, 12, 28, 0.34);
}

.score-strip > div,
.phrase-stats > div,
.question-card,
.round-list,
.deck-panel,
.phrase-stage {
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 255, 0.62), transparent 24%),
    linear-gradient(180deg, #fff4cf, #f0b34f);
}

.question-card,
.round-list,
.deck-panel,
.phrase-stage {
  border-radius: 18px;
}

.romani-word,
.flashcard strong,
.phrase-card strong {
  color: #271521;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.55);
}

.answer-form input,
.round-list li {
  border: 3px solid var(--ink);
  background: #fffaf0;
}

.primary-button,
.ghost-button,
.know-button,
.learn-button {
  border-width: 3px;
  border-radius: 12px;
  box-shadow: 0 5px 0 rgba(18, 12, 28, 0.48);
}

.primary-button {
  background: linear-gradient(180deg, #fff16e 0%, #ffb83f 44%, #d45b1f 100%);
  color: var(--ink);
}

.ghost-button {
  background: linear-gradient(180deg, #3a91ff 0%, #2559c9 58%, #172d7b 100%);
  color: #fff4c4;
}

.flashcard-face,
.phrase-face {
  border-width: 4px;
  border-radius: 18px;
  box-shadow: 0 10px 0 rgba(18, 12, 28, 0.54), 0 24px 46px rgba(0, 0, 0, 0.25);
}

.flashcard-front,
.phrase-front {
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 241, 110, 0.95) 0 9%, transparent 9.5%),
    radial-gradient(circle at 82% 76%, rgba(239, 62, 74, 0.9) 0 9%, transparent 9.5%),
    linear-gradient(135deg, var(--blue), var(--violet));
}

.mini-card {
  border-radius: 14px;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 255, 0.54), transparent 24%),
    linear-gradient(180deg, #fff8df, #ffd45f);
}

.phrase-tile-face {
  border-radius: 14px;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 14px, 1180px);
    padding-top: max(58px, env(safe-area-inset-top));
  }

  .top-bar {
    border-width: 4px;
    border-radius: 16px;
  }

  .score-strip > div,
  .phrase-stats > div {
    min-height: 68px;
  }

  .mode-tabs {
    grid-template-columns: 1fr;
  }

  .mode-tab,
  .primary-button,
  .ghost-button,
  .know-button,
  .learn-button {
    min-height: 50px;
  }

  .flashcard,
  .phrase-card {
    min-height: 280px;
  }
}
