:root {
  --ink: #1b1424;
  --font: 'Bangers', 'Luckiest Guy', Impact, 'Haettenschweiler', 'Arial Narrow Bold', 'Arial Black', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #6c8fb0; user-select: none; -webkit-user-select: none; }
canvas#game { display: block; position: fixed; inset: 0; touch-action: none; cursor: default; }

.ov {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(27, 20, 36, 0.55); font-family: var(--font); color: var(--ink); z-index: 10; padding: 16px;
}
.ov.clear { background: radial-gradient(ellipse at center, rgba(27,20,36,0) 30%, rgba(27,20,36,0.45) 100%); }

.btn {
  font-family: var(--font); font-size: 26px; letter-spacing: 1px; color: #fff; cursor: pointer;
  padding: 12px 34px; border: 4px solid var(--ink); border-radius: 14px; min-width: 240px;
  box-shadow: 5px 6px 0 var(--ink); text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
  transition: transform .08s, box-shadow .08s; margin: 7px;
}
.btn:hover { transform: translate(-1px, -3px) rotate(-1deg); box-shadow: 6px 9px 0 var(--ink); }
.btn:active { transform: translate(3px, 4px); box-shadow: 2px 2px 0 var(--ink); }
.btn[disabled] { filter: grayscale(1) brightness(.8); pointer-events: none; }
.btn.red { background: #ff5a4a; } .btn.yellow { background: #ffc93c; } .btn.blue { background: #5ab0ff; }
.btn.sm { font-size: 18px; padding: 8px 18px; min-width: 0; }
.btn.lang { background: #8a6bd6; }
.btn.lang span { opacity: .45; }
.btn.lang span.on { opacity: 1; color: #ffe46b; }

.title { text-align: center; }
.logo { display: flex; flex-direction: column; align-items: center; transform: rotate(-4deg); margin-bottom: 8px; }
.logo span { display: block; line-height: .9; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.logo .l1 { font-size: clamp(56px, 11vw, 130px); color: #ffe46b; text-shadow: 7px 8px 0 var(--ink); }
.logo .l2 { font-size: clamp(64px, 13vw, 160px); color: #ff6b4a; text-shadow: 8px 9px 0 var(--ink); margin-top: -6px; }
.tag { display: inline-block; background: #fff; border: 4px solid var(--ink); border-radius: 12px; padding: 6px 18px; font-size: 22px; box-shadow: 5px 5px 0 var(--ink); transform: rotate(1.5deg); margin: 10px 0 22px; }
.menu { display: flex; flex-direction: column; align-items: center; }
.best { margin-top: 14px; font-size: 22px; color: #ffe46b; text-shadow: 2px 2px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink); }
.foot { margin-top: 18px; font-size: 15px; color: #fff; opacity: .85; text-shadow: 2px 2px 0 var(--ink); }

.panel {
  background: #fff7e0; border: 5px solid var(--ink); border-radius: 18px; box-shadow: 9px 10px 0 var(--ink);
  padding: 22px 30px; text-align: center; max-width: 920px; max-height: 92vh; overflow: auto;
  background-image: radial-gradient(rgba(27,20,36,.08) 1.5px, transparent 1.6px); background-size: 12px 12px;
}
.panel.small { display: flex; flex-direction: column; align-items: center; }
.panel h2, .upg h2 { font-size: 52px; margin: 0 0 12px; color: #ffe46b; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 5px 5px 0 var(--ink); letter-spacing: 2px; }
.help .cols { display: flex; gap: 26px; text-align: left; flex-wrap: wrap; }
.help ul { flex: 1 1 320px; margin: 0 0 14px; padding-left: 20px; font-family: 'Segoe UI', system-ui, sans-serif; font-size: 15px; line-height: 1.55; }
.help ul.keys { list-style: none; padding-left: 0; }
kbd { display: inline-block; min-width: 26px; padding: 1px 7px; border: 3px solid var(--ink); border-radius: 7px; background: #ffe46b; font-family: var(--font); font-size: 15px; box-shadow: 2px 3px 0 var(--ink); text-align: center; }
.over h2 { color: #ff6b4a; }
.stats { display: flex; gap: 14px; margin: 4px 0 16px; }
.stats div { background: #fff; border: 4px solid var(--ink); border-radius: 12px; padding: 8px 18px; box-shadow: 4px 4px 0 var(--ink); display: flex; flex-direction: column; }
.stats span { font-size: 16px; color: #6b5a7a; } .stats b { font-size: 38px; color: var(--ink); font-weight: normal; }

.upg { text-align: center; }
.upg .sub { font-size: 24px; color: #fff; text-shadow: 3px 3px 0 var(--ink); margin: -6px 0 16px; }
.cards { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.card {
  width: 230px; background: #fff7e0; border: 5px solid var(--ink); border-radius: 16px; box-shadow: 7px 8px 0 var(--ink);
  padding: 10px 12px 14px; cursor: pointer; position: relative; transition: transform .12s, box-shadow .12s;
  background-image: radial-gradient(rgba(27,20,36,.07) 1.5px, transparent 1.6px); background-size: 11px 11px;
  animation: deal .45s cubic-bezier(.2, 1.6, .4, 1) backwards;
}
.card:nth-child(2) { animation-delay: .08s; } .card:nth-child(3) { animation-delay: .16s; }
@keyframes deal { from { transform: translateY(80px) rotate(-8deg) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.card:hover { transform: translateY(-10px) rotate(-1.5deg); box-shadow: 9px 16px 0 var(--ink); }
.card canvas { width: 200px; height: 170px; display: block; margin: 0 auto; background: radial-gradient(circle at 50% 60%, #fff 0, #ffe9b8 60%, transparent 61%); }
.card h3 { margin: 6px 0 0; font-size: 26px; font-weight: normal; letter-spacing: 1px; }
.card .ctag { font-size: 15px; color: #6b5a7a; }
.card p { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; margin: 8px 0 0; min-height: 40px; }
.card .rar { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); padding: 2px 14px; border: 3px solid var(--ink); border-radius: 10px; font-size: 16px; color: #fff; text-shadow: 1px 1px 0 var(--ink); }
.r-common .rar { background: #8fa6c0; } .r-rare .rar { background: #5ab0ff; } .r-epic .rar { background: #b46bff; }
.r-epic { background-color: #fbefff; } .r-rare { background-color: #eef7ff; }

.btn.purple { background: #b46bff; }
.sandbox b { color: #c98a1a !important; }
.over .tip { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; margin: -6px 0 10px; color: #6b5a7a; }

.ov.perkov { align-items: stretch; }
.perks {
  width: min(1180px, 100%); margin: auto; max-height: 100%; display: flex; flex-direction: column; gap: 10px;
  background: #fff7e0; border: 5px solid var(--ink); border-radius: 18px; box-shadow: 9px 10px 0 var(--ink); padding: 16px 20px; text-align: center;
  background-image: radial-gradient(rgba(27,20,36,.07) 1.5px, transparent 1.6px); background-size: 12px 12px;
}
.perks .ph { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: space-between; }
.perks h2 { font-size: 46px; margin: 0; color: #b46bff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 5px 5px 0 var(--ink); }
.perks .sand { display: flex; align-items: center; gap: 6px; background: #2a2038; color: #ffe9a8; border: 4px solid var(--ink); border-radius: 12px; padding: 2px 14px 2px 4px; box-shadow: 4px 4px 0 var(--ink); }
.perks .sand b { font-size: 30px; font-weight: normal; } .perks .sand span { font-size: 15px; color: #c8b8e0; }
.perks .slots { font-size: 20px; } .perks .slots b { font-weight: normal; color: #c2402e; font-size: 24px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tab { font-family: var(--font); font-size: 17px; padding: 4px 12px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; cursor: pointer; box-shadow: 2px 3px 0 var(--ink); }
.tab.on { background: #ffc93c; transform: translateY(-2px); }
.pgrid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; padding: 6px 4px 10px; min-height: 200px; }
.perk { background: #fff; border: 4px solid var(--ink); border-radius: 14px; padding: 6px 4px 6px; cursor: pointer; box-shadow: 4px 5px 0 var(--ink); transition: transform .08s; position: relative; }
.perk:hover { transform: translateY(-4px) rotate(-1deg); }
.perk canvas { width: 88px; height: 88px; display: block; margin: 0 auto; }
.perk .pn { font-size: 16px; line-height: 1.05; min-height: 34px; display: flex; align-items: center; justify-content: center; }
.perk .pc { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 12px; font-weight: 700; color: #6b5a7a; }
.perk.lock { background: #e6e0ee; } .perk.lock .pn { color: #6b5a7a; }
.perk.can .pc { color: #c98a1a; } .perk.can { border-color: #c98a1a; }
.perk.eq { background: #fff1b8; box-shadow: 0 0 0 4px #ffc93c, 4px 5px 0 4px var(--ink); } .perk.eq .pc { color: #25743b; }
.perks { overflow-y: auto; }
.perks > .btn { align-self: center; }
.perk.lock canvas { filter: saturate(0.35); }
.perks > * { flex-shrink: 0; }
.perks > .pgrid { flex: 1 1 auto; flex-shrink: 1; }
.pdesc { display: flex; align-items: center; gap: 14px; text-align: left; min-height: 92px; background: #fff; border: 4px solid var(--ink); border-radius: 14px; padding: 8px 14px; box-shadow: 4px 5px 0 var(--ink); }
.pdesc canvas { width: 72px; height: 72px; flex: 0 0 72px; }
.pdt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pdn { font-size: 26px; line-height: 1; letter-spacing: 1px; -webkit-text-stroke: 1px var(--ink); }
.pdtags { display: flex; gap: 6px; }
.tg { font-size: 13px; padding: 1px 8px; border: 2px solid var(--ink); border-radius: 7px; background: #ffe46b; text-transform: uppercase; }
.tg.r { color: #fff; text-shadow: 1px 1px 0 var(--ink); }
.pdx { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 15px; color: var(--ink); }
.st { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 12px; font-weight: 800; letter-spacing: .5px; }
.st.eq { color: #25743b; } .st.own { color: #3f7fe0; } .st.full { color: #a0907a; } .st.buy { color: #c98a1a; } .st.no { color: #c2402e; }

canvas#game {
  inset: env(safe-area-inset-top) auto auto env(safe-area-inset-left);
  width: calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right));
  height: calc(100% - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.ov {
  inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.ov > * { min-width: 0; max-width: 100%; max-height: 100%; }
.title, .upg { overflow: auto; padding: 14px 16px; }
.perk-detail { display: none; }

@media (hover: none) {
  .perks .pdesc { display: none; }
  .perk-detail { display: block; margin: 6px 0 2px; font-size: 12px; overflow-wrap: anywhere; }
}

@media (max-width: 800px), (max-height: 600px) {
  .ov > * { overflow: auto; overscroll-behavior: contain; }
  .title, .upg { padding-inline: 8px; }
  .logo .l1 { font-size: clamp(40px, 12vw, 100px); }
  .logo .l2 { font-size: clamp(48px, 15vw, 120px); }
  .panel, .perks { padding: 14px; }
  .panel h2, .upg h2, .perks h2 { font-size: clamp(28px, 8vw, 44px); }
  .btn { min-width: 0; max-width: calc(100% - 14px); padding-inline: 18px; }
  .btn, .tab { min-height: 44px; }
  .help .cols, .perks .ph { gap: 10px; }
  .stats { flex-wrap: wrap; justify-content: center; }
  .stats div { flex: 1 1 90px; padding-inline: 8px; }
  .cards { padding: 16px 8px 8px; }
  .card { max-width: 100%; }
  .card canvas { max-width: 100%; height: auto; }
  .perks > .pgrid { flex: none; min-height: 0; overflow: visible; }
  .perks .pgrid { grid-template-columns: repeat(auto-fit, minmax(min(104px, 100%), 1fr)); }
  .pdtags { flex-wrap: wrap; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .title { width: 100%; }
  .logo .l1 { font-size: 52px; }
  .logo .l2 { font-size: 64px; }
  .title .menu { flex-direction: row; justify-content: center; flex-wrap: wrap; }
  .title .tag { margin-bottom: 8px; }
  .upg h2 { font-size: 30px; margin-bottom: 2px; }
  .upg .sub { font-size: 17px; margin: 0 0 6px; }
  .cards { flex-wrap: nowrap; gap: 12px; padding-top: 14px; margin-bottom: 6px; }
  .card { min-width: 0; flex: 1 1 0; width: auto; max-width: 230px; padding: 6px 8px 8px; }
  .card canvas { width: 84px; height: 72px; }
  .card h3 { font-size: 19px; margin-top: 2px; }
  .card .ctag { font-size: 13px; }
  .card p { font-size: 12px; margin-top: 4px; min-height: 0; }
}

/* ---------- toque (celular/tablet) ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; overscroll-behavior: none; }
.ov, .btn, .card, .perk, .tab { touch-action: manipulation; }
.touch-only { display: none; }
html.touch .touch-only { display: block; }
html.touch .no-touch { display: none; }
html.touch .btn:hover:not(:active), html.touch .card:hover, html.touch .perk:hover { transform: none; }

/* retrato estreito: cartas de recompensa viram faixas horizontais para caberem as 3 na tela */
@media (max-width: 600px) and (orientation: portrait) {
  .upg h2 { font-size: clamp(28px, 9vw, 40px); }
  .upg .sub { font-size: 18px; margin: 0 0 10px; }
  .cards { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 16px; padding: 12px 6px 6px; }
  .card {
    width: auto; display: grid; grid-template-columns: 96px 1fr; grid-template-rows: auto auto 1fr;
    column-gap: 10px; text-align: left; padding: 8px 10px; align-items: start;
  }
  .card .rar { left: auto; right: 14px; transform: none; top: -13px; }
  .card canvas { grid-row: 1 / 4; width: 96px; height: 82px; max-width: none; align-self: center; }
  .card h3 { font-size: 21px; margin: 4px 0 0; line-height: 1.05; }
  .card .ctag { font-size: 13px; }
  .card p { font-size: 13px; margin: 4px 0 0; min-height: 0; }
}
