/* ============================================
   AI誤訳 — B+C Hybrid: Neubrutalism × Report
   Manga-bold game feel + official report world
   ============================================ */

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

:root {
  --paper: #F5F0E8;
  --white: #FFFFFF;
  --ink: #1a1a1a;
  --ink-mid: #4a4a4a;
  --ink-faint: #8a8a7a;

  --red: #E53935;
  --red-dark: #B71C1C;
  --yellow: #FFD600;
  --yellow-soft: #FFF8E1;
  --blue: #1565C0;

  --border: 3px solid var(--ink);
  --border-thick: 5px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-red: 4px 4px 0 var(--red-dark);
  --max-w: 440px;

  --font: 'Noto Sans JP', sans-serif;
  --font-num: 'Chakra Petch', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Paper texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* === CARD / PANEL === */
.card {
  border: var(--border);
  background: var(--white);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.card--thick { border-width: 5px; }

/* Screentone overlay */
.card--toned::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, var(--ink) 0.6px, transparent 0.6px);
  background-size: 6px 6px;
  opacity: 0.05;
  pointer-events: none;
}

/* Dot-grid (Bauhaus element) */
.dot-grid::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, var(--ink) 0.8px, transparent 0.8px);
  background-size: 16px 16px;
  opacity: 0.06;
  pointer-events: none;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 13px 28px;
  border: var(--border);
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.btn--red {
  background: var(--red);
  color: var(--white);
  border-color: var(--red-dark);
  box-shadow: var(--shadow-red);
}
.btn--red:active { box-shadow: 2px 2px 0 var(--red-dark); }

.btn--yellow {
  background: var(--yellow);
  color: var(--ink);
}

.btn--blue {
  background: var(--blue);
  color: var(--white);
  border-color: #0D47A1;
  box-shadow: 4px 4px 0 #0D47A1;
}
.btn--blue:active { box-shadow: 2px 2px 0 #0D47A1; }

.btn--ghost {
  background: transparent;
  border: 2px solid var(--ink-faint);
  box-shadow: none;
  color: var(--ink-mid);
  font-size: 0.9rem;
  font-weight: 500;
}
.btn--ghost:active { background: var(--paper); box-shadow: none; transform: none; }

.btn--full { width: 100%; }

.btn--large { font-size: 1.25rem; padding: 16px 32px; }

/* Buzz button — the star */
.btn--buzz {
  font-size: 1.5rem;
  font-weight: 900;
  padding: 20px 48px;
  width: 100%;
  background: var(--yellow);
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  animation: buzz-pulse 1.8s ease-in-out infinite;
}
.btn--buzz:active {
  animation: none;
  box-shadow: 2px 2px 0 var(--ink);
}
@keyframes buzz-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

/* === LABELS / BADGES (Bauhaus) === */
.label {
  display: inline-block;
  background: var(--ink);
  color: var(--white);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 10px;
  letter-spacing: 0.12em;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 9999px;
  border: 2px solid var(--ink);
}
.badge--blue { background: var(--blue); color: var(--white); border-color: var(--blue); }
.badge--red { background: var(--red); color: var(--white); border-color: var(--red); }
.badge--yellow { background: var(--yellow); color: var(--ink); }

/* === TITLE SCREEN === */
.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90dvh;
  text-align: center;
  gap: 20px;
}

.title-logo {
  position: relative;
  display: inline-block;
  line-height: 1.1;
}
.title-logo__ai {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: clamp(1.8rem, 8vw, 2.5rem);
  color: var(--red);
  vertical-align: super;
  margin-right: 2px;
}
.title-logo__text {
  font-size: clamp(3rem, 14vw, 4.5rem);
  font-weight: 900;
  letter-spacing: -0.04em;
}
.title-logo::before {
  content: '';
  position: absolute;
  top: 55%;
  left: -8%;
  width: 116%;
  height: 35%;
  background: var(--yellow);
  transform: translateY(-50%) rotate(-2.5deg);
  z-index: -1;
}

.title-sub {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-mid);
  line-height: 1.7;
  max-width: 340px;
}

/* Genre grid */
.genre-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.genre-card {
  border: 2px solid var(--ink);
  background: var(--white);
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s, box-shadow 0.08s;
}
.genre-card:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--ink);
}
.genre-card.selected { background: var(--yellow); }
.genre-card__icon { font-size: 1.6rem; margin-bottom: 4px; }
.genre-card__name { font-size: 0.82rem; font-weight: 700; }
.genre-card__count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--ink-faint);
  margin-top: 2px;
}

/* Stats bar */
.stats-bar {
  display: flex;
  justify-content: space-around;
  width: 100%;
  padding: 12px 0;
  border-top: 2px solid var(--ink);
  margin-top: 8px;
}
.stats-bar__item { text-align: center; }
.stats-bar__val {
  font-family: var(--font-num);
  font-size: 1.2rem;
  font-weight: 700;
  display: block;
}
.stats-bar__lbl { font-size: 0.7rem; color: var(--ink-faint); }

/* === GAME SCREEN === */
.game-screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

/* Top bar */
.game-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.game-bar__counter {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
}
.game-bar__counter b { color: var(--red); }

