@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Rajdhani:wght@300;400;600;700&display=swap');

:root {
  --bg: #060605;
  --panel: #0e0e0c;
  --panel-2: #161612;
  --text: #d9d0b0;
  --muted: #6b6450;
  --border: #2e2b1f;
  --ok: #2e5c32;
  --warn: #6b5820;
  --bad: #6b1a1a;
  --accent: #c8b88a;
  --accent-dim: #7a6e52;
  --red: #9b2020;
  --scanline: rgba(0, 0, 0, 0.18);
  --noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Rajdhani', 'Share Tech Mono', monospace;
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      var(--scanline) 3px,
      var(--scanline) 4px
    ),
    radial-gradient(ellipse at 50% 0%, #1a170e 0%, #060605 70%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--noise);
  background-size: 200px 200px;
  opacity: 0.4;
  pointer-events: none;
  z-index: 9998;
  animation: grain 0.4s steps(3) infinite;
}

/* Vignette */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
  z-index: 9997;
}

@keyframes grain {
  0%   { background-position: 0 0; }
  33%  { background-position: -40px -60px; }
  66%  { background-position: 40px 20px; }
  100% { background-position: -20px 40px; }
}

/* ─── CORNER BRACKET MIXIN ─── */
.panel {
  position: relative;
  border: 1px solid var(--border);
  background: var(--panel);
}

.panel::before,
.panel::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--accent);
  border-style: solid;
}

.panel::before {
  top: -1px; left: -1px;
  border-width: 2px 0 0 2px;
}

.panel::after {
  bottom: -1px; right: -1px;
  border-width: 0 2px 2px 0;
}

/* ─── LAYOUT ─── */
.app {
  max-width: 1140px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  position: relative;
  z-index: 1;
}

.hidden { display: none !important; }

/* ─── TOP CLASSIFICATION BAR ─── */
.yorha-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-bottom: none;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: rgba(0,0,0,0.4);
}

.yorha-bar::before {
  content: '▸ YoRHa Tactical Unit — Codename: NIERDLE ◂';
}

.yorha-bar::after {
  content: attr(data-time);
}

/* ─── MENU SCREEN ─── */
.menu-screen {
  text-align: center;
  padding: 4rem 1rem 3rem;
}

.menu-screen h1 {
  font-family: 'Rajdhani', sans-serif;
  font-size: clamp(2.8rem, 7vw, 5rem);
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text);
  position: relative;
  display: inline-block;
  animation: glitch-idle 8s infinite;
}

.menu-screen h1::before,
.menu-screen h1::after {
  content: attr(data-text);
  position: absolute;
  top: 0; left: 0;
  width: 100%;
}

.menu-screen h1::before {
  color: #c8b88a;
  clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
  animation: glitch-top 8s infinite;
  opacity: 0;
}

.menu-screen h1::after {
  color: #8b2020;
  clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
  animation: glitch-bot 8s infinite;
  opacity: 0;
}

@keyframes glitch-idle {
  0%, 90%, 100% { text-shadow: none; }
  91%            { text-shadow: -2px 0 #8b2020, 2px 0 #4a7090; }
  93%            { text-shadow: 2px 0 #8b2020, -2px 0 #4a7090; }
  95%            { text-shadow: none; }
  96%            { text-shadow: -2px 0 #8b2020; }
  97%            { text-shadow: none; }
}

@keyframes glitch-top {
  0%, 90%, 100% { opacity: 0; transform: none; }
  91%            { opacity: 1; transform: translate(-3px, 0); }
  93%            { opacity: 1; transform: translate(3px, 0); }
  95%            { opacity: 0; }
}

@keyframes glitch-bot {
  0%, 90%, 100% { opacity: 0; transform: none; }
  92%            { opacity: 1; transform: translate(3px, 0); }
  94%            { opacity: 1; transform: translate(-3px, 0); }
  95%            { opacity: 0; }
}

.menu-subtitle {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.25em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: -0.25rem;
  margin-bottom: 0.5rem;
}

.menu-description {
  margin: 0.75rem auto 2.5rem;
  max-width: 600px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  line-height: 1.65;
}


.mode-section-title {
  margin: 1.4rem auto 0.8rem;
  color: var(--accent-dim);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: left;
  max-width: 700px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(230px, 1fr));
  gap: 1.25rem;
  max-width: 700px;
  margin: 0 auto;
}

.mode-card {
  text-align: left;
  position: relative;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, #141310, #0a0a08);
  border-radius: 0;
  color: var(--text);
  padding: 1.5rem 1.25rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

.mode-card::before,
.mode-card::after {
  content: '';
  position: absolute;
  width: 8px; height: 8px;
  border-color: var(--accent-dim);
  border-style: solid;
  transition: border-color 0.2s;
}

.mode-card::before {
  top: 4px; left: 4px;
  border-width: 1px 0 0 1px;
}

.mode-card::after {
  bottom: 4px; right: 4px;
  border-width: 0 1px 1px 0;
}

.mode-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.mode-card:hover::before,
.mode-card:hover::after {
  border-color: var(--accent);
}

.mode-number {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--accent-dim);
  display: block;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.mode-title {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.mode-text {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.5;
}

/* ─── DIVIDER ─── */
.nier-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2rem 0 1.5rem;
  color: var(--muted);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.nier-divider::before,
.nier-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
}

/* ─── GAME SCREEN HEADER ─── */
.header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.header h2 {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
}

.muted {
  color: var(--muted);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  margin-top: 0.3rem;
}

.header-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

/* ─── CONTROLS ─── */
.controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: end;
}

.autocomplete {
  position: relative;
}

.autocomplete label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--accent-dim);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 1px rgba(200, 184, 138, 0.08), inset 0 0 12px rgba(200, 184, 138, 0.04);
}

