:root {
  color-scheme: light;
  --header: #173d34;
  --header-line: #2b5c50;
  --text: #f7fbf4;
  --muted: #afcac0;
  --yellow: #ffd15b;
  --sky: #8ed5ea;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body,
button {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }

button svg,
a svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

[hidden] { display: none !important; }

.game-app {
  display: grid;
  width: 100%;
  height: 100dvh;
  grid-template-rows: 64px minmax(0, 1fr);
  background: var(--sky);
  user-select: none;
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  min-width: 0;
  grid-template-columns: 42px minmax(180px, 1fr) minmax(500px, 720px) minmax(98px, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--header-line);
  color: var(--text);
  background: var(--header);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #477267;
  border-radius: 5px;
  color: #e4f0eb;
  background: #204b40;
  cursor: pointer;
  text-decoration: none;
}

.icon-button:disabled { opacity: 0.4; cursor: default; }
.icon-button .play-icon, .icon-button.is-paused .pause-icon, .mute-line { display: none; }
.icon-button.is-paused .play-icon, .icon-button.is-muted .mute-line { display: block; }
.icon-button.is-muted .sound-wave { display: none; }

.brand { display: flex; min-width: 0; align-items: center; gap: 10px; }
.brand > span:last-child { display: grid; min-width: 0; gap: 2px; }
.brand strong { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.brand small,
.metrics span,
.screen-content > p {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
}

.brand-fruit {
  position: relative;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  border-radius: 48% 52% 50% 50%;
  background: #ef6558;
  box-shadow: inset -6px -5px 0 rgba(119, 31, 30, 0.18);
}

.brand-fruit::before {
  position: absolute;
  top: -5px;
  left: 16px;
  width: 4px;
  height: 9px;
  border-radius: 2px;
  background: #6c4527;
  content: "";
  transform: rotate(15deg);
}

.brand-fruit::after {
  position: absolute;
  top: -3px;
  left: 20px;
  width: 10px;
  height: 6px;
  border-radius: 8px 1px 8px 1px;
  background: #79b64d;
  content: "";
}

.metrics {
  display: grid;
  height: 100%;
  grid-template-columns: repeat(4, minmax(70px, 1fr)) minmax(105px, 1.2fr);
  border-right: 1px solid var(--header-line);
  border-left: 1px solid var(--header-line);
}

.metrics > div {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: 3px;
  padding: 0 14px;
  border-right: 1px solid var(--header-line);
}

.metrics > div:last-child { border-right: 0; }
.metrics strong { font-family: "SFMono-Regular", Consolas, monospace; font-size: 17px; font-variant-numeric: tabular-nums; }

.life-cells { display: grid; width: 82px; height: 12px; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.life-cells i { border: 1px solid #b69033; background: var(--yellow); }
.life-cells i.is-empty { border-color: #5d756e; background: #31584e; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

.playfield {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--sky);
  isolation: isolate;
}

#gameCanvas { display: block; width: 100%; height: 100%; cursor: ew-resize; touch-action: none; }

.catch-popup {
  position: absolute;
  z-index: 8;
  color: #153e33;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 22px;
  font-weight: 900;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.screen-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  color: #f8fbf6;
  background: rgba(20, 56, 48, 0.63);
}

.screen-layer.is-hidden { pointer-events: none; opacity: 0; transition: opacity 180ms ease; }
.screen-content { display: grid; width: min(430px, calc(100% - 32px)); justify-items: center; text-align: center; }
.screen-content > p { margin: 0 0 13px; color: #ffe188; }
.screen-content h1 { margin: 0; font-size: clamp(38px, 7vh, 64px); line-height: 1; }
.screen-content > span { margin: 14px 0 24px; font-size: 14px; }

.result {
  display: grid;
  width: min(290px, 100%);
  margin-bottom: 20px;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid rgba(255,255,255,0.42);
  border-bottom: 1px solid rgba(255,255,255,0.42);
}
.result div { display: grid; gap: 3px; padding: 12px; }
.result div + div { border-left: 1px solid rgba(255,255,255,0.25); }
.result small { color: #cae0d9; }
.result strong { font-family: "SFMono-Regular", Consolas, monospace; font-size: 20px; }

.primary-button {
  display: flex;
  height: 46px;
  align-items: center;
  gap: 9px;
  padding: 0 22px;
  border: 1px solid #c3942f;
  border-radius: 5px;
  color: #2e240e;
  background: var(--yellow);
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 920px) {
  .game-app { grid-template-rows: 104px minmax(0, 1fr); }
  .topbar {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    grid-template-rows: 54px 50px;
    gap: 0 9px;
    padding: 0 12px;
  }
  .icon-button { width: 34px; height: 34px; }
  .brand-fruit { width: 27px; height: 27px; }
  .brand strong { font-size: 14px; }
  .metrics {
    grid-area: 2 / 1 / 3 / 4;
    width: calc(100% + 24px);
    height: 50px;
    margin-left: -12px;
    grid-template-columns: repeat(4, minmax(52px, 1fr)) minmax(86px, 1.2fr);
  }
  .metrics > div { gap: 2px; padding: 0 7px; }
  .metrics strong { font-size: 14px; }
  .life-cells { width: min(74px, 100%); gap: 2px; }
}

@media (max-width: 520px) {
  .brand-fruit, .brand small { display: none; }
  .metrics span { font-size: 8px; }
  .metrics strong { font-size: 13px; }
  .screen-content { transform: translateY(-20px); }
  .screen-content h1 { font-size: 38px; }
}
