:root {
  --bg: #faf8f3;
  --text: #2b2620;
  --accent: #4c6b3f;
  --accent-light: #a3c586;
  --nav-bg: #ffffff;
  --border: #e3ddce;
  --max-width: 960px;
  --sidebar-width: 220px;
  --bright-green: #16a34a;
  --muted-text: #6b6355;
}

html.dark-mode {
  --bg: #0a0f2c;
  --text: #e9ecfa;
  --accent: #9fd8b0;
  --accent-light: #4f7a63;
  --nav-bg: #121a42;
  --border: #262f5c;
  --bright-green: #4ade80;
  --muted-text: #a8acc4;
}

* {
  box-sizing: border-box;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.floral-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.floral-item {
  position: absolute;
  overflow: visible;
}

.floral-sway {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: floral-sway 7s ease-in-out infinite;
}

@keyframes floral-sway {
  0%, 100% {
    transform: rotate(-1.5deg) translateX(-1px);
  }
  50% {
    transform: rotate(1.5deg) translateX(1px);
  }
}

/* Wind gusts (sudden rush, blow-away, damped wobble) are driven per-flower
   from JS via the Web Animations API, since each gust needs a random
   direction with per-flower jitter that plain CSS keyframes can't express.
   This group just needs to exist as the layer that JS animates. */
.floral-wind {
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

.theme-toggle {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 9999;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--nav-bg);
  color: var(--text);
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  transition: background 0.2s ease, transform 0.15s ease;
}

.theme-toggle:hover {
  transform: scale(1.08);
}

.help-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 9999;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--nav-bg);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  transition: background 0.2s ease, transform 0.15s ease;
}

.help-fab:hover {
  transform: scale(1.08);
}

@media (min-width: 641px) {
  .help-fab {
    display: flex;
  }
}

.help-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1.5rem;
}

.help-modal-overlay.open {
  display: flex;
}

