/* AI Driver — Neubrutalism Racing */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700;900&display=swap');

:root {
  --bg: #F5F0E8;
  --black: #222;
  --border: 3px solid #222;
  --shadow: 4px 4px 0 #222;
  --red: #FF3B30;
  --yellow: #FFD60A;
  --green: #34C759;
  --white: #fff;
  --radius: 6px;
}

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

html, body {
  height: 100%;
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--black);
  overflow: hidden;
}

/* --- Screens --- */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
}
.screen.active { display: flex; }

/* --- Title --- */
.title-screen {
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}
.title-mascot {
  font-size: clamp(3rem, 12vw, 5rem);
  line-height: 1;
}
.title-screen h1 {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  text-shadow: 3px 3px 0 var(--yellow);
}
.accent { color: var(--red); }
.subtitle {
  font-size: clamp(0.9rem, 3vw, 1.2rem);
  color: #555;
  margin-top: -4px;
}
.title-stats {
  font-size: 0.85rem;
  color: #777;
  min-height: 1.2em;
}
.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 12px 32px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--black);
}
.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--black);
}
.btn-primary {
  background: var(--red);
  color: var(--white);
}
.btn-small {
  padding: 8px 20px;
  font-size: 0.9rem;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow);
}

/* --- Cards Screen --- */
.cards-screen {
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
}
.cards-screen h2 {
  font-size: 1.4rem;
  font-weight: 900;
}
.card-count {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--red);
}
.card-hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  max-width: 800px;
}
.card {
  width: 140px;
  padding: 16px 12px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  text-align: center;
  user-select: none;
}
.card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--black);
}
.card.selected {
  border-color: var(--red);
  box-shadow: 4px 4px 0 var(--red);
  transform: translateY(-6px);
  background: #FFF5F5;
}
.card-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}
.card-name {
  font-weight: 900;
  font-size: 0.9rem;
  margin-bottom: 4px;
}
.card-desc {
  font-size: 0.72rem;
  color: #666;
  line-height: 1.3;
}

/* --- Race Screen --- */
.race-screen {
  padding: 0;
  overflow: hidden;
  background: #333;
}
.race-hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--black);
  color: var(--white);
  font-weight: 700;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-height: 40px;
  z-index: 1;
}
.hud-timer {
  font-size: 1.3rem;
  color: var(--yellow);
}
.hud-item span {
  color: var(--yellow);
}
.hud-track {
  font-size: 0.75rem;
  color: #aaa;
  letter-spacing: 0.05em;
}
.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}
#race-canvas {
  display: block;
  width: 800px;
  height: 600px;
  max-width: 100%;
  max-height: calc(100vh - 56px);
}

/* --- Result Screen --- */
.result-screen {
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
}
.result-card {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 36px;
  min-width: 280px;
  max-width: 420px;
}
.result-card h2 {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 16px;
}
.result-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin: 12px 0;
}
.rstat { text-align: center; }
.rstat .label {
  font-size: 0.75rem;
  color: #777;
  margin-bottom: 2px;
}
.rstat .value {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}
.skill-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
}
.skill-label {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.skill-bar {
  flex: 1;
  height: 14px;
  background: #eee;
  border: 2px solid var(--black);
  border-radius: 7px;
  overflow: hidden;
}
.skill-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green));
  width: 0%;
  transition: width 0.8s ease;
}
.skill-text {
  font-size: 0.85rem;
  font-weight: 900;
  min-width: 45px;
}
.ai-comment {
  margin: 12px 0;
  padding: 10px 14px;
  background: #FFF8F0;
  border: 2px solid #eee;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #444;
}
.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

/* --- Mobile --- */
@media (max-width: 600px) {
  .card {
    width: 110px;
    padding: 12px 8px;
  }
  .card-icon { font-size: 1.5rem; }
  .card-name { font-size: 0.8rem; }
  .card-desc { font-size: 0.65rem; }
  .result-stats { gap: 16px; }
  .rstat .value { font-size: 1.2rem; }
  .result-card { padding: 20px 24px; }
}

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