:root {
  --page-bg: #f4eee7; /* warm paper */
  --card-bg: #f7f3ee; /* inner card */
  --frame: #d8c7b6; /* main frame line */
  --frame-light: #e6dbcf;
  --ink: #1e1e1e;
  --accent-red: #c17d6e; /* tweak if you want more/less saturated */
  --tile-light: #f8f6f3;
  --tile-dark: #e4cfbc;
  --tile-border: var(--tile-dark);
  --stamp-on-light: url("/stamps/paw-light.png");
  --stamp-on-dark: url("/stamps/paw-dark.png");
}

/* ========================================================================== */
/* ============================== SECTION START ============================== */
/* =========================== GLOBAL / DOCUMENT ============================= */
/* ========================================================================== */

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  align-items: center;
  padding: 16px 0;
}

button {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
}

button:focus {
  outline: none;
}

button::-moz-focus-inner {
  border: 0;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  min-height: 100vh;
  display: grid;
  justify-items: center;
  align-items: start;
  font-family: Georgia, "Times New Roman", serif;
}

#app {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* ========================================================================== */
/* =============================== SECTION END =============================== */
/* ============================ GLOBAL / DOCUMENT ============================ */
/* ========================================================================== */

/* ========================================================================== */
/* ============================== SECTION START ============================== */
/* =========================== POSTER / OUTER SHELL ========================= */
/* ========================================================================== */

.poster {
  touch-action: manipulation;
  width: min(100%, 520px);
  background: var(--card-bg);
  position: relative;
  margin: 16px auto;
  border-radius: 0;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  min-height: auto;
  padding: 12px 12px 32px;
}

.poster * {
  touch-action: manipulation;
}

.poster::before {
  content: "";
  position: absolute;
  inset: 12px 8px;
  border: 2px solid var(--frame);
  pointer-events: none;
  z-index: 2;
}

.poster::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  --frame-inset: 12px;
  --r: calc(var(--frame-inset) * 3.5);
  --arc-color: var(--frame);
  background: radial-gradient(
      circle at var(--frame-inset) var(--frame-inset),
      transparent var(--r),
      var(--arc-color) calc(var(--r) + 0.5px),
      var(--arc-color) calc(var(--r) + 1.5px),
      transparent calc(var(--r) + 2px)
    ),
    radial-gradient(
      circle at calc(100% - var(--frame-inset)) var(--frame-inset),
      transparent var(--r),
      var(--arc-color) calc(var(--r) + 0.5px),
      var(--arc-color) calc(var(--r) + 1.5px),
      transparent calc(var(--r) + 2px)
    ),
    radial-gradient(
      circle at var(--frame-inset) calc(100% - var(--frame-inset)),
      transparent var(--r),
      var(--arc-color) calc(var(--r) + 0.5px),
      var(--arc-color) calc(var(--r) + 1.5px),
      transparent calc(var(--r) + 2px)
    ),
    radial-gradient(
      circle at calc(100% - var(--frame-inset)) calc(100% - var(--frame-inset)),
      transparent var(--r),
      var(--arc-color) calc(var(--r) + 0.5px),
      var(--arc-color) calc(var(--r) + 1.5px),
      transparent calc(var(--r) + 2px)
    );
}

.poster-header {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 16px 0;
  position: relative;
}

.poster-header-img {
  width: 85%;
  max-width: 420px;
  height: auto;
  display: block;
}

.poster-footer {
  margin-top: 34px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  letter-spacing: 3px;
}

.poster-date {
  font-size: 14px;
  letter-spacing: 3px;
}

.poster-divider {
  font-size: 12px;
  margin: 6px 0;
  color: var(--accent-red);
  opacity: 1;
}

.poster-names {
  font-size: 12px;
  letter-spacing: 3px;
}

.flip-help-row {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.bingo-tile,
.flip-help-button {
  -webkit-tap-highlight-color: transparent;
}

.flip-help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1.5px solid var(--tile-border);
  background: var(--tile-light);
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.flip-help-button:active {
  transform: translateY(1px) scale(0.995);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.flip-help-button:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.flip-help-button-back {
  align-self: center;
}

.flip-help-button-outside {
  margin-top: 12px;
}

.flip-help-icon {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1.5px solid var(--tile-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
}

/* ========================================================================== */
/* =============================== SECTION END =============================== */
/* ============================ POSTER / OUTER SHELL ========================= */
/* ========================================================================== */

/* ========================================================================== */
/* ============================== SECTION START ============================== */
/* ========================= MAIN APP / FLIP SCENE ========================== */
/* ========================================================================== */

.bingo-flip-scene {
  width: 100%;
  max-width: 640px;
  /* margin: 12px 12px 18px; */
  perspective: 1400px;
}

.bingo-flip-inner {
  position: relative;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 520ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.bingo-flip-scene.is-flipped .bingo-flip-inner {
  transform: rotateY(180deg);
}

.bingo-face {
  width: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--card-bg);
  position: relative;
}

.bingo-face::before {
  content: "";
  position: absolute;
  inset: 10px 8px;
  pointer-events: none;
}

.bingo-face-front {
  position: relative;
  z-index: 2;
}

.bingo-face-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  display: flex;
  align-items: stretch;
  min-height: 100%;
}

/* ========================================================================== */
/* =============================== SECTION END =============================== */
/* ========================== MAIN APP / FLIP SCENE ========================= */
/* ========================================================================== */

/* ========================================================================== */
/* ============================== SECTION START ============================== */
/* ========================= FRONT FACE / BINGO GRID ======================== */
/* ========================================================================== */

.bingo-grid {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 8px;
  table-layout: fixed;
}

.bingo-grid td {
  width: 20%;
  padding: 0;
  vertical-align: top;
}

.bingo-tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5%;
  background: var(--tile-light);
  border: 1.5px solid var(--tile-border);
  box-sizing: border-box;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.1;
  text-align: center;
  overflow: hidden;
  color: var(--ink);
}

.bingo-tile.bingo-checked {
  border-color: var(--accent-red);
  border-width: 2px;
}

.bingo-tile.bingo-checked::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--stamp-on-light) center -110% / 120% no-repeat;
  opacity: 0.6;
  pointer-events: none;
}

