﻿:root {
  --bg: #f5efe3;
  --panel: rgba(255, 251, 245, 0.84);
  --panel-strong: rgba(255, 248, 240, 0.96);
  --line: rgba(88, 59, 35, 0.14);
  --text: #2b1c13;
  --muted: #715748;
  --accent: #d65a31;
  --accent-deep: #8b2d16;
  --accent-soft: rgba(214, 90, 49, 0.13);
  --good: #236b42;
  --bad: #9f2d2d;
  --shadow: 0 28px 70px rgba(62, 31, 16, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(233, 190, 92, 0.35), transparent 32%),
    radial-gradient(circle at bottom right, rgba(214, 90, 49, 0.22), transparent 28%),
    linear-gradient(135deg, #f7f1e5 0%, #efe4d1 45%, #ead8bf 100%);
}

button,
input,
select {
  font: inherit;
}

.background-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(20px);
  z-index: 0;
  opacity: 0.5;
}

.orb-one {
  width: 280px;
  height: 280px;
  top: 4rem;
  right: 8%;
  background: rgba(223, 150, 61, 0.26);
}

.orb-two {
  width: 220px;
  height: 220px;
  left: 4%;
  bottom: 8%;
  background: rgba(202, 81, 43, 0.18);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1220px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
  gap: 1.25rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent-deep);
}

.hero h1,
.panel h2,
.panel h3,
#studyModeTitle {
  font-family: "Noto Sans JP", sans-serif;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 0.95;
  max-width: 12ch;
}

.hero-copy {
  max-width: 66ch;
  color: var(--muted);
  line-height: 1.6;
  margin: 1rem 0 0;
}

.hero-stats,
.results-grid,
.study-status-grid {
  display: grid;
  gap: 0.85rem;
}

.hero-stats,
.results-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.study-status-grid {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

main {
  display: block;
}

.screen {
  display: none;
}

.screen.active {
  display: grid;
}

#setupScreen.active {
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
  gap: 1.25rem;
}

#studyScreen.active,
#resultsScreen.active {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 28px;
  padding: 1.35rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel-head {
  margin-bottom: 1.1rem;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
}

.panel-head p,
.muted-note,
.inline-message,
.card-hint,
.template-box small {
  color: var(--muted);
}

.field-grid {
  display: grid;
  gap: 1rem;
}

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

.field-box {
  display: grid;
  gap: 0.55rem;
}

.field-box span {
  font-weight: 700;
}

.field-box input,
.field-box select,
.answer-form input {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
}

.toggle-row,
.actions-row,
.section-title-row,
.study-topbar {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  justify-content: space-between;
}

.toggle-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin: 1rem 0 1.25rem;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  font-weight: 700;
}

.toggle-pill input {
  accent-color: var(--accent);
}

.groups-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 0.25rem;
}

.group-grid,
.dictionary-list,
.history-list,
.mini-stats-grid,
.button-cluster,
.stack-section {
  display: grid;
  gap: 0.75rem;
}

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

