:root {
  --grass: #1a6b4a;
  --grass-deep: #0f4a34;
  --sun: #f0b429;
  --sky-top: #7ec8e8;
  --sky-mid: #b8e0f0;
  --sky-bottom: #e8f6ee;
  --card: #fffef8;
  --ink: #1c2b24;
  --muted: #4a6358;
  --priority: #e85d04;
  --radius: 18px;
  --tap-min: 72px;
  --font-en: "Fredoka", system-ui, sans-serif;
  --font-jp: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-jp);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 28%, var(--sky-bottom) 55%, #d4edd8 100%);
  background-attachment: fixed;
  padding: 0 0 calc(4.5rem + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

.sky {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 85% 8%, rgba(255, 220, 100, 0.55) 0%, transparent 22%),
    radial-gradient(ellipse at 12% 18%, rgba(255, 255, 255, 0.45) 0%, transparent 18%),
    radial-gradient(ellipse at 40% 10%, rgba(255, 255, 255, 0.35) 0%, transparent 14%);
  z-index: 0;
}

.hero,
.tabs,
main,
.foot {
  position: relative;
  z-index: 1;
}

.hero {
  text-align: center;
  padding: calc(1.4rem + env(safe-area-inset-top)) 1.25rem 0.75rem;
  animation: rise 0.7s ease-out both;
}

.brand {
  margin: 0;
  font-family: var(--font-en);
  font-weight: 700;
  font-size: clamp(2.4rem, 11vw, 3.4rem);
  letter-spacing: 0.02em;
  color: var(--grass-deep);
  line-height: 1;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.5);
}

.brand-jp {
  margin: 0.2rem 0 0;
  font-size: clamp(1.05rem, 4.2vw, 1.35rem);
  font-weight: 700;
  color: var(--grass);
  letter-spacing: 0.12em;
}

.tagline {
  margin: 0.55rem 0 0;
  font-size: 1rem;
  color: var(--muted);
}

.level-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  padding: 0.75rem 1rem 0.25rem;
  max-width: 40rem;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.level-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-height: 3.4rem;
  padding: 0.55rem 0.35rem;
  border: 2px solid rgba(26, 107, 74, 0.22);
  border-radius: 14px;
  background: rgba(255, 254, 248, 0.9);
  color: var(--ink);
  font-family: var(--font-jp);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.level-btn:active {
  transform: scale(0.97);
}

.level-btn[aria-pressed="true"] {
  background: var(--grass);
  color: #fff;
  border-color: var(--grass-deep);
  box-shadow: 0 3px 0 var(--grass-deep);
}

.level-btn-label {
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.2;
}

.level-btn-cefr {
  font-family: var(--font-en);
  font-weight: 600;
  font-size: 0.78rem;
  opacity: 0.9;
}

.level-btn-short {
  font-size: 0.68rem;
  opacity: 0.85;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.85rem 1rem 0.5rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  scroll-snap-align: start;
  border: 2px solid transparent;
  background: rgba(255, 254, 248, 0.85);
  color: var(--ink);
  font-family: var(--font-jp);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.65rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.2s, border-color 0.2s;
}

.tab:active {
  transform: scale(0.96);
}

.tab[aria-selected="true"] {
  background: var(--grass);
  color: #fff;
  border-color: var(--grass-deep);
  box-shadow: 0 4px 0 var(--grass-deep);
}

.tab.priority-tab[aria-selected="true"] {
  background: var(--priority);
  border-color: #c44d00;
  box-shadow: 0 4px 0 #c44d00;
}

main {
  padding: 0.4rem 1rem 1.5rem;
  max-width: 40rem;
  margin: 0 auto;
}

.section-desc {
  margin: 0 0 0.85rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  min-height: 1.3em;
}

.grid {
  display: grid;
  gap: 0.75rem;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.25rem;
  min-height: var(--tap-min);
  width: 100%;
  padding: 1rem 1.15rem;
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 3px 0 rgba(26, 107, 74, 0.18);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s;
  animation: pop 0.45s ease-out both;
}

.card:nth-child(1) { animation-delay: 0.02s; }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(4) { animation-delay: 0.11s; }
.card:nth-child(5) { animation-delay: 0.14s; }

.card:active,
.card.is-playing {
  transform: translateY(2px) scale(0.985);
  box-shadow: 0 1px 0 rgba(26, 107, 74, 0.18);
  background: #fff6d6;
}

.card.is-playing {
  outline: 3px solid var(--sun);
}

.card-en {
  font-family: var(--font-en);
  font-weight: 600;
  font-size: clamp(1.35rem, 5.5vw, 1.7rem);
  line-height: 1.25;
  color: var(--grass-deep);
}

.card-ja {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 500;
}

.card-meta {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: #e6f4ec;
  color: var(--grass);
}

.badge.star {
  background: #ffe8d6;
  color: var(--priority);
}

.foot {
  text-align: center;
  padding: 0.5rem 1rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.foot-levels {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  line-height: 1.7;
}

.foot-levels a {
  color: var(--grass-deep);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid rgba(15, 74, 52, 0.35);
}

.foot-levels a:active {
  opacity: 0.7;
}

.playing-bar {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(120%);
  z-index: 10;
  max-width: min(92vw, 24rem);
  padding: 0.75rem 1.2rem;
  border-radius: 999px;
  background: var(--grass-deep);
  color: #fff;
  font-family: var(--font-en);
  font-weight: 600;
  font-size: 1.05rem;
  box-shadow: 0 8px 24px rgba(15, 74, 52, 0.35);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.playing-bar.is-visible {
  transform: translateX(-50%) translateY(0);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 560px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
