/* ==========================================================================
   鲫鱼速通 · 小游戏界面
   ========================================================================== */

.brand-play {
  padding: 0;
  border: 1px solid rgba(214, 161, 59, 0.5);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.18s ease, filter 0.18s ease;
}

.brand-play:hover {
  border-color: var(--gold);
  filter: brightness(1.18);
}

.brand-play::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid var(--gold-light);
  content: "";
  filter: drop-shadow(0 1px 2px #000);
  opacity: 0;
  transform: translate(-35%, -50%) scale(0.6);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.brand-play:hover::after,
.brand-play:focus-visible::after {
  opacity: 1;
  transform: translate(-35%, -50%) scale(1);
}

.brand-play:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
}

.brand-copy {
  color: inherit;
  text-decoration: none;
}

body.game-open {
  overflow: hidden !important;
}

.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at 50% 30%, rgba(20, 25, 23, 0.5), transparent 58%),
    rgba(2, 4, 4, 0.94);
  backdrop-filter: blur(5px);
}

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

.game-shell {
  display: flex;
  width: min(1280px, 96vw, calc((100svh - 152px) * 16 / 9));
  max-height: calc(100svh - 32px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--gold-line);
  background: #060909;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.72);
  clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 15px 100%, 0 calc(100% - 15px));
}

.game-overlay.is-start .game-bar,
.game-overlay.is-start .game-foot,
.game-overlay.is-result .game-bar,
.game-overlay.is-result .game-foot,
.game-overlay.is-pause .game-bar,
.game-overlay.is-pause .game-foot {
  display: none;
}

.game-result.is-fail .game-kicker,
.game-result.is-fail .game-result-stats {
  display: none;
}

.game-result.is-fail .game-start-card {
  width: min(760px, 100%);
}

.game-result.is-fail h2 {
  font-size: clamp(25px, 3.5vw, 40px);
  line-height: 1.35;
  letter-spacing: -0.03em;
}

.game-result.is-fail .game-result-actions {
  margin-top: 20px;
}

.game-start-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 40;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: rgba(5, 8, 7, 0.78);
  color: var(--muted);
  cursor: pointer;
}

.game-start-close:hover {
  border-color: var(--gold);
  color: var(--gold-light);
}

.game-start-close .icon {
  width: 15px;
  height: 15px;
}

.game-overlay:not(.is-start) .game-start-close {
  display: none;
}

.game-bar {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 13px;
  border-bottom: 1px solid var(--line);
  background: #080b0a;
}

.game-bar-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.game-bar-face {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--gold-line);
  flex: none;
}