.sidebar-panel {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.mini-stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.button-cluster {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.group-chip {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  padding: 0.85rem 0.9rem;
  color: var(--text);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.group-chip:hover,
.group-chip:focus-visible,
.primary-button:hover,
.secondary-button:hover,
.text-button:hover {
  transform: translateY(-1px);
}

.group-chip.active {
  border-color: rgba(214, 90, 49, 0.45);
  background: linear-gradient(135deg, rgba(255, 244, 234, 0.98), rgba(255, 230, 208, 0.96));
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
  font-weight: 800;
}

.group-example {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 1.1rem;
  display: block;
  color: var(--accent-deep);
}

.group-caption {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}

.primary-button,
.secondary-button,
.text-button {
  border: 0;
  border-radius: 16px;
  padding: 0.9rem 1.2rem;
  cursor: pointer;
  transition: transform 180ms ease, filter 180ms ease;
}

.primary-button {
  background: linear-gradient(135deg, #c94d28, #ef7a35);
  color: white;
  font-weight: 800;
  box-shadow: 0 18px 32px rgba(201, 77, 40, 0.28);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 700;
}

.text-button {
  background: transparent;
  color: var(--accent-deep);
  padding: 0;
  font-weight: 800;
}

.inline-message {
  min-height: 1.25rem;
  margin: 0;
}

.upload-box {
  position: relative;
  display: grid;
  gap: 0.3rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: 22px;
  border: 1px dashed rgba(214, 90, 49, 0.38);
  background: linear-gradient(135deg, rgba(255, 245, 237, 0.9), rgba(255, 236, 217, 0.88));
  cursor: pointer;
}

.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.template-box {
  padding: 0.95rem;
  border-radius: 18px;
  background: rgba(43, 28, 19, 0.05);
  margin-bottom: 1rem;
}

.template-box pre {
  overflow: auto;
  font-size: 0.86rem;
  line-height: 1.45;
}

.dictionary-item,
.stat-card,
.feedback-box,
.result-item,
.history-item {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.dictionary-item,
.result-item,
.history-item {
  padding: 0.9rem 1rem;
}

.dictionary-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.dictionary-title {
  font-weight: 800;
}

.dictionary-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-card {
  padding: 1rem;
}

.stat-card.compact {
  padding: 0.8rem 0.9rem;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
}

.stat-card strong {
  font-size: clamp(1.2rem, 3vw, 2.2rem);
}

.study-panel {
  display: grid;
  gap: 1.25rem;
}

.card-stage {
  padding: 2rem 1rem;
  border-radius: 28px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.85), rgba(255, 248, 240, 0.9)),
    linear-gradient(135deg, rgba(255, 244, 231, 0.9), rgba(255, 235, 215, 0.92));
  border: 1px solid rgba(214, 90, 49, 0.14);
  text-align: center;
}

.card-badge {
  display: inline-flex;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 800;
}

.card-face {
  margin: 1rem 0 0.4rem;
  font-family: "Noto Sans JP", sans-serif;
  font-size: clamp(3.6rem, 13vw, 7rem);
  line-height: 1;
}

.answer-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
}

.feedback-box {
  min-height: 4.5rem;
  padding: 1rem 1.1rem;
  font-weight: 700;
}

.feedback-box.hidden {
  display: block !important;
  visibility: hidden;
}

.feedback-box.good {
  color: var(--good);
  border-color: rgba(35, 107, 66, 0.2);
  background: rgba(35, 107, 66, 0.08);
}

.feedback-box.bad {
  color: var(--bad);
  border-color: rgba(159, 45, 45, 0.22);
  background: rgba(159, 45, 45, 0.08);
}

.hidden {
  display: none !important;
}

.result-breakdown {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.result-item strong {
  display: block;
  margin-bottom: 0.3rem;
}

.result-item span {
  display: block;
  color: var(--muted);
}

@media (max-width: 980px) {
  .hero,
  #setupScreen.active,
  .groups-layout,
  .two-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero h1 {
    max-width: none;
  }

  .group-grid,
  .hero-stats,
  .results-grid,
  .study-status-grid,
  .mini-stats-grid,
  .button-cluster {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .study-topbar {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 1rem, 1220px);
    padding-top: 1rem;
  }

  .panel {
    padding: 1rem;
    border-radius: 24px;
  }

  .group-grid,
  .hero-stats,
  .results-grid,
  .study-status-grid,
  .answer-form,
  .mini-stats-grid,
  .button-cluster {
    grid-template-columns: minmax(0, 1fr);
  }

  .toggle-row,
  .actions-row,
  .section-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .card-face {
    font-size: clamp(3.2rem, 24vw, 5.4rem);
  }
}


.history-item strong {
  display: block;
  margin-bottom: 0.3rem;
}

.history-item span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.mini-stat-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
}
