:root {
  --ink: #24233a;
  --yellow: #ffd23a;
  --green: #22b04b;
  --green-dark: #198d3a;
  --red: #e8323c;
  --orange: #f39a3d;
  --blue: #2d8cff;
  --cream: #fff6e8;
  --font-display: 'Fredoka', 'Arial Black', system-ui, sans-serif;
  --font-body: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--cream);
  user-select: none;
  -webkit-user-select: none;
}

.game-shell {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  gap: 8px;
  background-color: var(--cream);
  background-image:
    linear-gradient(to right, rgba(36, 35, 58, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(36, 35, 58, 0.05) 1px, transparent 1px);
  background-size: 36px 36px;
}

.game-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.shell-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 2.5px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.1s ease, background-color 0.12s ease;
}

.shell-btn:hover {
  background: var(--yellow);
  transform: translateY(-1px);
}

.shell-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.shell-btn--green {
  background: var(--green);
  color: #ffffff;
}

.shell-btn--green:hover {
  background: var(--green-dark);
}

.shell-btn--orange {
  background: var(--orange);
  color: var(--ink);
}

.hud-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hud-pill {
  padding: 5px 10px;
  border-radius: 999px;
  border: 2.5px solid var(--ink);
  background: #ffffff;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.hud-pill--yellow {
  background: var(--yellow);
}

.hud-pill--green {
  background: var(--green);
  color: #ffffff;
}

.hud-pill--red {
  background: var(--red);
  color: #ffffff;
}

.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: #fff9ee;
  box-shadow: 0 6px 0 var(--ink);
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.full-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  background: rgba(36, 35, 58, 0.56);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.overlay-card {
  width: 100%;
  max-width: 440px;
  background: #fffdf8;
  border: 3.5px solid var(--ink);
  border-radius: 22px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 8px 0 var(--ink);
}

.overlay-card h1,
.overlay-card h2 {
  margin: 6px 0 8px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  line-height: 1.15;
}

.overlay-card p {
  margin: 0 0 12px;
  font-size: 0.92rem;
  font-weight: 800;
  color: rgba(36, 35, 58, 0.85);
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.game-btn-lg {
  padding: 11px 18px;
  border-radius: 14px;
  border: 2.5px solid var(--ink);
  background: var(--green);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 0 var(--ink);
}

.game-btn-lg--yellow {
  background: var(--yellow);
  color: var(--ink);
}

.game-btn-lg--orange {
  background: var(--orange);
  color: var(--ink);
}

.game-btn-lg--white {
  background: #ffffff;
  color: var(--ink);
}

.game-btn-lg--story {
  background: linear-gradient(135deg, #f39a3d 0%, #e8323c 55%, #a855f7 100%);
  color: #ffffff;
}

/* Modal de prévia do Story 9:16 */
.story-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(36, 35, 58, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow-y: auto;
}

.story-modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 94dvh;
  overflow-y: auto;
  background: #fffdf8;
  border: 3.5px solid var(--ink);
  border-radius: 24px;
  padding: 16px;
  box-shadow: 0 10px 0 var(--ink);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.story-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.story-modal-head h2 {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: 1.18rem;
  line-height: 1.15;
}

.story-modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 0 var(--ink);
}

.story-preview-frame {
  display: flex;
  justify-content: center;
  background: #ffedd2;
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 10px;
}

.story-preview-img {
  width: auto;
  max-width: 100%;
  max-height: 46dvh;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  border: 2.5px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  object-fit: contain;
  background: #fff6e8;
}

.story-modal-actions {
  display: grid;
  gap: 8px;
}

.story-modal-actions .game-btn-lg {
  width: 100%;
  text-align: center;
  font-size: 0.92rem;
  padding: 10px 14px;
}

.story-modal-status {
  margin: 0;
  min-height: 18px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--green-dark);
}

.touch-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.touch-btn {
  flex: 1 1 0;
  padding: 11px 10px;
  border-radius: 14px;
  border: 2.5px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  touch-action: manipulation;
}

.touch-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
  background: var(--yellow);
}

.touch-btn--jump {
  background: var(--yellow);
}

@media (max-width: 560px) {
  .game-shell {
    padding: 6px;
    gap: 6px;
  }

  .hud-pill,
  .shell-btn {
    font-size: 0.74rem;
    padding: 5px 8px;
  }
}