.game-bar-face img {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

.game-bar-title b {
  display: block;
  color: var(--ivory);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.game-bar-title small {
  display: block;
  margin-top: 2px;
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.game-bar-side {
  display: flex;
  align-items: center;
  gap: 13px;
}

.game-step-count {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.game-close {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.game-close:hover {
  border-color: var(--gold);
  color: var(--gold-light);
}

.game-close .icon {
  width: 14px;
  height: 14px;
}

.game-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #0a0d0c;
  touch-action: none;
  user-select: none;
}

.game-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* HUD -------------------------------------------------------------------- */

.game-hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 17px 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.game-overlay.is-playing .game-hud {
  opacity: 1;
}

.game-hud::before,
.game-hud::after {
  position: absolute;
  right: 0;
  left: 0;
  height: 110px;
  content: "";
  pointer-events: none;
}

.game-hud::before {
  top: 0;
  background: linear-gradient(rgba(3, 6, 5, 0.7), transparent);
}

.game-hud::after {
  bottom: 0;
  background: linear-gradient(transparent, rgba(3, 6, 5, 0.82));
}

.game-hud-top,
.game-hud-bottom {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-hearts {
  display: flex;
  gap: 3px;
}

.game-hearts img {
  width: 19px;
  height: 19px;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 1px #000);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.game-hearts img.is-empty {
  opacity: 0.18;
  filter: grayscale(1) brightness(0.5);
}

.game-timer {
  padding: 5px 9px;
  border: 1px solid rgba(236, 233, 221, 0.16);
  background: rgba(4, 7, 6, 0.48);
  color: var(--ivory);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.game-progress {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.game-hud-bottom {
  align-items: flex-end;
}

.game-objective-wrap {
  max-width: 58%;
  padding: 7px 11px 8px;
  border-left: 2px solid var(--gold);
  background: rgba(4, 7, 6, 0.58);
}

.game-label {
  display: block;
  margin-bottom: 3px;
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.game-objective-wrap strong {
  display: block;
  overflow: hidden;
  color: var(--ivory);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-controls {
  color: rgba(236, 233, 221, 0.42);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.04em;
  text-align: right;
}

.game-controls-touch {
  display: none;
}

.game-rules-touch {
  display: none;
}

/* 开始 / 暂停 / 结算 ------------------------------------------------------ */

.game-screen {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 22px;
  isolation: isolate;
  background: linear-gradient(rgba(4, 7, 6, 0.84), rgba(4, 7, 6, 0.94));
  image-rendering: pixelated;
}

.game-screen::before {
  position: absolute;
  inset: -12px;
  z-index: -1;
  background: url("../img/game/dirt.png");
  background-size: 64px 64px;
  content: "";
  filter: blur(2px);
  opacity: 0.72;
}

.game-screen::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(3, 5, 4, 0.42);
  content: "";
  pointer-events: none;
}

.game-screen > * {
  position: relative;
  z-index: 1;
}

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

.game-start-card {
  width: min(540px, 100%);
  text-align: center;
}

.game-start-fish {
  width: 150px;
  height: auto;
  margin: 0 auto 11px;
  image-rendering: pixelated;
  animation: gameFishBob 2.4s ease-in-out infinite;
}

.game-kicker {
  margin: 0 0 8px;
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.game-start-card h2 {
  margin: 0;
  color: var(--ivory);
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 54px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
}

.game-start-copy {
  max-width: 430px;
  margin: 14px auto 18px;
  color: rgba(236, 233, 221, 0.76);
  font-size: 13px;
  line-height: 1.75;
}

.game-rules {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin-bottom: 19px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
}

.game-rules b {
  color: var(--gold-light);
}

.game-btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.game-btn:hover {
  border-color: var(--gold);
  color: var(--ivory);
}

.game-btn-primary {
  border-color: var(--gold);
  background: var(--gold);
  color: #0a0d0a;
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
}

.game-btn-primary:hover {
  background: var(--gold-light);
  color: #0a0d0a;
}

.game-btn:disabled {
  cursor: wait;
  opacity: 0.45;
}

.game-small {
  margin: 11px 0 0;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.04em;
}

.game-pause-card h2 {
  margin-bottom: 20px;
}

.game-result-stats {
  margin: 16px 0 20px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.9;
}

.game-result-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.game-result[hidden],
.game-pause[hidden],
.game-q[hidden] {
  display: none;
}

.game-q {
  position: absolute;
  bottom: 76px;
  left: 50%;
  z-index: 7;
  transform: translateX(-50%);
}

.game-toast {
  position: absolute;
  top: 56px;
  left: 50%;
  z-index: 6;
  max-width: 70%;
  padding: 7px 12px;
  border: 1px solid rgba(214, 161, 59, 0.38);
  background: rgba(4, 7, 6, 0.78);
  color: var(--ivory);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, -6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.game-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.game-btn-q {
  border-color: var(--gold);
  background: rgba(8, 11, 10, 0.86);
  color: var(--gold-light);
  box-shadow: 0 0 0 1px rgba(214, 161, 59, 0.2);
  animation: gameQ 1.2s ease-in-out infinite;
}

.game-btn-q:hover {
  background: var(--gold);
  color: #0a0d0a;
}

/* 底栏 -------------------------------------------------------------------- */

.game-foot {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 13px;
  border-top: 1px solid var(--line);
  background: #080b0a;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.03em;
}

.game-controls-touch {
  display: none;
}

.game-credit {
  text-align: right;
}

.game-credit a {
  color: var(--muted);
}

.game-credit a:hover {
  color: var(--gold);
}

@keyframes gameFishBob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes gameQ {
  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(214, 161, 59, 0.18);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(214, 161, 59, 0.06);
  }
}

/* 竖屏手机：先提示横屏，避免把 16:9 游戏压成一条 */
.game-rotate {
  display: none;
}

@media (max-width: 900px) {
  .game-overlay {
    padding: 0;
  }

  .game-shell {
    width: min(100vw, calc((100svh - 92px) * 16 / 9));
    max-height: 100svh;
    border: 0;
    clip-path: none;
  }

  .game-bar {
    min-height: 42px;
  }

  .game-foot {
    min-height: 28px;
  }

  .game-controls-desktop {
    display: none;
  }

  .game-controls-touch {
    display: inline;
  }

  .game-rules-touch {
    display: inline;
  }

  .game-credit {
    display: inline;
    max-width: 46%;
    font-size: 6px;
    line-height: 1.3;
    text-align: right;
  }

  .game-hud {
    padding: 10px 11px;
  }

  .game-objective-wrap {
    max-width: 66%;
    padding: 6px 8px;
  }

  .game-objective-wrap strong {
    font-size: 12px;
  }

  .game-timer {
    font-size: 9px;
  }

  .game-progress {
    font-size: 8px;
  }

  .game-hearts img {
    width: 16px;
    height: 16px;
  }

  .game-screen {
    padding: 12px;
  }

  .game-start-card {
    width: min(460px, 100%);
  }

  .game-start-fish {
    width: 100px;
  }

  .game-start-card h2 {
    font-size: clamp(28px, 8vw, 40px);
  }

  .game-start-copy {
    margin: 9px auto 12px;
    font-size: 11px;
    line-height: 1.6;
  }

  .game-rules {
    gap: 4px 10px;
    margin-bottom: 13px;
    font-size: 7px;
  }

  .game-small {
    margin-top: 7px;
  }

  .game-q {
    bottom: 58px;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  .game-rotate {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
      linear-gradient(rgba(4, 7, 6, 0.9), rgba(4, 7, 6, 0.96)),
      url("../img/game/dirt.png");
    background-size: auto, 64px 64px;
    text-align: center;
  }

  .game-rotate p {
    max-width: 280px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
  }

  .game-rotate strong {
    display: block;
    margin-bottom: 8px;
    color: var(--ivory);
    font-size: 20px;
  }
}

/* 矮屏 / 横屏手机：压缩开始页，保证开始按钮始终露出来 */
@media (max-height: 520px) {
  .game-screen {
    padding: 10px;
  }

  .game-start-fish {
    width: 64px;
    margin-bottom: 5px;
  }

  .game-start-card h2 {
    font-size: 30px;
  }

  .game-start-copy {
    margin: 7px auto 11px;
    font-size: 10px;
    line-height: 1.5;
  }

  .game-rules {
    margin-bottom: 10px;
  }

  .game-small {
    display: none;
  }

  .game-start-card .game-kicker {
    margin-bottom: 5px;
  }
}