/* Report panel (B bold + C report feel) */
.report-panel {
  border: var(--border-thick);
  background: var(--white);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.report-panel__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 2px solid var(--paper);
}
.report-panel__case {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
}
.report-panel__body {
  padding: 20px 16px;
  min-height: 160px;
}

/* AI text */
.ai-text {
  font-size: 1.1rem;
  line-height: 2;
  font-weight: 500;
}
.ai-text .ch {
  opacity: 0;
  transition: opacity 0.05s;
}
.ai-text .ch.v { opacity: 1; }
.ai-text .ch.pop {
  color: var(--red);
  font-weight: 700;
  animation: ch-pop 0.3s ease-out forwards;
}
@keyframes ch-pop {
  0% { transform: scale(1.4); }
  100% { transform: scale(1); color: var(--ink); font-weight: 500; }
}

/* Blinking cursor */
.cursor {
  display: inline-block;
  width: 2px;
  height: 1.15em;
  background: var(--red);
  margin-left: 1px;
  vertical-align: text-bottom;
  animation: blink 0.6s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Urgency */
.report-panel.urgent { border-color: var(--red); }
.report-panel.urgent::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #FFF0F0;
  opacity: 0;
  animation: pulse-bg 0.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulse-bg { 50% { opacity: 0.5; } }

/* Score decay indicator */
.score-decay {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
  padding: 4px 0;
}
.score-decay b {
  font-size: 1.1rem;
  color: var(--ink);
}

/* Buzz section */
.buzz-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  margin-top: auto;
}
.buzz-hint { font-size: 0.72rem; color: var(--ink-faint); }

/* === ANSWER INPUT === */
.answer-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: auto;
}
.answer-display {
  border: var(--border);
  background: var(--white);
  padding: 14px;
  text-align: center;
}
.answer-display__text {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  min-width: 80px;
  display: inline-block;
  border-bottom: 3px solid var(--ink);
  padding-bottom: 4px;
  min-height: 1.8em;
}
.answer-display__text:empty::after {
  content: '？';
  color: var(--ink-faint);
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.char-btn {
  font-family: var(--font);
  font-size: 1.2rem;
  font-weight: 700;
  padding: 14px 4px;
  border: 2px solid var(--ink);
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.06s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.char-btn:active { transform: scale(0.9); background: var(--paper); }
.char-btn.used { opacity: 0.2; pointer-events: none; }

.answer-controls {
  display: flex;
  gap: 8px;
}
.answer-controls .btn { flex: 1; font-size: 0.95rem; padding: 12px 8px; }

/* === RESULT SCREEN === */
.result-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 90dvh;
  padding-top: 20px;
  gap: 16px;
}

.result-big {
  font-size: clamp(2.2rem, 11vw, 3.8rem);
  font-weight: 900;
  text-align: center;
  line-height: 1.2;
}
.result-big--correct { color: var(--red); }
.result-big--wrong { color: var(--ink-mid); }

.result-enter { animation: burst 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
@keyframes burst {
  0% { transform: scale(0.3) rotate(-8deg); opacity: 0; }
  50% { transform: scale(1.1) rotate(1deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.result-shake { animation: shake 0.4s ease-out; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

/* Answer reveal */
.answer-reveal { text-align: center; padding: 8px 0; }
.answer-reveal__lbl {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--ink-faint);
  letter-spacing: 0.15em;
  margin-bottom: 4px;
}
.answer-reveal__text { font-size: 2.2rem; font-weight: 900; }

/* Score card (report style) */
.score-card {
  border: var(--border-thick);
  background: var(--white);
  box-shadow: var(--shadow);
  width: 100%;
}
.score-card__header {
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  padding: 6px 16px;
  text-align: center;
}
.score-card__body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.score-row__lbl { font-size: 0.82rem; color: var(--ink-mid); }
.score-row__val { font-family: var(--font-num); font-size: 1.4rem; font-weight: 700; }
.score-row__val--big { font-size: 2.8rem; color: var(--red); }

/* Rank badge (circle — Bauhaus) */
.rank-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--white);
  border: 3px solid var(--ink);
}
.rank-circle--s { background: var(--yellow); color: var(--ink); }
.rank-circle--a { background: var(--red); }
.rank-circle--b { background: var(--blue); }
.rank-circle--c { background: var(--ink-mid); }
.rank-circle--d { background: var(--ink-faint); }

/* Full text box */
.full-text-box {
  border: 2px solid var(--ink);
  background: var(--yellow-soft);
  padding: 14px 16px;
  font-size: 0.88rem;
  line-height: 1.8;
  width: 100%;
  position: relative;
}
.full-text-box__lbl {
  position: absolute;
  top: -10px;
  left: 12px;
  background: var(--yellow);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 8px;
  letter-spacing: 0.08em;
}

/* Share area */
.share-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* === SCREEN TRANSITIONS === */
.screen-enter { animation: screen-in 0.25s ease-out; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === RESPONSIVE === */
@media (max-width: 380px) {
  .char-grid { gap: 6px; }
  .char-btn { font-size: 1rem; padding: 11px 3px; }
  .ai-text { font-size: 1rem; }
}

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