/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  /* Solarized Dark */
  --green:       #2aa198;
  --green-light: #38c4ba;
  --green-dark:  #001e26;
  --gold:        #b58900;
  --gold-light:  #d4a200;
  --water:       #268bd2;
  --water-light: #2aa198;
  --bg:          #002b36;
  --card:        #073642;
  --card-hover:  #0d4455;
  --text:        #ffffff;
  --text-muted:  #93a1a1;
  --complete:    #2aa198;
  --complete-bg: #002d29;
  --medium:      #7a5a00;
  --hard:        #8b3000;
  --radius:      8px;
}

body {
  font-family: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
  font-weight: 800;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  background: var(--green-dark);
  border-bottom: 3px solid var(--gold);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.5rem;
  letter-spacing: 0.5px;
  color: var(--gold-light);
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.header-fish { font-size: 1.4rem; }

.mode-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: auto;
}
.mode-label.medium { background: var(--medium); color: #ffcc44; }
.mode-label.hard   { background: var(--hard);   color: #ff8888; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
nav {
  display: flex;
  background: var(--green-dark);
  border-bottom: 1px solid var(--green);
  padding: 0 16px;
}

.nav-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 10px 16px;
  transition: color 0.15s, border-color 0.15s;
}
.nav-btn:hover { color: var(--text); }
.nav-btn.active { color: var(--gold-light); border-bottom-color: var(--gold); }

/* ── Main layout ──────────────────────────────────────────────────────────── */
main { flex: 1; padding: 16px; max-width: 700px; margin: 0 auto; width: 100%; }

/* ── Generate controls ────────────────────────────────────────────────────── */
.generate-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.generate-bar select,
.generate-bar button {
  border-radius: var(--radius);
  border: 1px solid var(--green);
  padding: 8px 14px;
  font-size: 0.9rem;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

.generate-bar select:focus,
.generate-bar button:focus {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

#generate-btn {
  background: var(--green);
  border-color: var(--green-light);
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: background 0.15s, transform 0.1s;
}
#generate-btn:hover:not(:disabled) { background: var(--green-light); }
#generate-btn:active:not(:disabled) { transform: scale(0.97); }
#generate-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Bingo grid ───────────────────────────────────────────────────────────── */
#bingo-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  transition: opacity 0.2s;
}

#bingo-grid.shuffling .cell { pointer-events: none; }

.no-board {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 1rem;
}

.cell {
  aspect-ratio: 1;
  background: var(--card);
  border: 2px solid var(--green);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  cursor: pointer;
  position: relative;
  padding: 3px 3px 4px;
  gap: 2px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  user-select: none;
  overflow: hidden;
}

.cell:hover { background: var(--card-hover); border-color: var(--green-light); }
.cell:active { transform: scale(0.96); }

.cell-img {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;        /* prevents Android "open image" on long press */
  -webkit-touch-callout: none; /* prevents iOS callout */
}

.cell-name {
  font-size: clamp(0.42rem, 1.6vw, 0.62rem);
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* FREE space */
.free-space { cursor: default; }
.free-star {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  line-height: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  color: var(--gold-light);
  filter: drop-shadow(0 0 4px var(--gold));
}

.cell.complete {
  background: var(--complete-bg);
  border-color: var(--green-light);
}

.cell.complete .cell-img {
  filter: brightness(0.55) saturate(0.4);
}

.cell.complete::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  font-weight: 900;
  color: #77ff77;
  text-shadow: 0 0 8px #00aa00;
  pointer-events: none;
  line-height: 1;
}

.cell.winning {
  border-color: var(--gold);
  box-shadow: 0 0 10px var(--gold), inset 0 0 8px rgba(200,160,48,0.2);
  animation: winning-pulse 1.5s ease-in-out infinite;
}

@keyframes winning-pulse {
  0%, 100% { box-shadow: 0 0 10px var(--gold), inset 0 0 8px rgba(200,160,48,0.2); }
  50%       { box-shadow: 0 0 22px var(--gold-light), inset 0 0 16px rgba(240,192,64,0.35); }
}

.multiplier-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: clamp(18px, 5vw, 26px);
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
}


/* Generated flash */
@keyframes board-flash {
  0%   { opacity: 1; }
  30%  { opacity: 0.3; transform: scale(1.015); }
  100% { opacity: 1; transform: scale(1); }
}
#bingo-grid.generated-flash { animation: board-flash 0.55s ease-out; }