.bingo-tile.bingo-checked .bingo-text {
  opacity: 0.6;
}

.bingo-grid tr:nth-child(odd) td:nth-child(even) .bingo-tile,
.bingo-grid tr:nth-child(even) td:nth-child(odd) .bingo-tile {
  background: var(--tile-dark);
}

.bingo-grid tr:nth-child(odd) td:nth-child(even) .bingo-checked::after,
.bingo-grid tr:nth-child(even) td:nth-child(odd) .bingo-checked::after {
  background: var(--stamp-on-dark) center -140% / 120% no-repeat;
}

.bingo-text {
  display: -webkit-box;
  font-size: 0.75rem;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
}

.bingo-center {
  background: var(--tile-light);
}

.bingo-center-text {
  color: var(--accent-red);
  font-size: 48px;
  line-height: 1;
  letter-spacing: 0;
}

/* ========================================================================== */
/* =============================== SECTION END =============================== */
/* ========================== FRONT FACE / BINGO GRID ======================= */
/* ========================================================================== */

/* ========================================================================== */
/* ============================== SECTION START ============================== */
/* ===================== BACK FACE / SHARED CARD LAYOUT ===================== */
/* ========================================================================== */

.flip-shared-card {
  background: var(--tile-light);
  border: 2px solid var(--frame);
  border-radius: 4px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0px 16px;
}

.flip-instructions-card-container {
  width: 100%;
  height: 100%;
  padding: 8px;
}

.flip-tile-card-container {
  width: 100%;
  height: 100%;
  padding: 32px;
}

.flip-instructions-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 32px 0 16px;
}

.flip-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center; /* vertical centering */
  align-items: center; /* horizontal centering */
  text-align: center;
}

.install-title {
  text-align: center;
  font-size: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0 0 16px;
}

/* ========================================================================== */
/* =============================== SECTION END =============================== */
/* ====================== BACK FACE / SHARED CARD LAYOUT ==================== */
/* ========================================================================== */

/* ========================================================================== */
/* ============================== SECTION START ============================== */
/* ======================= BACK FACE / INSTRUCTIONS ========================= */
/* ========================================================================== */

/* INSTRUCTIONS START */
.flip-instructions-text-wrap {
  width: 100%;
  margin: 0 auto;
  text-align: left;
}

.flip-instructions-intro {
  margin: 0px auto 14px;
  max-width: 32ch;
  line-height: 1.35;
}

.flip-instructions-rules-grid {
  max-width: 28ch;
  margin: 10px auto 12px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  line-height: 0.9rem;
  opacity: 0.85;
}

.flip-rule-row {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 4px 0;
}

.flip-rule-row div:last-child {
  font-weight: 500;
}

.flip-score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 12px 0px 4px;
  font-weight: 900;
}

.flip-instructions-prize {
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.75;
  margin-top: 6px;
}

/* INSTRUCTIONS END */

/* ========================================================================== */
/* =============================== SECTION END =============================== */
/* ======================== BACK FACE / INSTRUCTIONS ======================== */
/* ========================================================================== */

/* ========================================================================== */
/* ============================== SECTION START ============================== */
/* ======================== BACK FACE / TILE DETAIL ========================= */
/* ========================================================================== */

.flip-tile-detail-content {
  width: 100%;
}

.flip-detail-tile-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

.flip-detail-tile {
  position: relative;
  width: 88px;
  height: 88px;
  border: 2px solid var(--tile-dark);
  border-radius: 4px;
  background: var(--tile-light);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.flip-detail-tile-alt {
  background: var(--tile-dark);
}

.flip-detail-tile-text {
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.1;
  text-align: center;
}

.flip-detail-tile-checked::after {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 70%;
  transform: rotate(var(--stamp-rotation, -8deg));
  pointer-events: none;
}

.flip-detail-tile-checked {
  position: relative;
}

/* normal stamp */
.flip-detail-tile-checked::after {
  background-image: url("/stamps/paw-light.png");
}

/* alternate stamp */
.flip-detail-tile-alt.flip-detail-tile-checked::after {
  background-image: url("/stamps/paw-dark.png");
}

.flip-detail-tile-hint {
  margin-top: 10px;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
  text-align: center;
}

/* ========================================================================== */
/* =============================== SECTION END =============================== */
/* ========================= BACK FACE / TILE DETAIL ======================== */
/* ========================================================================== */

/* ========================================================================== */
/* ============================== SECTION START ============================== */
/* ============================= MODAL / DEBUG ============================== */
/* ========================================================================== */

#modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(40, 25, 15, 0.35);
  backdrop-filter: blur(3px);
  z-index: 1000;
}

