:root {
  color-scheme: dark;
  --bg: #05070a;
  --surface: #0b1016;
  --surface-2: #101822;
  --surface-container: #16212d;
  --text: #dff7ff;
  --muted: #7d93a3;
  --dim: #4b5d6b;
  --primary: #00e5ff;
  --primary-light: rgba(0, 229, 255, 0.12);
  --on-primary: #00161a;
  --accent: #ff2bd6;
  --gold: #ffd54f;
  --hit: #39ff88;
  --miss: #ff3b5c;
  --pending: #ffcc33;
  --outline: rgba(0, 229, 255, 0.14);
  --outline-strong: rgba(0, 229, 255, 0.35);
  --grade-s: #ff2bd6;
  --grade-a: #00e5ff;
  --grade-b: #39ff88;
  --radius-card: 14px;
  --radius-pill: 999px;
  --font-mono: "Share Tech Mono", ui-monospace, Menlo, monospace;
  --font-logo: "Orbitron", "Share Tech Mono", sans-serif;
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  min-height: 100%;
  min-height: 100dvh;
}

body {
  margin: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(0, 229, 255, 0.12), transparent 55%),
    radial-gradient(80% 50% at 100% 40%, rgba(255, 43, 214, 0.08), transparent 50%),
    radial-gradient(70% 40% at 0% 80%, rgba(255, 213, 79, 0.05), transparent 45%),
    linear-gradient(rgba(0, 229, 255, 0.035) 1px, transparent 1px) 0 0 / 100% 28px,
    linear-gradient(90deg, rgba(0, 229, 255, 0.035) 1px, transparent 1px) 0 0 / 28px 100%,
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

html.fx-off body::after {
  display: none;
}

body.modal-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

a {
  color: var(--primary);
}

.app {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}

#view {
  animation: view-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header {
  --header-pt: calc(0.7rem + env(safe-area-inset-top, 0px));
  position: sticky;
  top: 0;
  z-index: 50;
  padding: var(--header-pt) 1rem 0.55rem;
  background: rgba(5, 7, 10, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease;
}

.header.scrolled {
  border-bottom-color: var(--outline);
}

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

.logo {
  font-family: var(--font-logo);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  margin: 0;
  line-height: 1.1;
}

.logo b {
  color: var(--accent);
  text-shadow: 0 0 6px rgba(255, 43, 214, 0.8), 0 0 18px rgba(255, 43, 214, 0.4);
}

.logo-sub {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.12em;
  margin-top: 0.15rem;
}

.hit-rate-pill {
  text-align: right;
  flex-shrink: 0;
}

.hit-rate-pill .label {
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.hit-rate-pill .value {
  font-family: var(--font-logo);
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--hit);
  text-shadow: 0 0 12px rgba(57, 255, 136, 0.55);
  font-variant-numeric: tabular-nums;
}

.tab-label {
  margin: 0.85rem 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--primary);
  text-transform: uppercase;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.chip {
  border: 1px solid var(--outline);
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.chip.active {
  border-color: var(--outline-strong);
  color: var(--text);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
}

.chip-fav {
  border-color: rgba(255, 43, 214, 0.35);
}

.chip-fav.active {
  color: var(--accent);
  box-shadow: 0 0 12px rgba(255, 43, 214, 0.35);
}

select.chip-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 1.4rem;
}

.main {
  padding: 0 1rem 1rem;
  flex: 1;
}

.lead {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.85rem;
}

.card {
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  border: 1px solid var(--outline);
  border-radius: var(--radius-card);
  padding: 0.85rem 0.9rem;
  margin-bottom: 10px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(0, 229, 255, 0.06), transparent 40%, rgba(255, 43, 214, 0.04));
  pointer-events: none;
}

