@import url("./character-intros.css");

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #0D0D0D;
  color: #F2F4F7;
  font-family: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  -webkit-font-smoothing: antialiased;
  cursor: default;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
  width: 100vw;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.5rem 0;
}

#game-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #16161A;
  border: 2px solid #26272C;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5), inset 0 0 60px rgba(0, 0, 0, 0.3);
  padding: 1.2rem 1.2rem 0.4rem;
  position: relative;
  z-index: 1;
  width: min(92vw, 680px);
}

#title {
  font-size: clamp(16px, 3vw, 26px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
  animation: neonFlicker 3s ease-in-out infinite;
  cursor: default;
}

@keyframes neonFlicker {
  0%, 19.9%, 22.1%, 62.9%, 64.1%, 64.9%, 100% { opacity: 1; }
  20%, 22% { opacity: 0.5; }
  63%, 64%, 65%, 70% { opacity: 0.5; }
}

#help-btn {
  background: none;
  border: 2px solid #26272C;
  color: #8A8F98;
  font-family: inherit;
  font-size: clamp(10px, 1.6vw, 14px);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: border-color 0.15s, color 0.15s;
}

#help-btn:hover {
  border-color: #00E5FF;
  color: #F2F4F7;
}

#status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0.5rem;
}

#controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#board:focus {
  outline: none;
}

#board:focus-visible {
  outline: 2px solid #00E5FF;
  outline-offset: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#status {
  font-size: clamp(10px, 1.6vw, 14px);
  color: #8A8F98;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: color 0.3s;
}

#status.win { color: #00E5FF; }
#status.lose { color: #7F0019; }

#status.turn-whit { color: #00E5FF; }
#status.turn-ki { color: #E03060; }
#status.turn-mj { color: #FFC53D; }

.difficulty-bar {
  display: inline-flex;
  gap: 0;
  border: 2px solid #26272C;
}

.diff-btn, .speed-btn {
  background: #0D0D0D;
  color: #8A8F98;
  font-family: inherit;
  font-size: clamp(11px, 1.3vw, 12px);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: none;
  border-right: 1px solid #26272C;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.difficulty-bar.hidden {
  display: none;
}

.diff-btn:last-child, .speed-btn:last-child {
  border-right: none;
}

.diff-btn:hover:not(.active), .speed-btn:hover:not(.active) {
  color: #B0B5BD;
}

.diff-btn.active, .speed-btn.active {
  background: rgba(0, 229, 255, 0.12);
  color: #00E5FF;
}

#restart {
  background: #0D0D0D;
  color: #8A8F98;
  font-family: inherit;
  font-size: clamp(11px, 1.3vw, 12px);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 2px solid #26272C;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

#restart:hover {
  border-color: #00E5FF;
  color: #F2F4F7;
}

#share {
  background: rgba(0, 229, 255, 0.12);
  color: #00E5FF;
  font-family: inherit;
  font-size: clamp(11px, 1.3vw, 12px);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 2px solid rgba(0, 229, 255, 0.4);
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

#share:hover {
  background: rgba(0, 229, 255, 0.18);
  border-color: #00E5FF;
}

.board-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 7 / 6;
  border: 2px solid #26272C;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.06);
  padding: 2px;
  overflow: hidden;
  background-color: #16161A;
  background-image: radial-gradient(circle, rgba(242, 244, 247, 0.03) 1px, transparent 1px);
  background-size: 10px 10px;
}

.board-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 10;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, rgba(0, 229, 255, 0.1) 40%, rgba(0, 229, 255, 0.18) 50%, rgba(0, 229, 255, 0.1) 60%, transparent 100%);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
  animation: scanSweep 6s linear infinite;
}

@keyframes scanSweep {
  from { top: -2px; }
  to { top: calc(100% + 2px); }
}

.board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 2px;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 2;
  perspective: 800px;
}

.col-indicator {
  position: absolute;
  top: 0;
  height: 100%;
  z-index: 5;
  pointer-events: none;
  transition: opacity 0.12s;
  border: 2px solid rgba(0, 229, 255, 0.6);
  opacity: 0.001;
}

.cell {
  background: #0D0D0D;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
  will-change: transform;
}

.cell .well {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  background: #16161A;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.cell .well::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(242, 244, 247, 0.04), transparent 55%);
}

.cell.sink-down {
  transform: translateY(5px) translateZ(-5px);
}

.cell.pivot-left {
  transform: rotateY(-11deg) translateZ(8px);
}