.help-modal {
  background: var(--nav-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.help-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.help-modal-header h2 {
  margin: 0;
  color: var(--accent);
  font-size: 1.2rem;
}

.help-modal-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
}

.help-refresh {
  margin: 0 0 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.help-refresh-title {
  margin: 0 0 0.4rem;
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 700;
}

.help-refresh-link,
.help-refresh-link:visited {
  color: #3b82f6;
  text-decoration: underline;
  font-size: 0.95rem;
}

.help-refresh-link:hover {
  color: #60a5fa;
}

.help-refresh-or {
  color: var(--muted-text);
  font-size: 0.9rem;
  margin: 0 0.2rem 0 0.35rem;
}

.help-refresh .help-key {
  vertical-align: middle;
}

.help-group + .help-group {
  margin-top: 1.1rem;
}

.help-group-title {
  margin: 0 0 0.55rem;
  color: var(--muted-text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.help-key-sep {
  color: var(--muted-text);
  font-size: 0.8rem;
  padding: 0 0.1rem;
}

/* The shortcuts window must never need scrolling, so it tightens up on short
   and narrow screens, and lays the groups out as columns when it's wide but
   short (e.g. a phone held sideways). */
@media (max-height: 700px) {
  .help-modal-overlay {
    padding: 0.75rem;
  }

  .help-modal {
    padding: 1rem 1.25rem;
    max-height: 94vh;
  }

  .help-modal-header {
    margin-bottom: 0.6rem;
  }

  .help-refresh {
    margin-bottom: 0.7rem;
    padding-bottom: 0.6rem;
  }

  .help-refresh-title {
    margin-bottom: 0.25rem;
    font-size: 1rem;
  }

  .help-group + .help-group {
    margin-top: 0.7rem;
  }

  .help-group-title {
    margin-bottom: 0.35rem;
  }

  .help-shortcut-list {
    gap: 0.4rem;
  }
}

@media (max-height: 700px) and (min-width: 600px) {
  .help-modal {
    max-width: 800px;
  }

  .help-groups {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0 1.5rem;
  }

  .help-group + .help-group {
    margin-top: 0;
  }
}

@media (max-height: 600px) {
  .help-modal {
    padding: 0.8rem 1rem;
  }

  .help-modal-header h2 {
    font-size: 1.05rem;
  }

  .help-refresh-title {
    font-size: 0.95rem;
  }

  .help-shortcut-list {
    gap: 0.3rem;
  }

  .help-key {
    padding: 0.1rem 0.35rem;
    font-size: 0.72rem;
  }

  .help-shortcut-desc {
    font-size: 0.8rem;
    line-height: 1.25;
  }
}

@media (max-height: 440px) {
  .help-modal-overlay {
    padding: 0.5rem;
  }

  .help-modal {
    padding: 0.6rem 0.9rem;
    max-height: 96vh;
  }

  .help-modal-header {
    margin-bottom: 0.3rem;
  }

  .help-modal-header h2 {
    font-size: 0.95rem;
  }

  .help-refresh {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15rem 0.6rem;
    margin-bottom: 0.4rem;
    padding-bottom: 0.4rem;
  }

  .help-refresh-title {
    margin: 0;
    font-size: 0.9rem;
  }

  .help-group-title {
    margin-bottom: 0.25rem;
  }

  .help-shortcut-list {
    gap: 0.2rem;
  }
}

@media (max-width: 520px) {
  .help-modal-overlay {
    padding: 0.5rem;
  }

  .help-modal {
    padding: 0.85rem 1rem;
    max-height: 96vh;
  }

  .help-modal-header h2 {
    font-size: 1.05rem;
  }

  .help-refresh-title {
    font-size: 1rem;
  }

  .help-refresh-link,
  .help-refresh-link:visited {
    font-size: 0.85rem;
  }

  .help-shortcut-list {
    gap: 0.3rem;
  }

  .help-shortcut-list li {
    gap: 0.6rem;
  }

  .help-key {
    min-width: 1.4rem;
    padding: 0.1rem 0.35rem;
    font-size: 0.72rem;
  }

  .help-shortcut-desc {
    font-size: 0.8rem;
    line-height: 1.25;
  }
}

.help-shortcut-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.help-shortcut-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.help-shortcut-keys {
  align-items: center;
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.help-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-family: monospace;
  font-size: 0.82rem;
}

.help-shortcut-desc {
  color: var(--muted-text);
  text-align: right;
  font-size: 0.9rem;
}

.firefly-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9998;
}

.firefly {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #f8ffc0 0%, #d9ff6e 45%, rgba(217, 255, 110, 0) 70%);
  box-shadow: 0 0 6px 2px rgba(217, 255, 110, 0.85), 0 0 14px 5px rgba(180, 255, 120, 0.35);
  animation-name: firefly-float;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

@keyframes firefly-float {
  0% {
    transform: translate(0, 0);
    opacity: 0.15;
  }
  20% {
    opacity: 1;
  }
  25% {
    transform: translate(var(--tx1), var(--ty1));
  }
  45% {
    opacity: 0.25;
  }
  50% {
    transform: translate(var(--tx2), var(--ty2));
  }
  70% {
    opacity: 1;
  }
  75% {
    transform: translate(var(--tx3), var(--ty3));
  }
  100% {
    transform: translate(0, 0);
    opacity: 0.15;
  }
}

header {
  background: var(--nav-bg);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar-width);
  flex-shrink: 0;
}

nav {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  text-decoration: none;
  padding: 0 0.5rem;
  margin-bottom: 1.5rem;
  display: block;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}

.nav-links a {
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  padding: 0.6rem 0.5rem;
  border-radius: 6px;
  border-left: 3px solid transparent;
  display: block;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-links a:hover {
  color: var(--accent);
  background: var(--bg);
}

.nav-links a.active {
  color: var(--accent);
  border-left-color: var(--accent-light);
  background: var(--bg);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  width: 100%;
}

.hero {
  text-align: center;
}

.hero-img-toggle {
  display: inline-block;
  max-width: 320px;
  width: 100%;
  margin: 1.5rem 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.hero-img-toggle:hover {
  opacity: 0.92;
  transform: translateY(-2px);
}

.hero img {
  display: block;
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.hero .hero-img-dark {
  display: none;
}

html.dark-mode .hero-img-light {
  display: none;
}

html.dark-mode .hero-img-dark {
  display: block;
}

.hero h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.hero p {
  color: var(--bright-green);
  font-weight: 600;
  font-size: 1.1rem;
}

h1 {
  font-size: 1.8rem;
}

.tab-buttons {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin: 1.5rem 0 2rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .tab-buttons {
    justify-content: center;
    flex-wrap: nowrap;
    gap: 0.25rem;
  }

  .tab-buttons button {
    padding: 0.5rem 0.4rem;
    font-size: 0.85rem;
  }
}

.tab-buttons button {
  background: none;
  border: 2px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  padding: 0.6rem 1rem;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tab-buttons button:hover {
  color: var(--accent);
}

.tab-buttons button.active {
  color: var(--accent);
  border-color: var(--accent-light);
  background: color-mix(in srgb, var(--accent-light) 25%, transparent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (min-width: 641px) {
  .tile-grid > :last-child:nth-child(3n + 1) {
    grid-column: 1 / -1;
    max-width: calc((100% - 2rem) / 3);
    justify-self: center;
  }

  #games .tile-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
  }

  #games .tile-card {
    padding: 0.85rem 0.5rem;
    gap: 0.3rem;
  }

  #games .tile-emoji {
    font-size: 1.7rem;
  }

  #games .tile-grid > :last-child:nth-child(3n + 1) {
    grid-column: auto;
    max-width: none;
    justify-self: auto;
  }
}

.tile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: var(--nav-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.75rem 1rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  text-align: center;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tile-card:hover {
  border-color: var(--accent-light);
  transform: translateY(-2px);
}

.tile-flag {
  width: 100%;
  max-width: 72px;
  height: auto;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--border);
}

.tile-emoji {
  font-size: 2.5rem;
  line-height: 1;
}

@media (max-width: 640px) {
  .tile-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.music-plus-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 150px));
  grid-template-rows: repeat(3, auto);
  gap: 0.6rem;
  justify-content: center;
}

#music .tile-card {
  padding: 1rem 0.6rem;
  gap: 0.35rem;
}

#music .tile-emoji {
  font-size: 1.8rem;
}

.music-plus-top {
  grid-column: 2;
  grid-row: 1;
}

.music-plus-left {
  grid-column: 1;
  grid-row: 2;
}

.music-plus-center {
  grid-column: 2;
  grid-row: 2;
}

.music-plus-right {
  grid-column: 3;
  grid-row: 2;
}

.music-plus-bottom {
  grid-column: 2;
  grid-row: 3;
}

@media (max-width: 640px) {
  .music-plus-grid {
    grid-template-columns: 1fr 1fr;
  }

  .music-plus-top,
  .music-plus-left,
  .music-plus-center,
  .music-plus-right,
  .music-plus-bottom {
    grid-column: auto;
    grid-row: auto;
  }

  .music-plus-grid > :last-child:nth-child(2n + 1) {
    grid-column: 1 / -1;
  }
}

.music-track-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.music-track-list[hidden] {
  display: none;
}

.embed-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.25rem;
  background: var(--nav-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  transition: opacity 0.3s ease;
}

.embed-placeholder a {
  color: inherit;
  text-decoration: underline;
}

.embed-placeholder-done {
  opacity: 0;
  pointer-events: none;
}

.music-artist-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin: 0 0 1.5rem;
}

