:root {
  color-scheme: light;
  --panel: rgba(255, 250, 244, 0.92);
  --ink: #2d241b;
  --muted: #6f6254;
  --primary: #d85f39;
  --primary-dark: #ad4929;
  --accent: #207561;
  --accent-dark: #155344;
  --board: #1f1a17;
  --board-grid: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 50px rgba(80, 52, 28, 0.18);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(circle at top left, rgba(216, 95, 57, 0.22), transparent 30%),
    radial-gradient(circle at bottom right, rgba(32, 117, 97, 0.24), transparent 34%),
    linear-gradient(160deg, #f8f3eb 0%, #efe6da 100%);
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.game-panel {
  width: min(100vw, 430px);
  min-height: 100dvh;
  padding: max(6px, env(safe-area-inset-top)) 8px max(10px, env(safe-area-inset-bottom)) 8px;
  background: var(--panel);
  border: 1px solid rgba(111, 98, 84, 0.14);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  touch-action: manipulation;
}

.heading,
.hud-strip,
.drop-row,
.action-row {
  display: flex;
  width: 100%;
}

.heading {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
  text-align: center;
}

.hub-link {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  background: rgba(111, 98, 84, 0.1);
  font-weight: 700;
}

.eyebrow,
.label {
  display: block;
  font-size: 0.52rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 1px 0 0;
  font-size: 1.02rem;
  line-height: 1;
}

.play-area {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.board-wrap {
  position: relative;
  display: inline-flex;
}

#next-piece,
#game {
  display: block;
  -webkit-user-select: none;
  user-select: none;
  background:
    linear-gradient(var(--board-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--board-grid) 1px, transparent 1px),
    var(--board);
}

#game {
  width: min(100%, 320px);
  max-height: calc(100dvh - 274px);
  height: auto;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.07);
  touch-action: none;
  background-size: calc(100% / 14) calc(100% / 28);
}

#next-piece {
  width: 34px;
  height: 34px;
  background-size: 12px 12px;
  border-radius: 8px;
}

.bomb-fab {
  position: absolute;
  top: 16%;
  right: 10px;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 30px rgba(21, 83, 68, 0.28);
  animation: bob 2s ease-in-out infinite;
}

.bomb-fab.is-visible {
  display: flex;
}

.bomb-count {
  position: absolute;
  top: -4px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff7e9;
  color: var(--accent-dark);
  font-size: 0.72rem;
  line-height: 20px;
}

.bomb-glyph {
  font-size: 1.1rem;
  font-weight: 800;
}

.score-burst-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 20px;
  pointer-events: none;
}

.score-burst {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translate(-50%, 10px) scale(0.92);
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff7e9;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  animation: burst-fade 900ms ease forwards;
}

.status-line {
  width: 100%;
  min-height: 0.9em;
  margin: 2px 0 0;
  text-align: center;
  color: var(--muted);
  line-height: 1.2;
  font-size: 0.54rem;
}

.hud-strip {
  gap: 4px;
  margin-top: 2px;
}

.hud-chip {
  flex: 1 1 0;
  min-width: 0;
  padding: 3px 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(111, 98, 84, 0.1);
  text-align: center;
}

.next-chip {
  flex: 0 0 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

strong {
  display: block;
  margin-top: 1px;
  font-size: 0.64rem;
}

.drop-row {
  margin-top: 4px;
  justify-content: center;
}

.action-row {
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}

button {
  border: none;
  border-radius: 999px;
  min-height: 42px;
  padding: 9px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button:hover,
button:focus-visible,
.hub-link:hover,
.hub-link:focus-visible {
  transform: translateY(-1px);
}

button:active,
.hub-link:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.ghost-button {
  color: var(--ink);
  background: rgba(111, 98, 84, 0.1);
}

.drop-button {
  width: min(100%, 320px);
  color: #fff;
  background: linear-gradient(135deg, #3b332d, #1f1a17);
}

.action-row button {
  min-width: 124px;
  min-height: 42px;
}

@keyframes burst-fade {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.9);
  }
  14% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -24px) scale(1.05);
  }
}

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

@media (min-width: 431px) {
  .game-panel {
    min-height: auto;
    border-radius: 26px;
    padding: 10px;
  }

  #game {
    max-height: 596px;
  }
}

@media (max-height: 760px) {
  #game {
    max-height: calc(100dvh - 258px);
  }

  .status-line {
    font-size: 0.52rem;
  }

  .hud-chip {
    padding: 2px 4px;
  }

  strong {
    font-size: 0.6rem;
  }

  .action-row button {
    min-height: 40px;
  }
}
