:root {
  --soil: #3b2417;
  --wood: #8a542f;
  --wood-light: #c4854a;
  --cream: #fff6dc;
  --paper: #fffaf0;
  --pond: #247e83;
  --pond-dark: #145b66;
  --leaf: #ef8130;
  --gold: #f3c35f;
  --grass: #5f9f47;
  --danger: #d94932;
  --ink: #26362f;
  --muted: #687a70;
  --line: rgba(59, 36, 23, .18);
  --shadow: 0 16px 36px rgba(59, 36, 23, .18);
  --radius: 7px;
  --display: Georgia, "Times New Roman", serif;
  --body: "Trebuchet MS", Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--body);
  background: #e9f5de url("../assets/images/pond_bg.svg") center top / cover fixed;
}

a {
  color: inherit;
}

button {
  font: inherit;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 14px clamp(16px, 4vw, 46px);
  background: rgba(255, 250, 240, .92);
  border-bottom: 4px solid rgba(138, 84, 47, .18);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  min-width: 0;
  max-width: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  text-decoration: none;
}

.logo img {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  flex: 0 0 auto;
}

.logo strong {
  display: block;
  font-family: var(--display);
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: .95;
  overflow-wrap: anywhere;
}

.logo span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.menu {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
  max-width: 100%;
}

.menu a {
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: .84rem;
  font-weight: 900;
  text-decoration: none;
  white-space: normal;
}

.menu a:hover,
.menu a.active {
  color: var(--cream);
  background: var(--wood);
}

.wrap {
  width: min(1160px, calc(100% - 28px));
  max-width: 100%;
  margin: 0 auto;
}

.game-shell {
  padding: 18px 0 44px;
}

.farm-board {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.score-board,
.play-card,
.field-note,
.article,
.legal,
.contact-card {
  min-width: 0;
  background: rgba(255, 250, 240, .95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.score-board {
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.score-board h1 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 2rem;
  line-height: 1;
}

.score-board p {
  margin: 0 0 16px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.meter-list {
  display: grid;
  gap: 8px;
}

.meter {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--leaf);
  border-radius: var(--radius);
}

.meter span {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.meter strong {
  font-family: var(--display);
  font-size: 1.5rem;
  line-height: .9;
}

.control-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.control-box h2 {
  margin: 0 0 9px;
  font-size: 1.05rem;
}

.mode-pills {
  display: grid;
  gap: 7px;
}

.mode-pills button,
.start-button,
.small-button {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 900;
}

.mode-pills button {
  padding: 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  text-align: left;
}

.mode-pills button.active {
  background: #ffe1a1;
  box-shadow: inset 5px 0 0 var(--leaf);
}

.start-button {
  width: 100%;
  margin-top: 12px;
  padding: 13px 16px;
  color: var(--cream);
  background: linear-gradient(180deg, #ec7d32, #bc4d27);
  box-shadow: 0 7px 0 #75331d;
}

.small-button {
  padding: 9px 12px;
  color: var(--cream);
  background: var(--wood);
}

.tips {
  margin-top: auto;
  padding-top: 16px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 800;
  line-height: 1.5;
}

.play-card {
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

.marquee {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  color: var(--cream);
  background: linear-gradient(90deg, var(--soil), var(--wood));
  min-width: 0;
}

.marquee h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  min-width: 0;
  overflow-wrap: anywhere;
}

.marquee span {
  color: #ffdca0;
  font-weight: 900;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

.canvas-zone {
  position: relative;
  background: var(--pond);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(36, 126, 131, .72);
  backdrop-filter: blur(7px);
  transition: opacity .22s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.start-card {
  width: min(470px, 94%);
  padding: 24px;
  text-align: center;
  background: var(--paper);
  border: 3px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: 0 20px 48px rgba(33, 51, 45, .3);
}

.start-card img {
  width: 110px;
}

.start-card h2 {
  margin: 8px 0;
  font-family: var(--display);
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

.start-card p {
  margin: 0 auto 16px;
  color: var(--muted);
  font-weight: 850;
  line-height: 1.5;
}

.note-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
  margin-top: 16px;
}

.field-note {
  padding: 18px;
}

.field-note h2,
.field-note h3 {
  margin: 0 0 8px;
  font-family: var(--display);
}

.field-note p,
.field-note li {
  color: var(--muted);
  font-weight: 780;
  line-height: 1.6;
}

.field-note ul {
  margin: 0;
  padding-left: 18px;
}

.hero {
  padding: 42px 0 18px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 22px;
  align-items: center;
  padding: clamp(22px, 4vw, 38px);
  background: rgba(255, 250, 240, .95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-panel h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.1rem, 5vw, 3.8rem);
  line-height: .95;
}

.hero-panel p {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.7;
}

.hero-panel img {
  width: 100%;
}

.article-grid,
.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 16px 0 44px;
}

.article,
.legal,
.contact-card {
  padding: clamp(20px, 3vw, 30px);
}

.article h2,
.legal h2 {
  margin: 0 0 10px;
  font-family: var(--display);
}

.article p,
.article li,
.legal p,
.legal li {
  color: var(--muted);
  font-weight: 780;
  line-height: 1.7;
}

.contact-card span {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.contact-card p,
.contact-card a {
  display: block;
  margin: 8px 0 0;
  color: var(--ink);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px clamp(16px, 4vw, 46px);
  color: var(--cream);
  background: var(--soil);
}

.footer a {
  color: var(--cream);
  font-weight: 900;
  text-decoration: none;
}

@media (max-width: 980px) {
  .farm-board,
  .note-grid,
  .article-grid,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .score-board {
    order: 2;
  }

  .play-card {
    order: 1;
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .menu {
    justify-content: flex-start;
    gap: 4px;
  }

  .menu a {
    padding: 7px 6px;
    font-size: .68rem;
  }

  .logo strong {
    font-size: 1.22rem;
  }

  .logo span {
    font-size: .66rem;
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

  .hero-panel img {
    max-width: 170px;
  }

  .marquee span {
    display: none;
  }
}

@media (max-width: 460px) {
  .logo img {
    width: 44px;
    height: 44px;
  }

  .logo strong {
    font-size: 1.22rem;
  }

  .marquee {
    align-items: flex-start;
    flex-direction: column;
  }

  .start-card {
    width: calc(100% - 20px);
    padding: 18px;
  }

  .start-card img {
    width: 86px;
  }
}
