* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --ink: #232527;
  --panel: #393b3d;
  --blue: #00a2ff;
  --blue-dark: #0074b8;
  --green: #02b757;
  --green-dark: #018a41;
  --gold: #ffb000;
  --red: #e2231a;
  --white: #ffffff;
  --cream: #f4f4f4;
  --stud-shadow: rgba(0, 0, 0, 0.35);
}

html, body { margin: 0; height: 100%; }

body {
  font-family: "Arial Black", "Trebuchet MS", system-ui, sans-serif;
  color: var(--white);
  background-color: #2b8fd6;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 40px 40px;
  min-height: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

.top {
  text-align: center;
  padding: 22px 16px 10px;
}

.logo {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 5px 0 var(--blue-dark), 0 0 0 var(--stud-shadow);
  -webkit-text-stroke: 1px var(--ink);
}
.logo .blox { color: var(--red); }

.tagline {
  display: inline-block;
  margin: 10px 0 0;
  padding: 6px 14px;
  font-size: 1rem;
  background: var(--ink);
  border-radius: 6px;
  box-shadow: 0 4px 0 #000;
}

.search-wrap { padding: 8px 14px 14px; }
#search {
  width: 100%;
  font-family: inherit;
  font-size: 1.1rem;
  padding: 14px 18px;
  border-radius: 8px;
  border: 0;
  background: var(--cream);
  color: var(--ink);
  outline: none;
  box-shadow: 0 5px 0 #9a9a9a, inset 0 -3px 0 rgba(0, 0, 0, 0.1);
}
#search:focus { box-shadow: 0 5px 0 var(--gold); }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 4px 14px 40px;
  max-width: 1100px;
  margin: 0 auto;
}
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1000px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

.card {
  appearance: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 0 #000;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: flex;
  flex-direction: column;
  text-align: left;
  font: inherit;
  color: var(--white);
}
.card:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 #000;
}

.card .poster {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--blue);
  overflow: hidden;
  border-bottom: 4px solid var(--ink);
}
.card .poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 14px, rgba(0, 0, 0, 0.12) 14px 16px);
  pointer-events: none;
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card .badge {
  position: absolute;
  inset: auto 8px 8px auto;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--green);
  border: 3px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 1rem;
  color: var(--white);
  box-shadow: 0 4px 0 var(--green-dark);
}
.card .name {
  padding: 10px 10px 12px;
  font-size: 0.95rem;
  line-height: 1.2;
  text-transform: uppercase;
}

.empty {
  text-align: center;
  font-size: 1.1rem;
  padding: 30px 16px;
  text-transform: uppercase;
}

/* Player */
.player {
  position: fixed;
  inset: 0;
  z-index: 10;
  background-color: var(--ink);
  background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 30px 30px;
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow-y: auto;
}
.player[hidden] { display: none; }

.player-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}
.player-bar h2 {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
  text-transform: uppercase;
}
.count {
  background: var(--panel);
  color: var(--gold);
  border: 3px solid var(--ink);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.btn-round {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  border-radius: 6px;
  border: 0;
  background: var(--red);
  color: var(--white);
  font-family: inherit;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 5px 0 #8a1410;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  min-height: 0;
}
.stage video {
  width: 100%;
  max-height: 68vh;
  border-radius: 8px;
  border: 4px solid var(--ink);
  background: #000;
  object-fit: contain;
  box-shadow: 0 6px 0 #000;
}

.big-play {
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 8px;
  border: 4px solid var(--ink);
  background: var(--green);
  color: var(--white);
  font-size: 2.6rem;
  cursor: pointer;
  box-shadow: 0 8px 0 var(--green-dark);
  padding-left: 8px;
}
.big-play.hidden { display: none; }

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 16px 12px 8px;
}

.btn-main {
  width: 84px;
  height: 84px;
  border-radius: 8px;
  border: 4px solid var(--ink);
  background: var(--green);
  color: var(--white);
  font-family: inherit;
  font-size: 1.8rem;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--green-dark);
}

.btn-nav {
  min-height: 60px;
  border-radius: 8px;
  border: 4px solid var(--ink);
  background: var(--blue);
  color: var(--white);
  font-family: inherit;
  font-size: 0.9rem;
  text-transform: uppercase;
  cursor: pointer;
  padding: 8px;
  box-shadow: 0 6px 0 var(--blue-dark);
}
.btn-nav:disabled { opacity: 0.4; cursor: default; }

.autonext {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.95rem;
  padding: 8px 16px 24px;
}
.autonext input { width: 26px; height: 26px; accent-color: var(--green); }

button:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 6px 14px 4px;
  max-width: 1100px;
  margin: 0 auto;
}
.tab {
  flex: 1 1 0;
  max-width: 260px;
  min-height: 52px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--panel);
  color: var(--white);
  font-family: inherit;
  font-size: 1rem;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 0 #000;
}
.tab.is-active {
  background: var(--green);
  box-shadow: 0 6px 0 var(--green-dark);
}

