/* AQUAGUESSR — Exact Design Match */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d0d0d;
  --bg-table: #1a1a1a;
  --bg-input: #1e1e1e;
  --bg-modal: #161616;

  --border-subtle: rgba(255,255,255,0.08);
  --border-cyan: #00c8d7;

  --text: #ffffff;
  --text-muted: #888888;

  --cyan: #00c8d7;
  --blue: #2563eb;
  --blue-hover: #1d4ed8;

  --correct: #00ff41;
  --incorrect: #ff3b3b;

  --font-pixel: 'Press Start 2P', monospace;
  --font-ui: 'Inter', sans-serif;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  min-height: 100vh;
}

button { cursor: pointer; font-family: var(--font-ui); }
input { font-family: var(--font-ui); }

.hidden { display: none !important; }

/* --- App Root --- */
.app-root {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 2rem 6rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --- Header Title --- */
.app-header {
  text-align: center;
  margin-bottom: 0.5rem;
}

.game-title {
  font-family: var(--font-pixel);
  font-size: 2.2rem;
  letter-spacing: 0.15em;
  color: var(--text);
  text-transform: uppercase;
  line-height: 1;
}

/* --- Top Panel: 3 columns --- */
.top-panel {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0;
}

/* LEFT: Spectrogram */
.spectrogram-box {
  flex-shrink: 0;
  width: 170px;
  height: 170px;
  border: 2px solid var(--cyan);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  background: #000;
}

.spectrogram-img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

.spectrogram-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  color: var(--cyan);
  background: #000;
  letter-spacing: 0.05em;
}

/* CENTER: Waveform player */
.player-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

/* Play button + waveform side by side */
.player-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.main-play-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 2px 12px rgba(37,99,235,0.4);
}

.main-play-btn:hover { background: var(--blue-hover); transform: scale(1.07); }
.main-play-btn:active { transform: scale(0.95); }

.main-play-btn svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.waveform-clickable {
  flex: 1;
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}

.waveform-clickable canvas {
  display: block;
  width: 100%;
  height: 48px;
}

.playhead-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: rgba(0,200,215,0.9);
  box-shadow: 0 0 6px rgba(0,200,215,0.6);
  pointer-events: none;
  transition: left 0.1s linear;
}

.time-bar {
  display: flex;
  justify-content: flex-end;
}

.time-display {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: monospace;
}

.answer-reveal {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  font-size: 0.92rem;
}

.answer-label {
  color: var(--text);
  font-weight: 500;
}

.answer-value {
  color: var(--text-muted);
  font-weight: 400;
  filter: blur(4px);
  transition: filter 0.5s ease;
}

.answer-value.revealed {
  filter: blur(0);
  color: var(--text);
}

/* RIGHT: Guess input */
.guess-panel {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.autocomplete-wrap {
  position: relative;
}

.guess-input {
  width: 240px;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.guess-input::placeholder { color: var(--text-muted); }

.guess-input:focus {
  border-color: rgba(255,255,255,0.35);
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  background: #222;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  z-index: 200;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

.autocomplete-item {
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.1s;
}

.autocomplete-item:hover {
  background: rgba(255,255,255,0.07);
  color: var(--text);
}

.guess-btn {
  background: var(--blue);
  color: var(--text);
  border: none;
  border-radius: 4px;
  padding: 0.65rem 1.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background 0.15s;
  white-space: nowrap;
}

.guess-btn:hover { background: var(--blue-hover); }
.guess-btn:active { transform: scale(0.97); }

/* --- Guesses Table --- */
.results-section {
  width: 100%;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.guesses-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-table);
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.9rem;
}

.guesses-table th {
  color: var(--text);
  font-weight: 500;
  font-size: 0.82rem;
  padding: 1rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

/* Header with ℹ icon — signals hoverable cells below */
.th-hoverable {
  cursor: default;
  user-select: none;
}

.th-info-icon {
  display: inline-block;
  font-style: normal;
  font-size: 0.7rem;
  color: var(--cyan);
  opacity: 0.7;
  margin-left: 3px;
  vertical-align: middle;
  animation: info-pulse 3s ease-in-out infinite;
}

@keyframes info-pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

.guesses-table td {
  padding: 0.85rem 1.1rem;
  color: var(--text);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  text-align: left;
  vertical-align: middle;
}

.guesses-table tbody tr:last-child td {
  border-bottom: none;
}

/* Colored text (not background) for correct/incorrect */
.guesses-table td.cell-correct {
  color: var(--correct) !important;
  font-weight: 500;
}

.guesses-table td.cell-incorrect {
  color: var(--incorrect) !important;
  font-weight: 400;
}

/* Direction arrows */
.cell-dir {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: inherit;
}

.cell-dir .arrow {
  font-size: 0.85em;
}

/* Asterisk + dashed underline for tooltip-able cells */
.cell-asterisk {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: rgba(255,255,255,0.3);
  text-underline-offset: 3px;
}

.cell-asterisk::after {
  content: ' *';
  font-size: 0.75em;
  opacity: 0.6;
}

/* Row animation */
.guesses-table tbody tr {
  animation: row-in 0.35s ease forwards;
}

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

/* Play button in table */
.col-compare { width: 56px; }

.row-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid rgba(255,255,255,0.55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.row-play-btn:hover {
  border-color: var(--cyan);
  background: rgba(0,200,215,0.08);
}

.row-play-btn.playing {
  border-color: var(--cyan);
  background: var(--cyan);
}

.row-play-btn svg {
  width: 13px;
  height: 13px;
  fill: var(--text);
}

.row-play-btn.playing svg {
  fill: #000;
}

/* --- Footer --- */
.app-footer {
  position: fixed;
  bottom: 1.5rem;
  right: 2rem;
  z-index: 10;
}

.card-deck-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 4px;
  padding: 0.6rem 1.5rem;
  font-size: 0.88rem;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}

.card-deck-btn:hover {
  border-color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.05);
}

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: var(--bg-modal);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 2rem 2rem 2.5rem;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  animation: modal-in 0.25s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

@keyframes modal-in {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: transparent;
  border: none;
  font-size: 2rem;
  color: var(--text-muted);
  line-height: 1;
  transition: color 0.15s;
}
.close-btn:hover { color: var(--text); }

.modal-title {
  font-family: var(--font-pixel);
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: 1.5rem;
  letter-spacing: 0.08em;
}

/* --- Card Deck Modal --- */
.deck-modal-box {
  width: 90vw;
  max-width: 820px;
  max-height: 85vh;
  overflow-y: auto;
}

.deck-search-wrap {
  margin-bottom: 1.5rem;
}

.deck-search {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
}

.deck-search:focus { border-color: rgba(255,255,255,0.3); }

.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.2rem;
}

.deck-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  transition: border-color 0.15s;
}