.cell.pivot-right {
  transform: rotateY(11deg) translateZ(8px);
}

.token {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.token::after {
  content: "";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(8px, 2vw, 15px);
  font-weight: 700;
  color: rgba(13, 13, 13, 0.5);
}

.token-cyan {
  background: #00E5FF;
  box-shadow:
    0 0 5px rgba(0, 229, 255, 0.7),
    0 0 14px rgba(0, 229, 255, 0.35),
    0 0 30px rgba(0, 229, 255, 0.15);
  border: 1.5px solid rgba(0, 200, 255, 0.5);
}

.token-cyan::after {
  inset: 30%;
  border: 2px solid rgba(13, 13, 13, 0.5);
  border-radius: 50%;
}

.token-crimson {
  background: #7F0019;
  box-shadow:
    0 0 5px rgba(127, 0, 25, 0.6),
    0 0 14px rgba(127, 0, 25, 0.3),
    0 0 30px rgba(127, 0, 25, 0.1);
  border: 1.5px solid rgba(242, 244, 247, 0.5);
}

.token-crimson::after {
  content: "✕";
  color: rgba(242, 244, 247, 0.92);
}

.token-gold {
  background: #FFC53D;
  box-shadow:
    0 0 5px rgba(255, 197, 61, 0.7),
    0 0 14px rgba(255, 197, 61, 0.35),
    0 0 30px rgba(255, 197, 61, 0.15);
  border: 1.5px solid rgba(255, 220, 130, 0.5);
}

.token-gold::after {
  content: "▲";
  font-size: clamp(7px, 1.8vw, 12px);
}

.token.win-cell {
  animation: winDrip 2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  z-index: 20;
}

@keyframes winDrip {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 10px currentColor;
  }
  20% {
    transform: translateY(4px) scale(1.08, 0.92);
  }
  100% {
    transform: translateY(40px) scale(0.85, 1.15);
    opacity: 0;
  }
}

.screen {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.screen[hidden] {
  display: none;
}

.title-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #16161A;
  border: 2px solid #26272C;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5), inset 0 0 60px rgba(0, 0, 0, 0.3);
  padding: 1.5rem 1.25rem;
  width: min(92vw, 640px);
  margin: auto 0;
}

.title-art-wrap {
  width: min(50vw, 200px);
  height: auto;
  border: 2px solid #26272C;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
}

.title-art {
  width: 100%;
  height: auto;
  display: block;
}

.art-scan-line {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(0, 229, 255, 0.15), transparent);
  height: 40px;
  animation: artScan 4s linear infinite;
}

@keyframes artScan {
  from { top: -40px; }
  to { top: 100%; }
}

.tagline {
  font-size: clamp(9px, 1.4vw, 12px);
  color: #8A8F98;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0.4rem 0 1.2rem;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
}

.menu-btn {
  background: #0D0D0D;
  color: #F2F4F7;
  font-family: inherit;
  font-size: clamp(11px, 1.8vw, 15px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 2px solid #00E5FF;
  padding: 0.7rem 1rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}

.menu-btn:hover {
  background: rgba(0, 229, 255, 0.12);
  transform: translateY(-2px);
}

.menu-btn-secondary {
  border-color: #26272C;
  color: #8A8F98;
  font-weight: 400;
}

.menu-btn-secondary:hover {
  border-color: #00E5FF;
  color: #F2F4F7;
  background: none;
}

.menu-btn-quiet {
  border-color: #26272C;
  color: #B0B5BD;
  font-weight: 400;
  font-size: clamp(10px, 1.6vw, 13px);
}

.menu-btn-quiet:hover {
  color: #F2F4F7;
  border-color: #00E5FF;
  background: rgba(0, 229, 255, 0.08);
}

.select-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #16161A;
  border: 2px solid #26272C;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  padding: 1.5rem;
  width: min(94vw, 640px);
}

#select-heading {
  font-size: clamp(13px, 2vw, 18px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #00E5FF;
  margin-bottom: 1.2rem;
}

.hero-cards {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

.hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  background: #0D0D0D;
  border: 2px solid #26272C;
  padding: 0.8rem;
  cursor: pointer;
  width: 160px;
  font-family: inherit;
  transition: border-color 0.15s, transform 0.15s, opacity 0.15s;
}

.hero-card:hover {
  border-color: #00E5FF;
  transform: translateY(-4px);
}

.hero-card.picked {
  opacity: 0.35;
  pointer-events: none;
}

.hero-card img {
  width: 100%;
  height: auto;
  border: 2px solid #26272C;
}