.card-clickable {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card-clickable:active {
  transform: scale(0.985);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  position: relative;
  z-index: 1;
}

.card-name {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0;
  line-height: 1.35;
}

.card-meta {
  font-size: 0.68rem;
  color: var(--dim);
  margin-top: 0.15rem;
}

.score-badge {
  flex-shrink: 0;
  text-align: center;
  min-width: 3.2rem;
}

.score-num {
  font-family: var(--font-logo);
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-num.grade-s {
  color: var(--grade-s);
  text-shadow: 0 0 14px rgba(255, 43, 214, 0.6);
}

.score-num.grade-a {
  color: var(--grade-a);
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
}

.score-num.grade-b {
  color: var(--grade-b);
  text-shadow: 0 0 14px rgba(57, 255, 136, 0.45);
}

.grade-tag {
  font-family: var(--font-logo);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.4rem 0;
  position: relative;
  z-index: 1;
}

.badge {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--outline);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
}

.badge.points {
  color: var(--gold);
  border-color: rgba(255, 213, 79, 0.35);
}

.badge.tag {
  color: var(--primary);
  border-color: rgba(0, 229, 255, 0.25);
}

.badge.degraded {
  color: var(--pending);
  border-color: rgba(255, 204, 51, 0.4);
}

.machines {
  font-size: 0.75rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.machines strong {
  color: var(--text);
  font-weight: 700;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.55rem;
  position: relative;
  z-index: 1;
}

.btn-sm {
  flex: 1;
  border: 1px solid var(--outline);
  background: var(--surface-container);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 800;
}

.btn-sm.primary {
  border-color: rgba(255, 43, 214, 0.45);
  color: var(--accent);
}

.btn-sm.fav-on {
  border-color: rgba(255, 43, 214, 0.6);
  box-shadow: 0 0 10px rgba(255, 43, 214, 0.25);
}

.memo-input {
  width: 100%;
  margin-top: 0.45rem;
  border: 1px dashed var(--outline);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-size: 0.72rem;
  color: var(--text);
  resize: vertical;
  min-height: 2.2rem;
  font-family: var(--font-mono);
}

.memo-input:focus {
  outline: none;
  border-color: var(--outline-strong);
}

.result-samai {
  font-family: var(--font-logo);
  font-size: 1.1rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.result-samai.hit {
  color: var(--hit);
  text-shadow: 0 0 10px rgba(57, 255, 136, 0.45);
}

.result-samai.miss {
  color: var(--miss);
  text-shadow: 0 0 10px rgba(255, 59, 92, 0.45);
}

.hit-icon {
  font-size: 0.72rem;
  font-weight: 900;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-pill);
}

.hit-icon.win {
  background: rgba(57, 255, 136, 0.15);
  color: var(--hit);
}

.hit-icon.lose {
  background: rgba(255, 59, 92, 0.15);
  color: var(--miss);
}

.article-card .article-date {
  font-size: 0.68rem;
  color: var(--dim);
  margin-bottom: 0.3rem;
}

.article-card .article-title {
  font-size: 0.92rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
  line-height: 1.4;
}

.article-card .article-excerpt {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}

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

.footer-note {
  font-size: 0.65rem;
  color: var(--dim);
  text-align: center;
  padding: 0.5rem 1rem 1rem;
  line-height: 1.5;
}

.tab-bar-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(5, 7, 10, 0.95), rgba(5, 7, 10, 0.75));
  backdrop-filter: blur(14px);
}

.tab-bar {
  max-width: 440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--surface-container);
  border: 1px solid var(--outline);
  border-radius: 16px;
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.08);
}

.tab-bar button {
  border: none;
  background: transparent;
  border-radius: 12px;
  padding: 0.55rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.tab-bar button .ico {
  font-size: 1.1rem;
  line-height: 1;
}

.tab-bar button.active {
  background: linear-gradient(145deg, rgba(0, 229, 255, 0.18), rgba(255, 43, 214, 0.12));
  color: var(--text);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.2);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 env(safe-area-inset-bottom);
}

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 88dvh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--outline-strong);
  border-radius: 18px 18px 0 0;
  padding: 1rem 1rem 1.5rem;
  box-shadow: 0 -8px 40px rgba(0, 229, 255, 0.12);
}

.modal h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
  line-height: 1.4;
}

.modal section {
  margin-bottom: 1rem;
}

.modal section h3 {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin: 0 0 0.4rem;
}

.modal p,
.modal li {
  font-size: 0.82rem;
  color: var(--muted);
}

.modal ul {
  margin: 0;
  padding-left: 1.1rem;
}

.modal-close {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.65rem;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: var(--surface-2);
  font-weight: 800;
}

.glossary details {
  border: 1px solid var(--outline);
  border-radius: var(--radius-card);
  padding: 0.65rem 0.85rem;
  margin-top: 1rem;
  background: var(--surface-2);
}

.glossary summary {
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
}

.glossary dl {
  margin: 0.75rem 0 0;
}

.glossary dt {
  font-weight: 800;
  font-size: 0.78rem;
  margin-top: 0.5rem;
}

.glossary dd {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  #view {
    animation: none;
  }
}