.deck-card:hover { border-color: rgba(0,200,215,0.3); }

.deck-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.deck-card-name {
  font-weight: 600;
  font-size: 1rem;
}

.deck-card-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(37,99,235,0.2);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.deck-card-play-btn:hover { background: var(--blue); }

.deck-card-play-btn.playing {
  background: var(--cyan);
}

.deck-card-play-btn svg {
  width: 14px;
  height: 14px;
  fill: var(--text);
}

.deck-card-play-btn.playing svg { fill: #000; }

.card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.82rem;
}

.stat-item { display: flex; flex-direction: column; gap: 0.1rem; }

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value { color: var(--text); font-weight: 500; }

/* --- Game Over Modal --- */
.gameover-modal-box {
  max-width: 460px;
  width: 90vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  text-align: center;
}

.outcome-badge {
  font-family: var(--font-pixel);
  font-size: 1.1rem;
  padding: 0.4rem 1.8rem;
  border-radius: 4px;
  letter-spacing: 0.06em;
}

.badge-victory { background: var(--correct); color: #000; }
.badge-defeat  { background: var(--incorrect); color: #fff; }

.outcome-message {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 340px;
  line-height: 1.5;
}

.target-preview {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 6px;
  padding: 1.2rem;
}

.play-again-btn {
  background: var(--cyan);
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 0.7rem 2.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 4px 16px rgba(0,200,215,0.3);
}

.play-again-btn:hover { opacity: 0.9; transform: scale(1.03); }

/* --- Tooltip --- */
.tooltip {
  position: fixed;
  background: #1a1a1a;
  border: 1px solid var(--cyan);
  border-radius: 5px;
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  color: var(--text);
  max-width: 260px;
  line-height: 1.4;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,200,215,0.12);
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

/* --- Responsive --- */
@media (max-width: 768px) {
  .app-root { padding: 1.2rem 0.8rem 5.5rem; gap: 1.2rem; }

  .game-title { font-size: 1.5rem; letter-spacing: 0.1em; }

  .top-panel {
    flex-direction: column;
    align-items: stretch;
    gap: 1.2rem;
  }

  .spectrogram-box { width: 100%; height: 160px; max-width: 280px; margin: 0 auto; }

  .player-center { width: 100%; }
  
  .player-row { width: 100%; }

  .guess-panel {
    width: 100%;
    display: flex;
    align-items: stretch;
  }
  
  .autocomplete-wrap {
    flex: 1;
  }

  .guess-input { width: 100%; }

  .guesses-table th,
  .guesses-table td { padding: 0.6rem 0.5rem; font-size: 0.78rem; }
  
  .cell-asterisk::after {
    content: '*';
  }

  .app-footer { right: 1rem; bottom: 1rem; position: fixed; }
  
  .deck-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.8rem;
  }
  
  .deck-modal-box {
    padding: 1.5rem 1rem;
    width: 95vw;
  }
}