input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* ─── AUTOCOMPLETE LIST ─── */
.autocomplete-list {
  position: absolute;
  width: 100%;
  margin: 0.25rem 0 0;
  padding: 0.25rem;
  list-style: none;
  background: #0a0a08;
  border: 1px solid var(--border);
  border-top: 1px solid var(--accent-dim);
  max-height: 220px;
  overflow-y: auto;
  display: none;
  z-index: 30;
}

.autocomplete-list.show { display: block; }

.autocomplete-list::-webkit-scrollbar { width: 4px; }
.autocomplete-list::-webkit-scrollbar-track { background: transparent; }
.autocomplete-list::-webkit-scrollbar-thumb { background: var(--border); }

.autocomplete-list li {
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.88rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  transition: color 0.15s, background 0.15s;
}

.autocomplete-option {
  display: block;
}

.autocomplete-content {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.55rem;
}

.autocomplete-icon-block {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.45);
}

.autocomplete-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  flex: 0 0 auto;
}

.autocomplete-text {
  min-width: 0;
}

.autocomplete-primary {
  color: var(--text);
}

.autocomplete-details {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  margin-top: 0.1rem;
}

.autocomplete-list li::before {
  content: '> ';
  color: var(--accent-dim);
}

.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--panel-2);
  color: var(--text);
}

/* ─── BUTTONS ─── */
.btn {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  padding: 0.7rem 1.1rem;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: color 0.2s, background 0.2s;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateX(-101%);
  transition: transform 0.2s ease;
  z-index: -1;
}

.btn:hover {
  color: #0a0a08;
}

.btn:hover::before {
  transform: translateX(0);
}

.btn.secondary {
  border-color: var(--border);
  color: var(--muted);
}

.btn.secondary::before {
  background: var(--border);
}

