:root {
  --bg: #140c0e;
  --bg-2: #1f1216;
  --ink: #2a1810;
  --paper: #f3e6cf;
  --paper-2: #e8d5b3;
  --line: #c9ae86;
  --stamp: #c41e3a;
  --stamp-deep: #8e1428;
  --gold: #d4a017;
  --foam: #f7efe2;
  --muted: #b89a8a;
  --ok: #3d7a4a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --ui: "Segoe UI", "Avenir Next", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--foam);
  font-family: var(--ui);
}

body {
  background-image:
    radial-gradient(ellipse at top, rgba(196, 30, 58, 0.18), transparent 55%),
    radial-gradient(ellipse at 80% 120%, rgba(212, 160, 23, 0.1), transparent 45%),
    linear-gradient(180deg, #1c1013 0%, #120b0d 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1rem 1rem 3.5rem;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

h1 {
  margin: 0.15rem 0 0;
  font-family: var(--serif);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.linkish,
.ghost {
  background: none;
  border: 0;
  color: var(--gold);
  padding: 0;
}

.ghost {
  color: var(--muted);
}

.ghost:hover,
.linkish:hover {
  color: var(--foam);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0 1.25rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font-weight: 650;
  background: var(--stamp);
  color: #fff;
  box-shadow: 0 8px 20px rgba(196, 30, 58, 0.28);
}

.btn:hover {
  background: var(--stamp-deep);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn--quiet {
  background: transparent;
  color: var(--foam);
  border: 1px solid rgba(247, 239, 226, 0.18);
  box-shadow: none;
}

.btn--quiet:hover {
  background: rgba(247, 239, 226, 0.06);
}

.btn--gold {
  background: var(--gold);
  color: #2a1810;
  box-shadow: 0 8px 20px rgba(212, 160, 23, 0.25);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-link,
.panel {
  display: block;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(247, 239, 226, 0.1);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.panel {
  margin-bottom: 1.25rem;
}

.list-title {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.card-link:hover {
  border-color: rgba(212, 160, 23, 0.45);
}

.card-link h2,
.panel h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
}

.meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  margin-top: 0.55rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid currentColor;
}

.badge--open {
  color: var(--gold);
}

.badge--live {
  color: #7dcea0;
}

.badge--bingo {
  color: var(--stamp);
  border-color: var(--stamp);
}

.empty {
  padding: 2.2rem 1rem;
  text-align: center;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.field span {
  font-size: 0.8rem;
  color: var(--muted);
}

.field input {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(247, 239, 226, 0.16);
  color: var(--foam);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
}

.board-wrap {
  background:
    linear-gradient(180deg, #f7edd8 0%, var(--paper) 40%, var(--paper-2) 100%);
  color: var(--ink);
  border-radius: 22px;
  padding: 0.9rem 0.7rem 0.85rem;
  box-shadow: var(--shadow), inset 0 0 0 3px #8e1428;
}

.letters {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 0.45rem;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(1.2rem, 6vw, 1.85rem);
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--stamp);
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.cell {
  aspect-ratio: 1;
  background: #fff8ea;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.28rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.cell textarea,
.cell .phrase {
  width: 100%;
  height: 100%;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--ui);
  font-size: clamp(0.58rem, 2.4vw, 0.82rem);
  line-height: 1.15;
  text-align: center;
  padding: 0;
}

.cell textarea:focus {
  outline: 2px solid var(--stamp);
  outline-offset: -2px;
  border-radius: 4px;
}

.cell .phrase {
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
  pointer-events: none;
}

.cell--play {
  cursor: pointer;
  user-select: none;
}

.cell--play:hover {
  background: #fff1d4;
}

.cell.marked::after {
  content: "";
  position: absolute;
  width: clamp(1.35rem, 42%, 2.1rem);
  height: clamp(1.35rem, 42%, 2.1rem);
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: 3px solid rgba(196, 30, 58, 0.95);
  background: rgba(196, 30, 58, 0.2);
  transform: translate(-50%, -50%) rotate(-12deg);
  pointer-events: none;
}

.cell.win {
  box-shadow: inset 0 0 0 2px var(--gold);
}

.status {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.9rem 0.15rem 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.warn {
  color: #f0c36d;
  font-size: 0.9rem;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 6, 8, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 1.5rem;
}

.overlay h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3.2rem, 16vw, 6rem);
  color: var(--gold);
  text-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: pop 0.45s ease;
}

@keyframes pop {
  from {
    transform: scale(0.6) rotate(-8deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(-2deg);
    opacity: 1;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%) translateY(120%);
  background: #2a1810;
  color: var(--paper);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  opacity: 0;
  transition: 0.25s ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.danger {
  color: #f0a0a8;
  font-size: 0.85rem;
}

@media (min-width: 640px) {
  .board-wrap {
    padding: 1.15rem 1.1rem 1rem;
  }
  .grid {
    gap: 6px;
  }
}
