:root {
  color-scheme: light;
  --bg: #fff3c7;
  --panel: #fffaf0;
  --panel-soft: #ffe7a3;
  --text: #37180e;
  --muted: #7c3f1d;
  --line: rgba(91, 37, 14, 0.16);
  --accent: #f5b000;
  --accent-strong: #e85d04;
  --busy: #d62828;
  --free: #168a43;
  --blue: #277da1;
  --green: #2a9d8f;
  --red: #d62828;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 10%, rgba(214, 40, 40, 0.18), transparent 18rem),
    radial-gradient(circle at 85% 12%, rgba(42, 157, 143, 0.2), transparent 18rem),
    linear-gradient(180deg, #fff0b6 0%, var(--bg) 42%, #f9d98f 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(45deg, rgba(91, 37, 14, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(91, 37, 14, 0.05) 25%, transparent 25%);
  background-size: 32px 32px;
  opacity: 0.65;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(3.2rem, env(safe-area-inset-top)) 1rem max(1.3rem, env(safe-area-inset-bottom));
  position: relative;
}

.flag-line {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 2;
  display: flex;
  width: min(100%, 780px);
  height: 2.4rem;
  transform: translateX(-50%);
  pointer-events: none;
}

.flag-line::before {
  content: "";
  position: absolute;
  top: 0.7rem;
  left: 0.4rem;
  right: 0.4rem;
  height: 2px;
  background: rgba(91, 37, 14, 0.35);
}

.flag-line span {
  width: 0;
  height: 0;
  margin: 0.8rem auto 0;
  border-left: 0.72rem solid transparent;
  border-right: 0.72rem solid transparent;
  border-top: 1.2rem solid var(--red);
  filter: drop-shadow(0 2px 2px rgba(91, 37, 14, 0.16));
}

.flag-line span:nth-child(2n) {
  border-top-color: var(--accent);
}

.flag-line span:nth-child(3n) {
  border-top-color: var(--blue);
}

.flag-line span:nth-child(4n) {
  border-top-color: var(--green);
}

.screen {
  display: grid;
  gap: 1rem;
}

.hidden {
  display: none !important;
}

.hero {
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.68), rgba(255, 246, 220, 0.92)),
    repeating-linear-gradient(45deg, rgba(214, 40, 40, 0.05) 0 8px, transparent 8px 16px);
  box-shadow: 0 18px 40px rgba(91, 37, 14, 0.14);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 1.8rem;
  padding: 0 0.75rem;
  border: 1px solid rgba(214, 40, 40, 0.22);
  border-radius: 999px;
  background: rgba(245, 176, 0, 0.18);
  color: #8b1e16;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-title {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
}

.hero-icon {
  width: clamp(3.6rem, 18vw, 5.6rem);
  height: clamp(3.6rem, 18vw, 5.6rem);
  flex: 0 0 auto;
  border-radius: 1.35rem;
  box-shadow: 0 14px 26px rgba(91, 37, 14, 0.16);
}

h1,
p {
  margin: 0;
}

.hero h1,
.card-top h1 {
  margin-top: 0.8rem;
  font-size: clamp(2rem, 10vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.hero p {
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.58;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: rgba(255, 250, 240, 0.86);
  box-shadow: 0 10px 24px rgba(91, 37, 14, 0.1);
}

.status-strip div {
  display: grid;
  gap: 0.2rem;
  min-height: 4.7rem;
  padding: 0.8rem;
  border-right: 1px solid var(--line);
}

.status-strip div:last-child {
  border-right: none;
}

.status-strip strong {
  color: var(--text);
  font-size: 1.1rem;
}

.status-strip span {
  color: var(--muted);
  font-size: 0.82rem;
}

.search-box {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  min-height: 3.25rem;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 250, 240, 0.9);
  color: var(--text);
  outline: none;
}

.search-box input:focus {
  border-color: rgba(246, 196, 83, 0.7);
  box-shadow: 0 0 0 3px rgba(246, 196, 83, 0.16);
}

.grid-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.1rem;
}