.intro-text {
  text-align: center;
  margin: 12px 14px 0;
  font-size: 1rem;
}

.card .clase {
  display: block;
  padding: 0 10px 12px;
  font-size: 0.75rem;
  color: var(--gold);
  text-transform: uppercase;
}

/* Character detail */
.char-body {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 0 14px 40px;
}
.char-class {
  margin: 0 0 12px;
  text-align: center;
  color: var(--gold);
  text-transform: uppercase;
  font-size: 1rem;
}
.char-body .stage { padding: 0; }
.char-section {
  margin-top: 18px;
  background: var(--panel);
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 5px 0 #000;
}
.char-section h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  text-transform: uppercase;
  color: var(--gold);
}
.char-section p {
  margin: 0;
  font-family: system-ui, sans-serif;
  font-size: 1.05rem;
  line-height: 1.5;
}
.char-section ul {
  margin: 0;
  padding-left: 22px;
  font-family: system-ui, sans-serif;
  font-size: 1.05rem;
  line-height: 1.5;
}
.char-section li + li { margin-top: 6px; }
.char-section .verse {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-left: 4px solid var(--gold);
  background: rgba(255, 255, 255, 0.05);
  font-family: system-ui, sans-serif;
}
.char-section .verse p { margin: 0 0 4px; font-style: italic; }
.char-section .verse cite { font-size: 0.9rem; font-style: normal; color: var(--gold); }

/* Discreet online counter */
.online-pill {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font: 600 0.72rem system-ui, sans-serif;
  opacity: 0.8;
  pointer-events: none;
}
.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ddc84;
}

/* Tab links */
.tab-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
}

/* Read page */
.story-card { cursor: default; }
.story-card:active { transform: none; box-shadow: 0 6px 0 #000; }
.story-card .name { padding-bottom: 8px; }
.story-card .actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 10px 12px;
  margin-top: auto;
}
.btn-read,
.btn-dl {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--ink);
  border-radius: 6px;
  color: var(--white);
  font-family: inherit;
  font-size: 0.78rem;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  padding: 6px;
}
.btn-read {
  background: var(--green);
  box-shadow: 0 4px 0 var(--green-dark);
}
.btn-dl {
  background: var(--blue);
  box-shadow: 0 4px 0 var(--blue-dark);
}
.btn-dl-small {
  flex: 0 0 auto;
  padding: 10px 12px;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: var(--blue);
  color: var(--white);
  font-size: 0.85rem;
  text-decoration: none;
  box-shadow: 0 4px 0 var(--blue-dark);
}
.pdf-frame {
  flex: 1 1 auto;
  width: calc(100% - 24px);
  min-height: 70vh;
  margin: 0 12px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--white);
}
.reader-note {
  margin: 10px 14px 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--gold);
}

/* Contribution popup */
.contrib {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
}
.contrib[hidden] { display: none; }
.contrib-box {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px 20px 22px;
  text-align: center;
  background: linear-gradient(160deg, #ffe066, #ffb000);
  color: var(--ink);
  border: 5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 10px 0 #000, 0 0 0 8px rgba(255, 255, 255, 0.35);
  animation: contrib-pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.contrib-emoji {
  font-size: 3rem;
  animation: contrib-bob 1.2s ease-in-out infinite;
}
.contrib h2 {
  margin: 6px 0 8px;
  font-size: 1.35rem;
  text-transform: uppercase;
  line-height: 1.2;
}
.contrib-text {
  margin: 0 0 16px;
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
}
.contrib-x {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: var(--red);
  color: var(--white);
  font-size: 1rem;
  cursor: pointer;
}
.contrib-actions {
  display: grid;
  gap: 10px;
}
.contrib-btn {
  min-height: 52px;
  padding: 10px 14px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  text-transform: uppercase;
  color: var(--white);
  cursor: pointer;
  box-shadow: 0 6px 0 #000;
}
.contrib-yes { background: var(--green); box-shadow: 0 6px 0 var(--green-dark); }
.contrib-no { background: var(--red); box-shadow: 0 6px 0 #8a1410; }
.contrib-pay {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 14px 12px;
  font-family: system-ui, sans-serif;
}
.contrib-pay-title {
  margin: 0 0 10px;
  font-weight: 700;
  font-size: 1rem;
}
.clabe-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.clabe-row code {
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--cream);
  border: 2px dashed var(--ink);
  border-radius: 6px;
  padding: 8px 10px;
  letter-spacing: 1px;
  word-break: break-all;
}
.contrib-copy {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 0.85rem;
  background: var(--blue);
  box-shadow: 0 4px 0 var(--blue-dark);
  border-width: 3px;
}
.contrib-data {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  text-align: left;
  font-size: 0.92rem;
  line-height: 1.5;
}
.contrib-pay > .contrib-yes { width: 100%; }

@keyframes contrib-pop {
  from { transform: scale(0.6) translateY(30px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes contrib-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@media (prefers-reduced-motion: reduce) {
  .contrib-box, .contrib-emoji { animation: none; }
}

