:root {
  --paper: #FAF6F0;
  --ink: #2B2926;
  --muted: #8A8378;
  --hairline: #E4DCCB;
  --accent: #C1652F;

  --serif: Georgia, "Iowan Old Style", ui-serif, serif;
  --sans: -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

.page {
  max-width: 46rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

/* ---- Banner ---- */

/* Sticks to the top once scrolled past — the title stays visible as a
   persistent, unobtrusive banner rather than scrolling away. */
.site-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  text-align: center;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--hairline);
}

.wordmark {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2.5rem;
  margin: 0;
  letter-spacing: 0.01em;
}

/* ---- Intro ---- */

.intro {
  margin: 0 auto 3rem;
  text-align: center;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 30rem;
}

/* ---- Tiles ---- */

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.tile {
  position: relative;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 1.5rem;
  background: var(--paper);
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}

.tile--link:focus-within {
  transform: translateY(-3px);
  box-shadow: 0 10px 22px rgba(43, 41, 38, 0.09);
  border-color: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .tile--link:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(43, 41, 38, 0.09);
    border-color: var(--accent);
  }

  .tile--twin:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(43, 41, 38, 0.09);
  }
}

/* Touch equivalent of :hover — see script.js. Fires on touchstart, always
   cleared by touchend/touchcancel so nothing stays "stuck" after a tap. */
.tile.is-touch-active {
  transform: translateY(-3px);
  box-shadow: 0 10px 22px rgba(43, 41, 38, 0.09);
  animation: tile-wiggle 420ms ease;
}

.tile--link.is-touch-active {
  border-color: var(--accent);
}

.tile--link.is-touch-active .tile__enter {
  opacity: 1;
  transform: translateX(0);
}

@keyframes tile-wiggle {
  0% { rotate: 0deg; }
  25% { rotate: -1.2deg; }
  50% { rotate: 1.2deg; }
  75% { rotate: -0.6deg; }
  100% { rotate: 0deg; }
}

@media (prefers-reduced-motion: reduce) {
  .tile.is-touch-active {
    animation: none;
  }
}

.tile--twin {
  grid-column: 1 / -1;
  text-align: center;
}

.tile__stretched {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.tile__stretched:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.tile__name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.3rem;
  margin: 0 0 0.4rem;
}

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

.tile__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.25rem;
  min-height: 1.5rem;
}

.tile__enter {
  color: var(--accent);
  font-size: 0.88rem;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 200ms ease, transform 200ms ease;
}

.tile--link:focus-within .tile__enter {
  opacity: 1;
  transform: translateX(0);
}

@media (hover: hover) and (pointer: fine) {
  .tile--link:hover .tile__enter {
    opacity: 1;
    transform: translateX(0);
  }
}

.mail-link {
  position: relative;
  z-index: 2;
  color: var(--muted);
  text-decoration: none;
  font-size: 1.05rem;
  padding: 0.25rem;
  margin: -0.25rem;
  transition: color 180ms ease;
}

.mail-link:focus-visible {
  color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

@media (hover: hover) and (pointer: fine) {
  .mail-link:hover {
    color: var(--accent);
  }
}

/* ---- Twin tile ---- */

.twin__names {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 0;
  font-weight: 400;
}

.twin__name {
  font-family: var(--serif);
  font-size: 1.3rem;
}

.twin__divider {
  width: 1px;
  height: 1.4em;
  background: var(--hairline);
}

.tile--twin .tile__descriptor {
  margin: 0.6rem auto 0;
  max-width: 26rem;
}

/* ---- Footer ---- */

.footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--hairline);
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer__copyright {
  margin: 0 0 0.5rem;
}

.footer__invite {
  margin: 0 0 1.25rem;
}

/* ---- Game ---- */

.game {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.game__controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.game__modes {
  display: flex;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  overflow: hidden;
}

.game__mode-btn,
.game__restart {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease;
}

.game__mode-btn + .game__mode-btn {
  border-left: 1px solid var(--hairline);
}

@media (hover: hover) and (pointer: fine) {
  .game__mode-btn:hover,
  .game__restart:hover {
    color: var(--ink);
  }
}

.game__mode-btn.is-active {
  color: var(--ink);
  background: var(--hairline);
}

.game__restart {
  border: 1px solid var(--hairline);
  border-radius: 4px;
}

.game__legend {
  display: flex;
  gap: 0.5rem;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  transition: background 180ms ease, color 180ms ease;
}

.legend__item.is-turn {
  background: var(--hairline);
  color: var(--ink);
}

.mark--mini {
  width: 1rem;
  height: 1rem;
}

.game__status {
  min-height: 1.1rem;
  margin: 0;
  font-size: 0.8rem;
}

.game__board {
  display: grid;
  grid-template-columns: repeat(3, 2.6rem);
  grid-template-rows: repeat(3, 2.6rem);
  gap: 3px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
}

.game__cell {
  background: var(--paper);
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  transition: background 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .game__cell:hover:not(:disabled) {
    background: #F3ECE0;
  }
}

.game__cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.game__cell:disabled {
  cursor: default;
}

.mark {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mark--wave {
  color: var(--accent);
}

/* ---- Responsive ---- */

@media (max-width: 620px) {
  .page {
    padding: 1.75rem 1.25rem 2.5rem;
  }

  .site-banner {
    padding: 0.9rem 1.25rem;
  }

  .tiles {
    grid-template-columns: 1fr;
  }

  .wordmark {
    font-size: 2.1rem;
  }
}