.grid-title strong {
  color: var(--text);
  font-size: 1.05rem;
}

.grid-title span {
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
}

.card-choice {
  display: grid;
  place-items: center;
  gap: 0.25rem;
  min-height: 4.25rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(91, 37, 14, 0.1);
}

.card-choice strong {
  font-size: clamp(1.28rem, 6vw, 1.8rem);
  line-height: 1;
}

.card-choice span {
  color: var(--free);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.card-choice.available {
  border-color: rgba(22, 138, 67, 0.35);
  background: linear-gradient(180deg, #e5ffe8, #bff1c6);
}

.card-choice.busy {
  border-color: rgba(139, 30, 22, 0.45);
  background: linear-gradient(180deg, #ef4444, #b91c1c);
  color: #fff7f7;
  cursor: not-allowed;
  opacity: 1;
}

.card-choice.busy span {
  color: #ffe4e6;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 1.45rem;
  background:
    linear-gradient(135deg, rgba(255, 250, 240, 0.94), rgba(255, 231, 163, 0.9)),
    repeating-linear-gradient(45deg, rgba(42, 157, 143, 0.08) 0 10px, transparent 10px 20px);
  box-shadow: 0 14px 32px rgba(91, 37, 14, 0.12);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  min-height: 2.2rem;
  padding: 0 0.8rem;
  border-radius: 999px;
  background: rgba(22, 138, 67, 0.13);
  color: var(--free);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.live-pill.offline {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
}

.card-help,
.card-footer {
  padding: 0 0.2rem;
  color: var(--muted);
  line-height: 1.48;
}

.bingo-board {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  background: #fffaf0;
  box-shadow: 0 18px 44px rgba(91, 37, 14, 0.16);
}

.bingo-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.board-head {
  display: grid;
  place-items: center;
  min-height: 3rem;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #d62828, #a4161a);
  color: #fffaf0;
  font-size: 1.4rem;
  font-weight: 950;
}

.board-head:nth-child(5) {
  border-right: none;
}

.board-grid {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.board-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: none;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff7dc;
  color: var(--text);
  font-size: clamp(1.25rem, 8vw, 2.3rem);
  font-weight: 950;
  cursor: pointer;
  transition:
    background 0.12s ease,
    color 0.12s ease,
    transform 0.12s ease;
}

.board-cell:nth-child(5n) {
  border-right: none;
}

.board-cell:nth-last-child(-n + 5) {
  border-bottom: none;
}

.board-cell:active {
  transform: scale(0.96);
}

.board-cell.marked {
  background: linear-gradient(180deg, #f5b000, #f77f00);
  color: #37180e;
}

.board-cell.free {
  font-size: 0.9rem;
  text-transform: uppercase;
}

.board-cell.free span {
  rotate: -12deg;
}

.card-footer {
  display: grid;
  gap: 0.65rem;
}

.card-footer strong {
  color: var(--accent);
}

.choose-another-button {
  width: 100%;
  min-height: 3.15rem;
  margin-top: 0.35rem;
  border: 1px solid rgba(139, 30, 22, 0.2);
  border-radius: 999px;
  background: linear-gradient(180deg, #fffaf0, #ffe7a3);
  color: #7c2d12;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(91, 37, 14, 0.12);
}

.choose-another-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.toast {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 10;
  width: min(calc(100% - 2rem), 34rem);
  margin: 0 auto;
  padding: 1rem;
  border: 1px solid rgba(91, 37, 14, 0.18);
  border-radius: 1rem;
  background: #fffaf0;
  color: var(--text);
  box-shadow: 0 18px 50px rgba(91, 37, 14, 0.2);
}

@media (max-width: 380px) {
  .app-shell {
    padding-inline: 0.75rem;
  }

  .cards-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hero-title {
    gap: 0.65rem;
  }
}