.music-artist-tab-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  padding: 0.5rem 1rem;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.music-artist-tab-btn:hover {
  color: var(--accent);
}

.music-artist-tab-btn.active {
  color: var(--accent);
  border-color: var(--accent-light);
  background: color-mix(in srgb, var(--accent-light) 25%, transparent);
}

.spotify-embed {
  position: relative;
  width: 100%;
  max-width: 640px;
  height: 152px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.spotify-embed.spotify-embed-album {
  height: 352px;
}

.spotify-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.fact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.fact-list li {
  background: var(--nav-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.fact-list .lang-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.basics-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.basics-section h2 {
  color: var(--accent);
  margin: 0 0 0.4rem;
  font-size: 1.3rem;
}

.basics-note {
  color: var(--muted-text);
  font-size: 0.9rem;
  margin: 0 0 1rem;
  line-height: 1.5;
}

.basics-note code {
  background: var(--nav-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.85em;
}

.basics-group {
  margin-bottom: 1.5rem;
}

.basics-group h3 {
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 0.6rem;
}

.basics-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin: 0 0 1.25rem;
}

.basics-tab-btn {
  background: none;
  border: none;
  font: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.basics-tab-btn:hover {
  color: var(--accent);
}

.basics-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.basics-tab-panel {
  display: none;
}

.basics-tab-panel.active {
  display: block;
}

.tone-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.tone-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--nav-bg);
  padding: 0.75rem 0.9rem;
}

.tone-card-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.tone-symbol {
  font-size: 1.2rem;
}

.tone-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
}

.tone-effect {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--muted-text);
  line-height: 1.4;
}

.tone-example {
  margin: 0;
  font-size: 0.85rem;
  font-style: italic;
}

