/* ============================================================
   Tileborne Rush — game styles.
   Reuses the shell theme variables (--g-bg, --g-bg2, --g-card,
   --g-accent*, --g-heading, --g-shadow-lg, --g-accent-edge/-soft/-hi).
   The tile BODY (ivory) is painted here; shared/tiles.js only draws
   the pips/glyphs onto a transparent <svg> inside .tl.
   ============================================================ */

/* Beat the shell's ".mj-stage > * { max-width:760px }" so the arena
   can fill the whole play area instead of a narrow column. */
.mj-game .mj-stage > .mr-game { max-width: none; }

.mr-game {
  position: relative;
  align-self: stretch;   /* override .mj-stage's align-items:center so we fill its height */
  width: 100%;
  height: 100%;          /* fill .mj-stage (flex row) vertically */
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mr-arena {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Felt-table look: accent glow up top, dark vignette below, theme bg2 base. */
  background:
    radial-gradient(120% 80% at 50% -12%, var(--g-accent-soft), transparent 58%),
    radial-gradient(150% 120% at 50% 122%, rgba(0,0,0,.22), transparent 55%),
    var(--g-bg2, var(--g-bg));
  box-shadow: inset 0 0 0 2px var(--g-accent-edge), inset 0 0 70px rgba(0,0,0,.26);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
/* faint felt weave */
.mr-arena::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 15px 15px;
  opacity: .5;
}

.mr-tiles { position: absolute; inset: 0; will-change: transform; }

/* ---- a real mahjong tile, flying ---- */
.mr-tile {
  position: absolute;
  top: 0; left: 0;
  width: var(--mr-tile, 56px);
  aspect-ratio: 58 / 79;
  background: linear-gradient(158deg, #FCF7EC 0%, #F0E6CF 58%, #E2D4B2 100%);
  border: 1px solid rgba(120,95,55,.35);
  border-radius: 7px;
  box-shadow: 0 3px 6px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.85);
  cursor: pointer;
  will-change: transform, opacity;
  transform: translate(-300px, -300px);
}
.mr-tile .tl { position: relative; width: 100%; height: 100%; display: block; background: none; border: 0; box-shadow: none; }
.mr-tile .tl svg { width: 100%; height: 100%; display: block; }
.mr-tile .tl .cnr {
  position: absolute; top: 2px; left: 4px; z-index: 3;
  font: 600 11px/1 Georgia, 'Times New Roman', serif;
  color: #9A7B3F;
}
.mr-tile.is-sel {
  outline: 3px solid var(--g-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--g-accent-soft), 0 8px 16px rgba(0,0,0,.45);
  z-index: 4;
}

.mr-fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.mr-frenzy {
  position: absolute; top: 33%; left: 50%;
  transform: translate(-50%, -50%);
  font: 800 54px/1 var(--serif, 'Cormorant Garamond', Georgia, serif);
  color: var(--g-accent-lt);
  text-shadow: 0 0 30px var(--g-accent);
  letter-spacing: 6px;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}
.mr-frenzy.show { animation: mr-frenzy 1.4s ease-out; }
@keyframes mr-frenzy {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(.4) rotate(-8deg); }
  30%  { opacity: 1; transform: translate(-50%,-50%) scale(1.15) rotate(3deg); }
  60%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1.5); }
}