.btn.secondary:hover {
  color: var(--text);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn:disabled::before { display: none; }

/* ─── STATUS ─── */
.status {
  min-height: 1.8rem;
  margin: 0.6rem 0 0.9rem;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.status.success {
  color: #5dcf7e;
}

.status.success::before {
  content: '[ ';
  color: var(--muted);
}

.status.success::after {
  content: ' ]';
  color: var(--muted);
}


.daily-stats {
  min-height: 2rem;
  margin: 0.4rem 0 0.9rem;
  color: var(--accent-dim);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.share-controls {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.15rem 0 1rem;
}

.share-controls .btn {
  font-size: 0.76rem;
  padding: 0.5rem 0.75rem;
}

/* ─── HISTORY TABLE ─── */
.history-wrap {
  border: 1px solid var(--border);
  /* hide scrollbars while keeping scroll functionality */
  overflow: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  background: rgba(0,0,0,0.25);
  position: relative;
}

.history-wrap::-webkit-scrollbar {
  display: none;
}

.history-wrap::before,
.history-wrap::after {
  content: '';
  position: absolute;
  width: 8px; height: 8px;
  border-color: var(--accent-dim);
  border-style: solid;
  z-index: 2;
  pointer-events: none;
}

.history-wrap::before {
  top: -1px; left: -1px;
  border-width: 2px 0 0 2px;
}

.history-wrap::after {
  bottom: -1px; right: -1px;
  border-width: 0 2px 2px 0;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-family: 'Share Tech Mono', monospace;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.55rem;
  text-align: center;
  letter-spacing: 0.04em;
}

.history-table th {
  position: sticky;
  top: 0;
  background: #0d0c0a;
  color: var(--accent-dim);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--accent-dim);
}

.history-table td:first-child,
.history-table th:first-child {
  text-align: left;
  min-width: 190px;
  padding-left: 0.8rem;
}

.history-table.history-table-weapons td:first-child,
.history-table.history-table-weapons th:first-child {
  text-align: center;
  min-width: 58px;
  width: 58px;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
}

.history-table.history-table-weapons td:nth-child(2),
.history-table.history-table-weapons th:nth-child(2) {
  text-align: left;
  min-width: 190px;
  padding-left: 0.8rem;
}

.history-icon-cell {
  text-align: center;
}

.history-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  padding: 2px;
}

/* ─── RESULT TILES ─── */
/* Base tile — gives each data cell a subtle inset panel feel */
.history-table td:not(:first-child) {
  padding: 0.45rem 0.4rem;
}

/* Inner tile wrapper generated by JS — if not present, fallback on td */
.cell-match,
.cell-partial,
.cell-miss {
  position: relative;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
}

/* ── MATCH — confirmed hit, glowing jade ── */
.cell-match {
  background:
    linear-gradient(135deg,
      rgba(34, 90, 45, 0.55) 0%,
      rgba(20, 60, 30, 0.35) 100%);
  color: #7ee89a;
  border-left: 2px solid #3ecf65;
  box-shadow:
    inset 2px 0 8px rgba(62, 207, 101, 0.12),
    inset 0 0 12px rgba(62, 207, 101, 0.06);
  text-shadow: 0 0 8px rgba(126, 232, 154, 0.6);
}

.cell-match::after {
  content: ' ◆';
  font-size: 0.55rem;
  color: #3ecf65;
  opacity: 0.75;
  vertical-align: middle;
}

/* ── PARTIAL — close but off, amber scanner pulse ── */
.cell-partial {
  background:
    linear-gradient(135deg,
      rgba(100, 78, 20, 0.5) 0%,
      rgba(70, 55, 14, 0.3) 100%);
  color: #e8bf65;
  border-left: 2px solid #c89a30;
  box-shadow:
    inset 2px 0 8px rgba(200, 154, 48, 0.12),
    inset 0 0 12px rgba(200, 154, 48, 0.06);
  text-shadow: 0 0 8px rgba(232, 191, 101, 0.5);
}

.cell-partial::after {
  content: ' ▲';
  font-size: 0.55rem;
  color: #c89a30;
  opacity: 0.75;
  vertical-align: middle;
}

/* ── MISS — no data, dim red / flat ── */
.cell-miss {
  background:
    linear-gradient(135deg,
      rgba(80, 20, 20, 0.35) 0%,
      rgba(40, 10, 10, 0.2) 100%);
  color: #8a5050;
  border-left: 2px solid #6b2525;
  box-shadow:
    inset 2px 0 6px rgba(107, 37, 37, 0.1);
}

.cell-miss::after {
  content: ' —';
  font-size: 0.7rem;
  color: #6b2525;
  opacity: 0.7;
  vertical-align: middle;
}

/* Row hover — subtle scan highlight */
.history-table tbody tr {
  transition: background 0.15s;
}

.history-table tbody tr:hover td {
  background-color: rgba(200, 184, 138, 0.03);
}

/* Don't double-tint colored cells on row hover */
.history-table tbody tr:hover .cell-match,
.history-table tbody tr:hover .cell-partial,
.history-table tbody tr:hover .cell-miss {
  background-color: unset;
}

.indicator {
  display: inline-block;
  margin-left: 0.3rem;
  color: #6b6450;
  font-size: 0.75rem;
}

/* ─── FOOTER LINE ─── */
.nier-footer {
  margin-top: 2rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
  opacity: 0.5;
}


.footer-links {
  display: inline-flex;
  gap: 1rem;
}

.footer-links a {
  color: inherit;
  text-decoration: none;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--text);
  text-decoration: underline;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 860px) {
  .mode-grid { grid-template-columns: 1fr; }
  .header { flex-direction: column; }
  .controls { grid-template-columns: 1fr; }
  .header-actions { width: 100%; }
  .header-actions .btn { flex: 1; }
  .footer-links { width: 100%; justify-content: space-between; }
}
