:root {
  color-scheme: light;
  font-family: "Segoe UI", Arial, sans-serif;
  color: #382d26;
  background: #fff8eb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 12% 2%, rgba(255, 222, 167, 0.35), transparent 28rem),
    #fff8eb;
}

button {
  font: inherit;
}

.page {
  width: min(100% - 40px, 950px);
  margin: 0 auto;
}

.page-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(112, 80, 52, 0.1);
}

.wordmark {
  color: #594334;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.8px;
  text-decoration: none;
}

.wordmark span {
  color: #f28a45;
}

.game-label {
  color: #9b8778;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 620px) 250px;
  align-items: start;
  justify-content: center;
  gap: 30px;
  padding: 30px 0 20px;
}

.game-main {
  min-width: 0;
}

.game-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 10px 12px;
}

.game-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: #e78340;
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-size: clamp(30px, 5vw, 40px);
  font-weight: 700;
  letter-spacing: 0.015em;
  line-height: 1.15;
  text-shadow: 1px 2px 0 rgba(244, 181, 124, 0.35);
  transform: rotate(-1deg);
  transform-origin: left center;
}

.reset-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border: 1px solid #eddfca;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  color: #755e4a;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: background 140ms ease, transform 140ms ease;
}

.reset-button:hover {
  transform: translateY(-1px);
  background: #fff;
}

.sound-button {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid #eddfca;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  color: #755e4a;
  cursor: pointer;
  font-size: 16px;
  transition: background 140ms ease, transform 140ms ease;
}

.sound-button:hover {
  transform: translateY(-1px);
  background: #fff;
}

.sound-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.reset-button:focus-visible,
.sound-button:focus-visible,
button:focus-visible,
canvas:focus-visible {
  outline: 3px solid #f3a65c;
  outline-offset: 3px;
}

.reset-button:first-letter {
  font-size: 17px;
}

.playfield {
  position: relative;
  width: min(100%, 430px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #ead8bf;
  border-radius: 22px;
  background: #fbf3e5;
  box-shadow: 0 16px 38px rgba(107, 76, 43, 0.12), 0 3px 8px rgba(107, 76, 43, 0.06);
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(62, 43, 30, 0.35);
  backdrop-filter: blur(3px);
}

.game-overlay[hidden] {
  display: none;
}

.overlay-card {
  width: min(100%, 270px);
  padding: 26px 22px 22px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  background: #fffaf1;
  box-shadow: 0 14px 40px rgba(55, 39, 27, 0.2);
  text-align: center;
}

.overlay-fruit {
  display: block;
  margin-bottom: 8px;
  font-size: 48px;
}

.overlay-card h2 {
  margin-bottom: 5px;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 23px;
  font-weight: 900;
}

.overlay-card p {
  margin-bottom: 18px;
  color: #8d7967;
  font-size: 14px;
}

.overlay-card p strong {
  color: #5a4432;
}

.overlay-card button {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: #ef9250;
  color: white;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 4px 0 #d5783c;
}

.overlay-card button:hover {
  background: #e78340;
}

.game-tip {
  margin: 13px 10px 0;
  color: #9c8875;
  font-size: 12px;
  text-align: center;
}

.game-tip span {
  margin-right: 4px;
  color: #e9954d;
}

.game-sidebar {
  display: grid;
  gap: 13px;
  padding-top: 15px;
}

.score-card,
.next-card {
  border: 1px solid #f0e2ce;
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 5px 16px rgba(107, 76, 43, 0.045);
}

.score-card {
  padding: 17px 19px 14px;
}

.card-label {
  display: block;
  color: #aa9076;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.score-card > strong {
  display: block;
  margin: 3px 0 8px;
  color: #533d2d;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 37px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
}

.best-score {
  padding-top: 9px;
  border-top: 1px solid #f2e8d9;
  color: #b19d88;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.best-score span {
  float: right;
  color: #866b51;
  font-size: 11px;
  letter-spacing: 0;
}

.next-card {
  min-height: 128px;
  padding: 16px 19px 12px;
}

.next-fruit {
  min-height: 54px;
  margin-top: 1px;
  font-size: 43px;
  line-height: 1.3;
}

.next-fruit-image {
  display: block;
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 3px 4px rgba(108, 72, 39, 0.15));
}

.next-name {
  color: #927b65;
  font-size: 11px;
  font-weight: 600;
}

@media (max-width: 760px) {
  .page {
    width: min(100% - 28px, 520px);
  }

  .page-header {
    height: 60px;
  }

  .game-layout {
    grid-template-columns: minmax(0, 430px);
    gap: 15px;
    padding-top: 22px;
  }

  .game-sidebar {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-top: 0;
  }

  .score-card,
  .next-card {
    min-height: 118px;
  }

}

@media (max-width: 420px) {
  .game-heading {
    margin-right: 4px;
    margin-left: 4px;
  }

  h1 {
    font-size: clamp(21px, 7vw, 32px);
  }

  .game-actions {
    gap: 6px;
  }

  .reset-button {
    padding-right: 9px;
    padding-left: 9px;
  }

  .game-sidebar {
    gap: 8px;
  }

  .game-tip {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