.mr-hud {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 7;
  display: flex; gap: 18px;
  padding: 8px 22px; border-radius: 30px;
  background: rgba(0,0,0,.30);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--g-accent-edge);
}
.mr-stat { display: flex; flex-direction: column; align-items: center; min-width: 42px; }
.mr-stat .k {
  font: 600 10px/1 var(--sans, 'Inter', system-ui, sans-serif);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--g-accent-lt); opacity: .9;
}
.mr-stat .v {
  font: 700 18px/1 var(--sans, 'Inter', system-ui, sans-serif);
  color: #fff; margin-top: 3px; text-shadow: 0 1px 3px rgba(0,0,0,.55);
}
.mr-stat .v.combo { color: var(--g-accent-lt); }
.mr-stat .v.frenzy { color: #FF7AD9; animation: mr-pulse .4s infinite alternate; }
@keyframes mr-pulse { from { opacity: .6; } to { opacity: 1; } }

.mr-pause { position: absolute; top: 12px; right: 14px; z-index: 7; }

/* ---- start / game-over overlay ---- */
.mr-overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.5);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.mr-overlay[hidden] { display: none; }
.mr-card {
  width: min(460px, 88%);
  padding: 26px 28px; border-radius: 22px; text-align: center;
  background: linear-gradient(180deg, var(--g-card), var(--g-bg));
  border: 1px solid var(--g-accent-hi);
  box-shadow: var(--g-shadow-lg), 0 0 0 6px var(--g-accent-soft);
}
.mr-card h1 { font: 700 34px/1 var(--serif, 'Cormorant Garamond', Georgia, serif); color: var(--g-heading); letter-spacing: -.01em; }
.mr-card h1.gameover { color: #C0392B; }
.mr-sub { margin: 10px 0 14px; color: var(--g-heading); opacity: .85; font-size: 15px; line-height: 1.55; }
.mr-howto {
  text-align: left; font-size: 13px; line-height: 1.7;
  color: var(--g-heading); opacity: .92;
  border: 1px solid var(--g-accent-edge); border-radius: 12px;
  padding: 12px 16px; background: rgba(255,255,255,.04);
}
.mr-howto b { color: var(--g-accent-dk); }
.mr-stats { display: flex; gap: 28px; justify-content: center; margin: 6px 0 4px; }
.mr-stats .item .num { font: 700 30px/1 var(--serif, Georgia, serif); color: var(--g-heading); }
.mr-stats .item .lbl { font-size: 12px; color: var(--g-heading); opacity: .7; margin-top: 2px; }
.mr-card .mj-btn { font-size: 16px; padding: 11px 34px; margin-top: 14px; }

/* ---- help sheet ---- */
.mr-help {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.5);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.mr-help[hidden] { display: none; }
.mr-help-card {
  position: relative;
  width: min(540px, 92%); max-height: 88%; overflow: auto;
  padding: 24px 26px; border-radius: 20px;
  background: linear-gradient(180deg, var(--g-card), var(--g-bg));
  border: 1px solid var(--g-accent-hi);
  box-shadow: var(--g-shadow-lg);
}
.mr-help-card h2 { font: 700 26px/1.1 var(--serif, Georgia, serif); color: var(--g-heading); margin-bottom: 10px; }
.mr-help-card h3 { font: 700 15px/1.2 var(--sans, system-ui, sans-serif); color: var(--g-accent-dk); margin: 14px 0 4px; }
.mr-help-card p { font-size: 13.5px; line-height: 1.65; color: var(--g-heading); opacity: .92; margin: 6px 0; }
.mr-help-card p.mr-help-lead { opacity: 1; }
.mr-help-card .close { margin-top: 16px; }
.mr-help-note { font-size: 12px; opacity: .7; margin-top: 14px; border-top: 1px solid var(--g-accent-edge); padding-top: 10px; }
.mr-help-x {
  position: absolute; top: 12px; right: 14px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--g-accent-edge); background: var(--g-card);
  color: var(--g-heading); font-size: 20px; line-height: 1; cursor: pointer;
}
.mr-help-x:hover { border-color: var(--g-accent); color: var(--g-accent); }

/* small screens: tighten the HUD and tile cap */
@media (max-width: 520px) {
  .mr-hud { gap: 12px; padding: 6px 14px; }
  .mr-stat { min-width: 34px; }
  .mr-stat .v { font-size: 16px; }
  .mr-card { padding: 20px 18px; }
  .mr-frenzy { font-size: 40px; }
}