#tileModal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(86vw, 360px);
  padding: 32px 18px 32px;
  background: var(--card-bg);
  border: 2px solid var(--frame);
  border-radius: 4px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
  z-index: 1001;
}

#tileModal:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#tileModalTitle {
  width: 100%;
  text-align: center;
  font-size: 18px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 2px;
  margin-bottom: 2px;
}

#tileModalBody {
  width: 100%;
  text-align: center;
  font-size: 15px;
  line-height: 1.45;
  opacity: 0.9;
}

#tileModalHint {
  width: 100%;
  text-align: center;
  font-size: 13px;
  opacity: 0.7;
  margin-top: 2px;
  margin-bottom: 2px;
}

#tileModalTile {
  width: 72%;
  aspect-ratio: 1 / 1;
  border-width: 2px;
  border-radius: 4px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

#tileModalTile.modal-alt {
  background: var(--tile-dark);
}

#tileModalTile:active {
  transform: translateY(2px) scale(0.995);
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.12);
}

#tileModalTile.bingo-checked {
  outline: 3px solid var(--accent-red);
  outline-offset: -3px;
}

.modal-tile.bingo-checked::after {
  background: var(--stamp-on-light) center 50% / 75% no-repeat;
  opacity: 0.25;
}

.modal-tile.modal-alt.bingo-checked::after {
  background: var(--stamp-on-dark) center 50% / 70% no-repeat;
}

#debug {
  font-size: 12px;
  opacity: 0.6;
  margin-bottom: 8px;
}

/* ========================================================================== */
/* =============================== SECTION END =============================== */
/* ============================== MODAL / DEBUG ============================= */
/* ========================================================================== */

/* ========================================================================== */
/* ============================== SECTION START ============================== */
/* ============================== INSTALL UI ================================ */
/* ========================================================================== */

.install-card {
  width: 100%;
  max-width: 420px;
  margin: 24px 12px;
  padding: 24px 16px;
  background: var(--card-bg);
  border: 2px solid var(--frame);
  border-radius: 4px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.08);
  position: relative;
  z-index: 3;
}

.install-card::before {
  content: "";
  position: absolute;
  inset: 10px 8px;
  pointer-events: none;
}

.install-steps {
  margin: 0;
  padding-left: 18px;
  line-height: 1.55;
  font-size: 14px;
  opacity: 0.92;
}

.install-steps li {
  margin: 6px 0;
}

.install-steps strong {
  font-weight: normal;
  padding: 1px 6px;
  border: 1.5px solid var(--tile-border);
  background: var(--tile-light);
  border-radius: 3px;
  display: inline-block;
}

.install-icon {
  padding-top: 1px;
  width: 16px;
  height: 16px;
  vertical-align: -2px;
}

/* ========================================================================== */
/* =============================== SECTION END =============================== */
/* =============================== INSTALL UI =============================== */
/* ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .bingo-flip-inner,
  .flip-help-button,
  #tileModalTile {
    transition: none;
  }
}

/* ========================================================================== */
/* ============================ POSTER HELP SEAL ============================ */
/* ========================================================================== */

.poster-help-seal {
  position: absolute;
  top: 16px;
  right: 32px;
  -webkit-tap-highlight-color: transparent;
}

.poster-help-seal-icon {
  width: 30px;
  height: 30px;
  stroke: var(--accent-red);
}

.poster-help-seal:not(:disabled):active {
  transform: translateY(1px);
}

.poster-help-seal:not(:disabled):active .poster-help-seal-icon {
  transform: scale(0.97);
}

.poster-help-seal[aria-pressed="true"],
.poster-help-seal.is-active {
  opacity: 0.78;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.poster-help-seal[aria-pressed="true"] .poster-help-seal-icon,
.poster-help-seal.is-active .poster-help-seal-icon {
  opacity: 0.9;
}

.poster-help-seal:disabled,
.poster-help-seal.is-disabled {
  opacity: 0.5;
  box-shadow: none;
  pointer-events: none;
}

.poster-help-seal:disabled .poster-help-seal-icon,
.poster-help-seal.is-disabled .poster-help-seal-icon {
  opacity: 0.55;
  transform: none;
}

.poster-help-seal:disabled:active,
.poster-help-seal.is-disabled:active {
  transform: none;
}

.poster-help-seal:disabled:active .poster-help-seal-icon,
.poster-help-seal.is-disabled:active .poster-help-seal-icon {
  transform: none;
}
/* ========================================================================== */
/* ========================== END POSTER HELP SEAL ========================== */
/* ========================================================================== */