.ocr-target {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.ocr-target-word {
  font-size: 1.6rem;
  font-weight: 700;
  margin-right: 0.6rem;
}

.ocr-target-meta {
  color: var(--muted-text);
  font-size: 0.9rem;
}

.ocr-canvas {
  display: block;
  width: 100%;
  max-width: 440px;
  height: auto;
  aspect-ratio: 440 / 220;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

.ocr-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.ocr-btn {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform 0.1s ease;
}

.ocr-btn:hover {
  transform: translateY(-1px);
}

.ocr-btn-secondary {
  background: var(--nav-bg);
  color: var(--text);
}

.ocr-btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.ocr-result {
  margin-top: 1rem;
}

.ocr-result p {
  margin: 0.3rem 0;
}

.ocr-result-status {
  font-weight: 700;
}

.ocr-result.match .ocr-result-status {
  color: var(--bright-green);
}

.ocr-result.nomatch .ocr-result-status {
  color: #d94f4f;
}

.ocr-result-row span {
  color: var(--muted-text);
  margin-right: 0.4rem;
}

.ocr-result.error {
  color: var(--muted-text);
  font-size: 0.9rem;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.char-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--nav-bg);
}

.char-chip .chip-char {
  font-size: 1.25rem;
  line-height: 1.3;
  white-space: nowrap;
}

.char-chip .chip-translit {
  font-size: 0.7rem;
  color: var(--muted-text);
  margin-top: 0.2rem;
  text-align: center;
  white-space: nowrap;
}

.vocab-table {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.5rem 1rem;
  align-items: baseline;
}

.vocab-word {
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
}

.vocab-translit {
  color: var(--muted-text);
  font-style: italic;
  font-size: 0.88rem;
  white-space: nowrap;
}

.vocab-meaning {
  color: var(--text);
}

@media (max-width: 640px) {
  .vocab-table {
    grid-template-columns: 1fr;
    gap: 0.1rem 0;
  }

  .vocab-table > div {
    margin-bottom: 0.1rem;
  }

  .vocab-meaning {
    margin-bottom: 0.6rem;
  }
}

.project-name {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.blog-date {
  font-size: 0.85rem;
  color: var(--bright-green);
  font-weight: 600;
  margin: 0 0 0.5rem;
}

/* The whole card is clickable on the projects page, so the border/
   background moves from the <li> onto the link itself (letting it lift
   together on hover), and the <li> just becomes a plain wrapper. */
.fact-list li:has(> .project-link) {
  background: none;
  border: none;
  padding: 0;
}

.project-link {
  display: block;
  background: var(--nav-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.project-link:hover {
  border-color: var(--accent-light);
  transform: translateY(-2px);
}

.project-link .project-name {
  color: var(--accent);
}

.project-coauthors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0 1.25rem;
}

.coauthor-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  padding: 0.3rem 0.75rem 0.3rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--nav-bg);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.coauthor-chip:hover {
  border-color: var(--accent-light);
  transform: translateY(-2px);
}

.coauthor-photo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.coauthor-name {
  font-size: 1.5rem;
  font-weight: 600;
}

.video-embed {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16 / 9;
  margin: 1.5rem auto;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.video-embed:empty {
  display: none;
}

.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Project pages with a video (SnowSocial) are exactly one viewport tall:
   the video takes the space left under the text and keeps its 16:9 shape,
   shrinking to fit so the page never scrolls. */
body.project-fit {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

.project-fit .content {
  min-height: 0;
}

.project-fit main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: 1.5rem;
  padding-bottom: 1rem;
}

.project-fit .project-video-wrap {
  flex: 1 1 0;
  min-height: 9rem;
  container-type: size;
  margin-top: 1rem;
}

.project-fit .video-embed {
  width: min(100cqw, calc(100cqh * 16 / 9));
  max-width: none;
  margin: 0 auto;
}

.project-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin: 1.5rem 0;
}

.project-gallery img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

@media (min-width: 641px) {
  .project-gallery > :last-child:nth-child(2n + 1) {
    grid-column: 1 / -1;
    max-width: calc((100% - 1rem) / 2);
    justify-self: center;
  }
}

@media (max-width: 640px) {
  .project-gallery {
    grid-template-columns: 1fr;
  }
}

.recipe-image {
  width: 100%;
  max-width: 420px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  margin: 1rem 0 1.5rem;
  display: block;
}

.recipe-steps {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.game-emoji {
  font-size: 3rem;
  line-height: 1;
  margin: 0.5rem 0 1.25rem;
}

/* Game detail pages are sized to exactly fit the viewport: the image takes
   whatever space is left under the text and scales down (never up, never
   cropped) so the whole picture is always visible without scrolling. */
body.game-page {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

.game-page .content {
  min-height: 0;
}

.game-page main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: 1.5rem;
  padding-bottom: 1rem;
}

.game-page .game-emoji {
  margin: 0.25rem 0 0.75rem;
}

.game-image-wrap {
  flex: 1 1 0;
  min-height: 9rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-top: 1rem;
}

.game-image {
  display: none;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.game-image[src] {
  display: block;
}

.recipe-author {
  margin-top: 2rem;
  font-style: italic;
  color: var(--muted-text);
}

.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 1rem;
}

.back-link:hover {
  text-decoration: underline;
}

.placeholder-box {
  background: var(--nav-bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  color: var(--muted-text);
}

footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: #948c7a;
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  body {
    flex-direction: column;
  }

  header {
    position: static;
    height: auto;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  nav {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    position: relative;
  }

  .brand {
    margin-bottom: 0;
  }

  .nav-toggle {
    display: block;
  }

  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    gap: 0;
    display: none;
    padding: 0.5rem 0;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 0.9rem 1.5rem;
    width: 100%;
    border-radius: 0;
  }
}