/* ── Confirm modal ───────────────────────────────────────────────────────── */
#confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 27, 36, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  padding: 20px;
}
#confirm-modal[hidden] { display: none; }

.modal-box {
  background: var(--card);
  border: 2px solid var(--green);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
}

.modal-box p {
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.55;
  margin-bottom: 20px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-buttons button {
  border-radius: var(--radius);
  border: 2px solid;
  padding: 8px 18px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#modal-cancel {
  background: transparent;
  border-color: var(--text-muted);
  color: var(--text-muted);
}
#modal-cancel:hover { border-color: var(--text); color: var(--text); }

#modal-confirm {
  background: var(--hard);
  border-color: #cc4400;
  color: #fff;
}
#modal-confirm:hover { background: #a83500; }

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
#tooltip {
  position: fixed;
  z-index: 9999;
  background: #111e11;
  border: 1px solid var(--green-light);
  border-radius: var(--radius);
  padding: 8px 12px;
  max-width: 240px;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
#tooltip[hidden] { display: none; }

/* Cell emoji (custom items with no image) */
.cell-emoji {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.4rem, 5vw, 2.4rem);
  line-height: 1;
  width: 100%;
}

/* Mobile info panel — sits below the bingo grid, same width */
#info-panel {
  margin-top: 10px;
  background: var(--card);
  border: 2px solid var(--green);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
#info-panel[hidden] { display: none; }

.info-icon-wrap {
  position: relative;
  flex-shrink: 0;
}

#info-panel-img {
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#info-panel-img[hidden] { display: none; }

#info-panel-emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  line-height: 1;
}
#info-panel-emoji[hidden] { display: none; }

.info-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 28%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#info-panel-badge[hidden] { display: none; }

.info-text { flex: 1; min-width: 0; }

#info-panel-progress {
  display: block;
  font-style: italic;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 5px;
}
#info-panel-progress[hidden] { display: none; }

.tip-name { display: block; font-weight: 800; font-size: 0.85rem; margin-bottom: 4px; color: #ffffff; }
.tip-desc { display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-muted); line-height: 1.4; }

/* ── BINGO banner ─────────────────────────────────────────────────────────── */
#bingo-banner {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  background: rgba(0,0,0,0.6);
  cursor: pointer;
  animation: banner-in 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

#bingo-banner span {
  font-size: clamp(2.5rem, 12vw, 5rem);
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--gold-light);
  text-shadow: 0 0 30px var(--gold), 0 4px 0 #6a4000;
  animation: banner-bounce 0.6s ease infinite alternate;
}

@keyframes banner-in {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes banner-bounce {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-8px) scale(1.04); }
}

/* ── Settings view ────────────────────────────────────────────────────────── */
#view-settings { display: flex; flex-direction: column; gap: 20px; }

.add-custom-form {
  background: var(--card);
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.add-custom-form h3 { font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.add-custom-form input {
  background: var(--bg);
  border: 1px solid var(--green);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.9rem;
  width: 100%;
}
.add-custom-form input:focus { outline: 2px solid var(--gold); border-color: transparent; }

.add-custom-form button {
  align-self: flex-start;
  background: var(--green);
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 8px 16px;
  transition: background 0.15s;
}
.add-custom-form button:hover { background: var(--green-light); }

.settings-category { margin-bottom: 8px; }
.settings-category h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold);
  margin: 10px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--green-dark);
}

.settings-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
}
.settings-row input[type="checkbox"] { flex-shrink: 0; accent-color: var(--green-light); width: 16px; height: 16px; cursor: pointer; }
.settings-emoji { font-size: 1rem; flex-shrink: 0; }
.settings-item-name { font-weight: 600; font-size: 0.88rem; white-space: nowrap; }
.settings-item-desc { font-size: 0.78rem; color: var(--text-muted); flex: 1; }

.badge-mh {
  font-size: 0.65rem;
  background: #4a3000;
  color: #ffcc44;
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.del-custom {
  background: none;
  border: none;
  color: #884444;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 4px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s;
}
.del-custom:hover { color: #ff4444; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  header { padding: 10px 14px; }
  header h1 { font-size: 1.2rem; }
  main { padding: 10px; }
  #bingo-grid { gap: 4px; }
  .generate-bar { gap: 8px; }
  .generate-bar select,
  .generate-bar button { padding: 7px 10px; font-size: 0.82rem; }
}
