@import url('https://fonts.googleapis.com/css2?family=Shippori+Mincho:wght@500;700&family=Zen+Kaku+Gothic+New:wght@400;500;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --washi:      #F2EDE3;
  --washi-dark: #E7DFCE;
  --ai:         #1F3A5F;
  --ai-light:   #33547F;
  --sumi:       #232323;
  --shu:        #B23A2E;
  --matcha:     #6B7A4F;
  --muted:      #746C5E;
  --line:       #D8CFBB;

  --font-display: 'Shippori Mincho', 'Hiragino Mincho ProN', serif;
  --font-body: 'Zen Kaku Gothic New', 'Hiragino Sans', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--washi);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(35,35,35,0.035) 1px, transparent 0);
  background-size: 18px 18px;
  color: var(--sumi);
  font-family: var(--font-body);
  min-height: 100vh;
}

a { color: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--washi);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--washi);
  background: var(--ai);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.02em;
}
.topnav { display: flex; gap: 22px; font-size: 14px; }
.topnav a {
  text-decoration: none;
  color: var(--muted);
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.topnav a:hover { color: var(--sumi); }
.topnav a.active { color: var(--ai); border-color: var(--shu); font-weight: 600; }

/* ---------- Practice page ---------- */
.practice-wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.session-bar {
  display: flex;
  gap: 28px;
  margin-bottom: 34px;
}
.session-stat { display: flex; flex-direction: column; align-items: center; }
.session-stat .num {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--ai);
}
.session-stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 2px;
}

.stage { width: 100%; display: flex; flex-direction: column; align-items: center; }

.card-shell {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 4 / 5;
  perspective: 1200px;
}

.card {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(.4,.2,.2,1);
}
.card.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius);
  background: #FBF8F2;
  border: 1px solid var(--line);
  box-shadow: 0 2px 0 var(--line), 0 12px 28px rgba(35,35,35,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}
.card-back { transform: rotateY(180deg); }

.type-tag {
  position: absolute;
  top: 16px;
  left: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ai);
  border: 1px solid var(--ai);
  border-radius: 999px;
  padding: 3px 10px;
  letter-spacing: 0.04em;
}

.jp {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 64px;
  line-height: 1.2;
  color: var(--sumi);
}
.jp.small { font-size: 40px; margin-bottom: 6px; }

.reading-front {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--muted);
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.reading {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 14px;
}

.masu {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ai);
  background: var(--washi-dark);
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 16px;
}

.meaning {
  font-size: 19px;
  font-weight: 500;
  color: var(--sumi);
  margin-bottom: 20px;
}

.box-dots { display: flex; gap: 6px; }
.box-dots span {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--line);
  display: inline-block;
}
.box-dots span.filled { background: var(--ai); }

.stamp {
  position: absolute;
  top: 50%; left: 50%;
  width: 100px; height: 100px;
  margin: -50px 0 0 -50px;
  border: 5px solid var(--shu);
  border-radius: 50%;
  color: var(--shu);
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transform: scale(1.6) rotate(-12deg);
  pointer-events: none;
  z-index: 5;
}
.stamp.show {
  animation: stampIn 0.5s cubic-bezier(.2,1.4,.4,1) forwards;
}
@keyframes stampIn {
  0%   { opacity: 0; transform: scale(2.2) rotate(-12deg); }
  60%  { opacity: 0.9; transform: scale(0.92) rotate(-12deg); }
  100% { opacity: 0.85; transform: scale(1) rotate(-12deg); }
}

.controls {
  margin-top: 28px;
  display: flex;
  gap: 14px;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  padding: 12px 26px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ai); color: var(--washi); }
.btn-primary:hover { background: var(--ai-light); }
.btn-miss { background: #EDE3DD; color: var(--shu); border: 1px solid var(--shu); }
.btn-miss:hover { background: #F6E9E4; }
.btn-hit { background: var(--matcha); color: var(--washi); }
.btn-hit:hover { filter: brightness(1.08); }

.link-btn {
  background: none; border: none; text-decoration: underline;
  color: var(--ai); cursor: pointer; font-size: inherit; font-family: inherit; padding: 0;
}

.empty-state {
  margin-top: 40px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  max-width: 340px;
  line-height: 1.6;
}

/* ---------- Login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: #FBF8F2;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 44px 40px;
  text-align: center;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 12px 28px rgba(35,35,35,0.08);
}
.login-card .seal {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--ai);
  color: var(--washi);
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.login-card h1 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0;
}
.login-card .subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  margin-bottom: 24px;
}
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { text-align: left; font-size: 13px; color: var(--muted); }
.login-form input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 15px;
  font-family: var(--font-body);
}
.login-form button {
  margin-top: 8px;
  padding: 11px;
  background: var(--ai);
  color: var(--washi);
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
}
.login-form button:hover { background: var(--ai-light); }
.error { color: var(--shu); font-size: 13px; margin: 0; }

/* ---------- Stats page ---------- */
.stats-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}
.stat-tile {
  background: #FBF8F2;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-tile .num {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--ai);
}
.stat-tile .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel {
  background: #FBF8F2;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 22px;
}
.panel h2 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0 0 4px;
}
.panel-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
}

.box-chart { display: flex; flex-direction: column; gap: 10px; }
.box-row { display: flex; align-items: center; gap: 12px; }
.box-row .box-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  width: 46px;
}
.box-row .box-track {
  flex: 1;
  height: 10px;
  background: var(--washi-dark);
  border-radius: 999px;
  overflow: hidden;
}
.box-row .box-fill {
  height: 100%;
  background: var(--ai);
  border-radius: 999px;
}
.box-row .box-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--sumi);
  width: 28px;
  text-align: right;
}

.verb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.verb-table th, .verb-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.verb-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.verb-table td:first-child { font-family: var(--font-display); font-size: 17px; }

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .jp { font-size: 48px; }
  .topbar { padding: 14px 16px; }
  .topnav { gap: 14px; font-size: 13px; }
}
