:root {
  color-scheme: light;
  --ink: #2f2a25;
  --muted: #766d63;
  --paper: rgba(255, 252, 245, 0.86);
  --line: rgba(87, 66, 44, 0.12);
  --accent: #f27a54;
  --accent-dark: #c95336;
  --green: #5e9f67;
  --shadow: 0 18px 60px rgba(87, 58, 34, 0.13);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #fff6e8; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 196, 119, 0.22), transparent 30rem),
    radial-gradient(circle at 86% 22%, rgba(123, 195, 137, 0.2), transparent 28rem),
    linear-gradient(180deg, #fff9ef 0%, #fff2dc 100%);
}

button, canvas { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.ambient {
  position: fixed;
  width: 20rem;
  height: 20rem;
  border-radius: 50%;
  filter: blur(18px);
  opacity: .28;
  pointer-events: none;
  z-index: -1;
}
.ambient-a { left: -7rem; top: 38%; background: #ffd78f; }
.ambient-b { right: -8rem; top: 8%; background: #b8e1b6; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.brand-row { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  font-size: 35px;
  border-radius: 20px;
  background: rgba(255,255,255,.72);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.88);
}
.eyebrow, .kicker {
  margin: 0 0 5px;
  font-size: 11px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: .14em;
  color: var(--accent-dark);
}
h1 { margin: 0; font-size: clamp(28px, 4vw, 44px); line-height: 1.08; letter-spacing: -.03em; }
.subtitle { margin: 7px 0 0; color: var(--muted); font-size: 14px; }

.score-strip { display: grid; grid-template-columns: repeat(3, minmax(100px, 1fr)); gap: 10px; }
.score-card {
  min-width: 112px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.68);
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: 0 8px 24px rgba(80,54,30,.08);
}
.score-card.primary { background: #fff0df; }
.score-card span { display: block; color: var(--muted); font-size: 12px; }
.score-card strong { display: block; margin-top: 2px; font-size: 21px; font-variant-numeric: tabular-nums; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 760px) minmax(260px, 1fr);
  gap: 18px;
  align-items: start;
}
.game-column { min-width: 0; }
.game-frame {
  position: relative;
  width: 100%;
  max-width: 760px;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 28px;
  background: linear-gradient(180deg, #fff8e8, #f5d8ab);
  border: 1px solid rgba(255,255,255,.88);
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
}
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility .2s ease;
  background: rgba(70, 52, 34, .16);
  backdrop-filter: blur(6px);
}
.overlay.visible { opacity: 1; visibility: visible; pointer-events: auto; }
.overlay-card {
  width: min(420px, 94%);
  padding: 28px;
  text-align: center;
  border-radius: 26px;
  background: rgba(255, 252, 245, .96);
  border: 1px solid rgba(255,255,255,.96);
  box-shadow: 0 22px 80px rgba(58, 39, 26, .22);
}
.overlay-card.compact { width: min(330px, 92%); }
.overlay-fruit { font-size: 52px; filter: drop-shadow(0 7px 10px rgba(66,37,20,.12)); }
.overlay h2 { margin: 8px 0 8px; font-size: 28px; }
.overlay p { margin: 8px 0; color: var(--muted); line-height: 1.6; }
.overlay .small-note { margin-top: 14px; font-size: 12px; }
.new-best { color: var(--accent-dark) !important; font-weight: 800; }

.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 22px;
  min-height: 46px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  margin-top: 10px;
  color: #fff;
  background: linear-gradient(180deg, #ff8965, #ef704c);
  box-shadow: 0 10px 24px rgba(220, 91, 56, .25);
}

.side-panel { display: grid; gap: 12px; }
.panel-card {
  padding: 18px;
  border-radius: 22px;
  background: var(--paper);
  border: 1px solid rgba(255,255,255,.88);
  box-shadow: 0 10px 30px rgba(79,54,31,.08);
  backdrop-filter: blur(8px);
}
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading.simple { justify-content: flex-start; }
.panel-heading h2 { margin: 0; font-size: 18px; }
.panel-card > p { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.next-preview {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
}

.control-list { display: grid; gap: 9px; margin-top: 14px; }
.control-list div { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
kbd {
  min-width: 52px;
  padding: 5px 7px;
  text-align: center;
  border-radius: 8px;
  color: var(--ink);
  background: #fff9ef;
  border: 1px solid rgba(91, 63, 37, .13);
  box-shadow: inset 0 -2px 0 rgba(91, 63, 37, .06);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
}

.fruit-chain { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin-top: 14px; }
.chain-item {
  display: grid;
  place-items: center;
  min-height: 46px;
  border-radius: 12px;
  background: rgba(255,255,255,.62);
  border: 1px solid rgba(89,65,42,.08);
}
.chain-dot { display: block; border-radius: 50%; box-shadow: inset -4px -6px 10px rgba(74, 40, 23, .09), inset 4px 4px 8px rgba(255,255,255,.38); }

.desktop-action-row, .mobile-action-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.icon-btn {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(83,59,37,.12);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255,255,255,.72);
  font-weight: 700;
  cursor: pointer;
}
.icon-btn:hover { background: #fff; }
.icon-btn.danger { color: #a44633; }
.mobile-action-row { display: none; margin-top: 10px; }

.tip-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 13px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.56);
  color: var(--muted);
  font-size: 13px;
}
.tip-bar p { margin: 0; }
.tip-icon { font-size: 17px; }

@media (max-width: 900px) {
  .app-shell { width: min(720px, calc(100% - 24px)); padding-top: 18px; }
  .hero { align-items: stretch; flex-direction: column; gap: 14px; }
  .score-strip { width: 100%; }
  .game-layout { grid-template-columns: 1fr; }
  .game-frame { max-width: none; }
  .side-panel { grid-template-columns: 1fr 1fr; }
  .chain-card { grid-column: 1 / -1; }
  .desktop-action-row { display: none; }
  .mobile-action-row { display: grid; }
}

@media (max-width: 560px) {
  .app-shell { width: 100%; padding: 12px 10px 22px; }
  .brand-mark { width: 48px; height: 48px; font-size: 28px; border-radius: 16px; }
  .eyebrow { font-size: 9px; }
  .subtitle { font-size: 12px; }
  .score-strip { gap: 6px; }
  .score-card { min-width: 0; padding: 9px 9px; border-radius: 14px; }
  .score-card span { font-size: 10px; }
  .score-card strong { font-size: 17px; }
  .game-layout { gap: 10px; }
  .game-frame { border-radius: 20px; }
  .side-panel { grid-template-columns: 1fr; }
  .chain-card { grid-column: auto; }
  .controls-card { display: none; }
  .panel-card { padding: 14px; border-radius: 18px; }
  .fruit-chain { grid-template-columns: repeat(6, 1fr); gap: 5px; }
  .chain-item { min-height: 40px; }
  .overlay { padding: 14px; }
  .overlay-card { padding: 22px 18px; border-radius: 22px; }
  .overlay h2 { font-size: 24px; }
  .overlay p { font-size: 13px; }
  .tip-bar { margin-top: 10px; }
}

@media (max-height: 760px) and (min-width: 901px) {
  .app-shell { width: min(1100px, calc(100% - 32px)); padding-top: 14px; }
  .hero { margin-bottom: 12px; }
  .brand-mark { width: 50px; height: 50px; font-size: 29px; }
  h1 { font-size: 32px; }
  .subtitle { margin-top: 3px; }
  .game-layout { grid-template-columns: minmax(0, 640px) minmax(260px, 1fr); }
  .panel-card { padding: 14px; }
  .tip-bar { display: none; }
}

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

/* Phone landscape: keep the playfield fully usable instead of creating a very tall page. */
@media (orientation: landscape) and (max-height: 560px) and (max-width: 900px) {
  .app-shell { width: 100%; padding: 8px 10px 12px; }
  .hero { flex-direction: row; align-items: center; margin-bottom: 8px; gap: 10px; }
  .brand-row { min-width: 0; }
  .brand-mark { width: 40px; height: 40px; border-radius: 13px; font-size: 24px; flex: 0 0 auto; }
  .eyebrow, .subtitle { display: none; }
  h1 { font-size: 22px; white-space: nowrap; }
  .score-strip { margin-left: auto; width: min(380px, 52vw); gap: 5px; }
  .score-card { padding: 7px 8px; border-radius: 12px; min-width: 0; }
  .score-card span { font-size: 9px; }
  .score-card strong { font-size: 15px; }
  .game-layout {
    grid-template-columns: auto minmax(220px, 1fr);
    gap: 9px;
    justify-content: center;
  }
  .game-column { width: auto; }
  .game-frame {
    width: calc((100vh - 78px) * 2 / 3);
    max-width: 58vw;
    border-radius: 17px;
  }
  .mobile-action-row { display: none; }
  .side-panel { display: grid; grid-template-columns: 1fr; gap: 7px; }
  .panel-card { padding: 10px 12px; border-radius: 15px; }
  .panel-card > p { margin-top: 6px; font-size: 11px; line-height: 1.35; }
  .panel-heading h2 { font-size: 15px; }
  .kicker { font-size: 9px; }
  .next-preview { width: 48px; height: 48px; }
  .controls-card, .chain-card { display: none; }
  .desktop-action-row { display: grid; gap: 6px; }
  .icon-btn { min-height: 38px; padding: 7px 8px; border-radius: 11px; font-size: 12px; }
  .tip-bar { display: none; }
  .overlay { padding: 10px; }
  .overlay-card { width: min(300px, 92%); padding: 16px; border-radius: 18px; }
  .overlay-fruit { font-size: 34px; }
  .overlay h2 { margin: 4px 0; font-size: 20px; }
  .overlay p { margin: 4px 0; font-size: 11px; line-height: 1.4; }
  .overlay .small-note { display: none; }
  .btn { min-height: 38px; padding: 8px 18px; border-radius: 12px; }
}