.hero-name {
  color: #F2F4F7;
  font-size: clamp(10px, 1.5vw, 13px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hero-trait {
  color: #8A8F98;
  font-size: clamp(8px, 1.2vw, 11px);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#versus-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0.5rem;
}

.side-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: clamp(9px, 1.4vw, 12px);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #B0B5BD;
}

.side-chip img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border: 2px solid #26272C;
  border-radius: 50%;
}

#versus-label {
  color: #8A8F98;
  font-size: clamp(9px, 1.4vw, 12px);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#opponent-mood {
  color: #8A8F98;
  font-size: clamp(7px, 1.1vw, 10px);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#record-line {
  font-size: clamp(8px, 1.2vw, 11px);
  color: #8A8F98;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: -0.8rem 0 1.2rem;
}

.settings-gear-btn {
  background: #0D0D0D;
  color: #8A8F98;
  font-size: 14px;
  border: 2px solid #26272C;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.settings-gear-btn:hover {
  border-color: #00E5FF;
  color: #F2F4F7;
}

.quit-btn {
  background: none;
  border: 2px solid #26272C;
  color: #8A8F98;
  font-family: inherit;
  font-size: clamp(11px, 1.4vw, 12px);
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: border-color 0.15s, color 0.15s;
}

.quit-btn:hover {
  border-color: #00E5FF;
  color: #F2F4F7;
}

#over-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #16161A;
  border: 2px solid #26272C;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  padding: 2rem;
  width: min(92vw, 420px);
  background-size: cover;
  background-position: center;
}

#over-panel.won {
  background-image:
    linear-gradient(rgba(13, 13, 13, 0.82), rgba(13, 13, 13, 0.82)),
    url("../assets/win-scene_schnell.jpg");
  border-color: rgba(0, 229, 255, 0.4);
}

#over-headline {
  font-size: clamp(16px, 3vw, 26px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #00E5FF;
  text-align: center;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
  margin-bottom: 0.6rem;
}

#over-stats {
  font-size: clamp(10px, 1.6vw, 13px);
  color: #B0B5BD;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1.4rem;
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

#overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

#dialog {
  background: #16161A;
  border: 2px solid #26272C;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.7);
  padding: 1.5rem;
  max-width: 360px;
  width: 90vw;
  background-image: radial-gradient(circle, rgba(242, 244, 247, 0.02) 1px, transparent 1px);
  background-size: 8px 8px;
}

#dialog h2 {
  font-size: clamp(14px, 2.2vw, 18px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #00E5FF;
  margin-bottom: 1rem;
  border-bottom: 2px solid #26272C;
  padding-bottom: 0.5rem;
}

#dialog ul {
  list-style: none;
  padding: 0;
  margin-bottom: 1.2rem;
}

#dialog li {
  font-size: clamp(10px, 1.5vw, 13px);
  color: #B0B5BD;
  margin-bottom: 0.6rem;
  line-height: 1.5;
  padding-left: 1em;
  text-indent: -1em;
}

#dialog li::before {
  content: "▸ ";
  color: #00E5FF;
}

#dialog button {
  background: rgba(0, 229, 255, 0.12);
  color: #00E5FF;
  font-family: inherit;
  font-size: clamp(9px, 1.4vw, 12px);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 2px solid rgba(0, 229, 255, 0.4);
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s, border-color 0.15s;
}

#dialog button:hover {
  background: rgba(0, 229, 255, 0.18);
  border-color: #00E5FF;
}

#footer {
  position: absolute;
  bottom: 1.5rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.85rem;
  color: #8A8F98;
  letter-spacing: 0.12em;
  z-index: 1;
  text-transform: uppercase;
}

#footer a {
  color: #9ca3af;
  text-decoration: underline;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

#footer a:hover {
  color: #00E5FF;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
  transform: scale3d(1.1, 1.1, 1.1);
}

#footer a:focus-visible {
  outline: 2px solid #00E5FF;
  outline-offset: 4px;
  color: #00E5FF;
}

#footer .footer-social {
  margin-left: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  vertical-align: middle;
}

#footer .footer-social svg {
  width: 1.05em;
  height: 1.05em;
}

@media (prefers-reduced-motion: reduce) {
  #title,
  .board-wrap::after,
  .art-scan-line,
  .token.win-cell {
    animation: none;
  }
}

.board {
  touch-action: manipulation;
}

.chip-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
}

#player-chip .chip-stack {
  align-items: flex-start;
}
