/* =========================================================
   ARCADE — game cards
   ========================================================= */
.arcade-grid { position: relative; display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; margin-top: 10px; }
.gcard {
  position: relative; display: flex; flex-direction: column; border-radius: 26px; overflow: hidden;
  background: linear-gradient(180deg, var(--ink3), var(--ink2)); border: 1px solid var(--line);
  transition: transform .6s var(--ease), border-color .4s, box-shadow .5s;
}
.gcard:hover { transform: translateY(-8px); border-color: rgba(227, 20, 27, .55); box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .9), 0 20px 80px -40px rgba(227, 20, 27, .7); }
.gcard-art { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #0d0a0a; }
.gcard-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; transition: transform 1.2s var(--ease); }
.gcard:hover .gcard-art canvas { transform: scale(1.05); }
.gcard-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 55%, rgba(17, 11, 10, .9)); pointer-events: none; }
.gcard-ninja { background: radial-gradient(circle at 60% 50%, rgba(227, 20, 27, .3), #0d0a0a 70%); }
.gcard-ninja .play-demo { position: absolute; inset: auto; left: 50%; top: 52%; width: min(64%, 330px); max-width: none; aspect-ratio: 1; transform: translate(-50%, -50%); }
.gcard-heroes { position: absolute; z-index: 2; right: 14px; bottom: 12px; display: flex; }
.gcard-heroes img { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; border: 2px solid var(--paper); background: var(--red); box-shadow: 0 6px 16px rgba(0, 0, 0, .5); }
.gcard-heroes img + img { margin-left: -14px; }
.gcard-body { display: flex; flex-direction: column; flex: 1; padding: 20px 24px 22px; }
.gtag { align-self: flex-start; padding: 6px 12px; border-radius: 30px; background: rgba(227, 20, 27, .14); color: var(--red2); font-weight: 800; font-size: 12px; letter-spacing: .08em; margin-bottom: 10px; }
.gcard-body h3 { margin: 0 0 6px; font: 800 26px/1.1 var(--f-display); color: var(--paper); }
.gcard-body p { margin: 0 0 14px; color: var(--muted); font-size: 14.5px; }
.rules.mini { margin: 0 0 16px; gap: 6px; grid-template-columns: 1fr 1fr; }
.rules.mini li { font-size: 12.5px; gap: 8px; }
.rules.mini i { width: 32px; height: 32px; border-radius: 10px; }
.rules.mini i img { width: 28px; }
.gfoot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gbest { display: flex; flex-direction: column; padding-left: 12px; border-left: 2px solid var(--red); }
.gbest small { font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.gbest b { font: 800 22px/1.1 var(--f-display); color: var(--paper); }

/* =========================================================
   ARCADE OVERLAY
   ========================================================= */
.arcade { position: fixed; inset: 0; z-index: 270; visibility: hidden; opacity: 0; transition: opacity .45s, visibility 0s .45s; background: #0a0707; overflow: hidden; }
.arcade.open { visibility: visible; opacity: 1; transition: opacity .45s; }
.arcade:not(.open), .arcade:not(.open) * { pointer-events: none !important; visibility: hidden !important; }
/* Exit stays reachable above the hero chooser and results. */
.arcade .ar-hud { z-index: 6; }
#arCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; z-index: 1; }
.ar-hud { position: absolute; z-index: 3; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px clamp(12px, 3vw, 30px); pointer-events: none; background: linear-gradient(rgba(10, 7, 7, .55), transparent); }
.ar-hud > * { pointer-events: auto; }
.ar-score small, .ar-best small { display: block; font-size: 10.5px; letter-spacing: .24em; text-transform: uppercase; color: rgba(243, 230, 207, .7); }
.ar-score b { font: 900 clamp(28px, 4.4vw, 46px)/1 var(--f-display); color: var(--paper); text-shadow: 0 0 24px rgba(227, 20, 27, .7), 0 2px 0 #000; }
.ar-best b { font: 800 20px/1 var(--f-display); color: var(--gold); }
.ar-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ar-mid > div { display: flex; align-items: center; gap: 10px; }
.ar-title { font: 800 12px var(--f-display); letter-spacing: .2em; text-transform: uppercase; color: rgba(243, 230, 207, .75); }
.ar-pill { padding: 6px 12px; border-radius: 30px; background: rgba(10, 7, 7, .7); border: 1px solid var(--line); font-weight: 700; font-size: 14px; color: var(--paper); }
.ar-pill b { font-family: var(--f-display); color: var(--red2); }
.ar-time { position: relative; width: clamp(140px, 28vw, 280px); height: 22px; border-radius: 20px; background: rgba(10, 7, 7, .75); border: 1px solid var(--line); overflow: hidden; }
.ar-time i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(90deg, #c9a26b, #ffd23a); border-radius: 20px; transition: width .2s linear; }
.ar-time i.low { background: linear-gradient(90deg, var(--blood), var(--red2)); animation: beat .8s infinite; }
.ar-time span { position: relative; display: block; text-align: center; font: 800 12px/22px var(--f-display); color: #140c0a; mix-blend-mode: normal; }
.ar-right { display: flex; align-items: center; gap: 10px; }
.arcade .x { position: static; }

.ar-controls { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; display: none; justify-content: space-between; gap: 10px; padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); pointer-events: none; }
.ar-controls:empty { display: none !important; }
@media (pointer: coarse), (max-width: 760px) { .ar-controls { display: flex; } }
.ar-btn { pointer-events: auto; flex: 1; max-width: 120px; height: 74px; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: rgba(20, 12, 10, .72); border: 1.5px solid rgba(243, 230, 207, .25); color: var(--paper); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); touch-action: none; user-select: none; -webkit-user-select: none; transition: transform .15s, background .15s; }
.ar-btn span { font-size: 26px; line-height: 1; }
.ar-btn small { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; opacity: .8; }
.ar-btn.on { background: rgba(227, 20, 27, .75); transform: scale(.94); }

.ar-screen { position: absolute; z-index: 5; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(5, 3, 3, .7); backdrop-filter: blur(4px); opacity: 0; visibility: hidden; transition: opacity .4s, visibility 0s .4s; overflow-y: auto; }
.ar-screen.show { opacity: 1; visibility: visible; transition: opacity .4s; }
.ar-screen .g-card { transform: translateY(30px) scale(.95); }
.ar-screen.show .g-card { transform: none; }
.g-extra:empty { display: none; }
.g-stats.g-extra { margin-top: -10px; }
.ar-screen .g-stats { grid-template-columns: repeat(2, 1fr); }

.ar-sel { width: min(760px, 100%); text-align: center; }
.ar-sel h3 { margin: 0 0 22px; font: 900 clamp(26px, 4vw, 40px) var(--f-display); color: var(--paper); }
.ar-heroes { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.hero-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 18px 20px; border-radius: 26px; overflow: hidden;
  border: 2px solid var(--line); background: linear-gradient(180deg, var(--ink3), var(--ink2)); color: var(--paper);
  transition: transform .5s var(--ease), border-color .3s, box-shadow .4s;
}
.hero-card:hover, .hero-card:focus-visible { transform: translateY(-8px) scale(1.02); border-color: var(--red); box-shadow: 0 30px 60px -20px rgba(227, 20, 27, .6); outline: none; }
.hc-ninja { background: linear-gradient(180deg, #121534, #0a0a14); }
.hc-samurai { background: linear-gradient(180deg, #3a1a10, #170c09); }
.hc-img { width: min(170px, 38vw); aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: var(--red); border: 3px solid var(--paper); box-shadow: 0 16px 30px rgba(0, 0, 0, .5); transition: transform .6s var(--ease); }
.hero-card:hover .hc-img { transform: rotate(-4deg) scale(1.05); }
.hc-img img { width: 100%; height: 100%; object-fit: cover; }
.hc-k { position: absolute; right: 14px; top: 8px; font: 900 54px/1 var(--f-jp); color: rgba(243, 230, 207, .08); }
.hero-card b { font: 900 24px var(--f-display); margin-top: 8px; }
.hero-card small { color: var(--muted); font-size: 13.5px; line-height: 1.45; min-height: 3em; }
.hc-time { margin-top: 4px; padding: 5px 12px; border-radius: 30px; background: rgba(243, 230, 207, .08); font-size: 12.5px; font-weight: 700; }

@media (max-width: 860px) {
  .arcade-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .ar-heroes { gap: 10px; }
  .hero-card { padding: 16px 10px; }
  .hero-card small { font-size: 12px; }
  .ar-best { display: none; }
  .ar-title { display: none; }
  .rules.mini { grid-template-columns: 1fr; }
}

/* ---------- touch / phone ---------- */
button, .pick, .gcard, .hero-card, .ar-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.arcade, .game { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: contain; touch-action: none; }
.arcade .ar-screen { touch-action: pan-y; }
#arCanvas, #gameCanvas, #boardCanvas { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (max-width: 560px) {
  .ar-hud { padding: 10px 12px; }
  .ar-time { width: 46vw; }
  .ar-btn { height: 66px; border-radius: 18px; }
  .ar-btn span { font-size: 24px; }
  .hc-img { width: 30vw; }
  .ar-sel h3 { margin-bottom: 14px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .ar-btn { height: 56px; max-width: 96px; }
  .ar-controls { padding-bottom: 8px; }
  .hc-img { width: 90px; }
  .hero-card small { display: none; }
}
@media (max-width: 560px) {
  .ar-hud { gap: 6px; }
  .ar-mid { flex: 1; min-width: 0; }
  .ar-mid > div { gap: 6px; flex-wrap: nowrap; }
  .ar-time { width: auto; flex: 1; min-width: 70px; max-width: 150px; }
  .ar-pill { padding: 5px 9px; font-size: 12.5px; white-space: nowrap; }
  .ar-right { gap: 6px; }
  .ar-right .icon-btn, .arcade .x { width: 38px; height: 38px; }
  .ar-score b { font-size: 26px; }
}
.ar-lives { display: inline-flex; gap: 3px; padding: 4px 9px; border-radius: 30px; background: rgba(10, 7, 7, .7); border: 1px solid var(--line); }
.ar-lives i { font-style: normal; font-size: 15px; color: var(--red2); filter: drop-shadow(0 0 6px rgba(255, 45, 51, .6)); transition: opacity .3s, transform .3s; }
.ar-lives i.lost { opacity: .2; filter: grayscale(1); transform: scale(.8); }

/* Short instructions stay outside the play area. */
.arcade-instruction, .game-instruction {
  position: absolute; z-index: 3; left: 50%; bottom: 22px; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 28px); margin: 0; padding: 9px 16px;
  border: 1px solid rgba(209, 177, 133, .2); border-radius: 30px;
  background: rgba(15, 23, 33, .8); color: #e6d7bd; font: 600 12px/1.5 var(--f-body);
  text-align: center; pointer-events: none; backdrop-filter: blur(8px);
}
.arcade-instruction[hidden] { display: none; }
.arcade[data-game="crush"] .arcade-instruction { top: 72px; bottom: auto; padding: 6px 14px; font-size: 11px; }
.arcade[data-game="crush"] .ar-time { height: 20px; border-color: rgba(209, 177, 133, .3); }
.arcade[data-game="crush"] .ar-time i { background: linear-gradient(90deg, #b98a61, #ebcb84); }
.arcade[data-game="crush"] .ar-time i.low { background: linear-gradient(90deg, #a84448, #ef8276); }
.game .g-hud { background: linear-gradient(rgba(12, 19, 30, .7), transparent); }
@media (pointer: coarse), (max-width: 760px) {
  .arcade[data-game="racer"] .arcade-instruction { bottom: calc(102px + env(safe-area-inset-bottom)); font-size: 10px; padding: 7px 12px; }
  .game-instruction { font-size: 10px; padding: 8px 12px; }
}
@media (max-height: 500px) {
  .arcade-instruction, .game-instruction { display: none; }
}
.gcard-art .arcade-static { position:absolute;inset:0;width:100%;height:100%;object-fit:cover;pointer-events:none; } .gcard-art canvas { position:relative;z-index:1; }
