/* Mobile Board — Dedicated layout (<=768px)
   Uses .mb-* classes that don't conflict with desktop board.css */

/* ── Board Container ── */
.mb-board {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 60px);
  min-height: calc(100dvh - 60px);
  background: #1a3a2a;
  overflow: hidden;
}

/* Hide the desktop board wrapper chrome on mobile */
@media (max-width: 768px) {
  .mj-board-wrapper {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    z-index: 100;
  }
  .mj-board-center {
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    display: block !important;
    align-items: unset !important;
    justify-content: unset !important;
  }
  .game-container.mj-board {
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
    display: block !important;
  }
  #game-board {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
  }
  .topbar { display: none !important; }
  .game-top-bar-slot { display: none !important; }
  .game-actions { display: none !important; }
  .mj-lower-ui { display: none !important; }
  .mj-game-controls { display: none !important; }
  .mj-size-warning { display: none !important; }
  .yaku-paths-box { display: none !important; }
  .mj-mini-tile-box { display: none !important; }
}

/* ── Opponent Strip ── */
.mb-strip {
  position: absolute; top: 0; left: 0; right: 0; height: 46px;
  background: rgba(15, 23, 41, 0.92);
  display: flex; align-items: center; justify-content: space-evenly;
  z-index: 10; border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 6px;
}
.mb-opp {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 3px 10px; border-radius: 6px;
  background: rgba(40, 40, 70, 0.6); font-size: 0.55rem;
}
.mb-opp .mb-wind { color: #7ba3d4; font-weight: 700; }
.mb-opp .mb-name { color: #aaa; max-width: 48px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-opp .mb-score { font-size: 0.55rem; color: #ddd; font-weight: 600; font-variant-numeric: tabular-nums; }
.mb-opp .mb-dots { display: flex; gap: 1px; margin-top: 1px; }
.mb-dot { width: 5px; height: 8px; background: #2d5a3d; border: 0.5px solid #4a8a60; border-radius: 1px; }
.mb-dot--empty { opacity: 0.2; }
.mb-opp--active { background: rgba(74, 111, 165, 0.25); box-shadow: 0 0 8px rgba(74, 111, 165, 0.3); }

/* ── Status Strip ── */
.mb-status {
  position: absolute; top: 46px; left: 0; right: 0; height: 26px;
  background: rgba(15, 23, 41, 0.88);
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px; z-index: 10;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.mb-round-badge {
  font-size: 0.5rem; font-weight: 700; color: #fff;
  background: rgba(76, 175, 80, 0.5); padding: 1px 8px;
  border-radius: 10px; white-space: nowrap;
}
.mb-tag {
  font-size: 0.48rem; font-weight: 600; padding: 1px 6px;
  border-radius: 8px; white-space: nowrap;
}
.mb-tag--tenpai { background: rgba(100, 200, 100, 0.2); color: #6c6; }
.mb-tag--shanten { background: rgba(200, 170, 100, 0.12); color: #ca8; }
.mb-tag--furiten { background: rgba(220, 60, 60, 0.2); color: #e66; }
.mb-tag--riichi { background: rgba(74, 111, 165, 0.2); color: #7ba3d4; }
/* Speed button */
.mb-speed {
  margin-left: 4px;
  width: 20px; height: 20px; min-width: 0; min-height: 0;
  padding: 0; border-radius: 50%;
  font-size: 0.4rem; font-weight: 700; line-height: 1;
  background: rgba(74, 111, 165, 0.2); color: #7ba3d4;
  border: 1px solid rgba(74, 111, 165, 0.3);
  cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
  -webkit-appearance: none; appearance: none;
  flex-shrink: 0;
}

.mb-eval {
  margin-left: auto; width: 60px; height: 8px;
  background: rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden;
  position: relative;
}
.mb-eval__fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #c43, #e93, #4c4, #4cc);
  transition: width 0.3s ease;
}
.mb-eval__label {
  position: absolute; right: 2px; top: 0; font-size: 0.35rem;
  color: rgba(255,255,255,0.7); line-height: 8px;
}

/* ── Edge Glows ── */
.mb-glow {
  position: absolute; width: 4px; height: 200px; z-index: 8;
  top: 78px;
}
.mb-glow--left {
  left: 0;
  background: linear-gradient(to right, rgba(74, 111, 165, 0.5), transparent);
  border-radius: 0 3px 3px 0;
}
.mb-glow--right {
  right: 0;
  background: linear-gradient(to left, rgba(74, 111, 165, 0.5), transparent);
  border-radius: 3px 0 0 3px;
}
.mb-glow-label {
  position: absolute; z-index: 9; font-size: 0.7rem;
  color: rgba(123, 163, 212, 0.8); font-weight: 700;
  writing-mode: vertical-lr; letter-spacing: 2px;
}
.mb-glow-label--left { left: 5px; top: 155px; }
.mb-glow-label--right { right: 5px; top: 155px; transform: rotate(180deg); }

/* ── Discard Columns ── */
.mb-disc {
  position: absolute;
  display: flex; flex-direction: column; gap: 2px;
  z-index: 4; align-items: center;
  max-height: 280px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.mb-disc--north { top: 78px; left: 50%; transform: translateX(-50%); max-height: 220px; }
.mb-disc--south { bottom: 120px; left: 50%; transform: translateX(-50%); max-height: 220px; }
.mb-disc--west { left: 14px; top: 82px; }
.mb-disc--east { right: 14px; top: 82px; }

.mb-disc .mj-tile {
  width: 22px; height: 30px; border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ── Center Info ── */
.mb-center {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 41, 0.9);
  border: 1px solid rgba(74, 111, 165, 0.5);
  border-radius: 10px; padding: 8px 14px;
  text-align: center; z-index: 5;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.mb-center__wind { font-size: 1.3rem; color: #7ba3d4; font-weight: 700; }
.mb-center__round { font-size: 0.55rem; color: #888; }
.mb-center__wall { font-size: 0.5rem; color: #666; margin-top: 2px; }
.mb-center__scores {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px 10px; margin-top: 4px; font-size: 0.5rem; color: #aaa;
}
.mb-center__scores .mb-active { color: #7ba3d4; font-weight: 600; }

/* ── Dora + Waits Panel ── */
.mb-dora {
  position: absolute; bottom: 124px; right: 10px;
  background: rgba(15, 23, 41, 0.92);
  border-radius: 8px; padding: 4px 6px; z-index: 6;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex; flex-direction: column; gap: 3px;
}
.mb-dora__label {
  font-size: 0.38rem; color: rgba(123, 163, 212, 0.6);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.mb-dora__label--waits { color: rgba(100, 200, 100, 0.7); }
.mb-dora__tiles { display: flex; gap: 2px; flex-wrap: wrap; max-width: 120px; }
.mb-dora__tiles .mj-tile {
  width: 20px; height: 28px; border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.mb-dora__divider {
  width: 100%; height: 1px;
  background: rgba(123, 163, 212, 0.15);
}

/* ── Player Hand ── */
.mb-hand {
  position: absolute; bottom: 60px; left: 0; right: 0;
  display: flex; gap: 1px; z-index: 10;
  padding: 0 1px 6px;
  justify-content: center;
}
.mb-hand .mj-tile {
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.mb-hand .mj-tile:active {
  transform: translateY(-4px);
}
.mb-hand .mb-drawn {
  margin-left: 3px;
  box-shadow: 0 0 8px rgba(100, 200, 100, 0.5), 0 2px 4px rgba(0,0,0,0.25);
}

/* ── Action Bar ── */
.mb-actions {
  position: absolute; bottom: 14px; left: 0; right: 0; height: 36px;
  background: rgba(15, 23, 41, 0.95);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: center;
  gap: 5px; padding: 0 8px; z-index: 20;
  overflow: hidden;
}
.mb-turn {
  font-size: 0.6rem; font-weight: 600; color: #7ba3d4;
  white-space: nowrap;
}
.mb-btn {
  padding: 4px 10px; border-radius: 14px; font-size: 0.55rem;
  font-weight: 600; border: 1px solid #555; background: #2a2a4a;
  color: #ccc; cursor: pointer; white-space: nowrap;
  line-height: 1; max-height: 28px;
}
.mb-btn--primary { background: #4a6fa5; border-color: #5a8fd5; color: #fff; }
.mb-btn--call {
  background: #3a5a3a; border-color: #5a9a5a; color: #8c8;
  animation: mb-call-pulse 1.2s ease-in-out infinite;
}
.mb-btn--pass { background: #3a3a3a; border-color: #555; color: #888; }
.mb-btn--sensei { box-shadow: 0 0 6px rgba(74, 111, 165, 0.4); }

@keyframes mb-call-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(100, 200, 100, 0.3); }
  50% { box-shadow: 0 0 14px rgba(100, 200, 100, 0.6); }
}
@media (prefers-reduced-motion: reduce) {
  .mb-btn--call { animation: none; }
}
.mb-btn--util {
  width: 22px; height: 22px; padding: 0; border-radius: 50%;
  min-width: 0; min-height: 0;
  font-size: 0.5rem; display: inline-flex;
  align-items: center; justify-content: center;
  background: rgba(74, 111, 165, 0.15); border: 1px solid rgba(74, 111, 165, 0.3);
  color: #7ba3d4; flex-shrink: 0;
}
.mb-btn--util:first-of-type { margin-left: auto; }

/* ── Nav Spacer ── */
.mb-nav-spacer { height: 14px; }

/* ── Retractable Nav ── */
.mobile-nav--retracted {
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.mobile-nav--retracted.mobile-nav {
  pointer-events: none;
}
/* Re-show on toggle */
.mobile-nav:not(.mobile-nav--retracted) {
  transform: translateY(0);
  transition: transform 0.25s ease;
  pointer-events: auto;
}

/* Pull tab — left side, slim */
.mb-nav-tab {
  position: fixed;
  bottom: 0;
  left: 4px;
  min-width: 0;
  min-height: 0;
  width: 10px !important;
  height: 28px !important;
  background: rgba(15, 23, 41, 0.85);
  border: 1px solid rgba(74, 111, 165, 0.3);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  z-index: 201;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}
.mb-nav-tab__line {
  display: block;
  width: 3px;
  height: 14px;
  background: rgba(123, 163, 212, 0.5);
  border-radius: 2px;
}
.mb-nav-tab--open {
  bottom: 60px;
}
.mb-nav-tab--open .mb-nav-tab__line {
  background: rgba(123, 163, 212, 0.8);
}

/* ── Tile Zoom Overlay ── */
.mb-tile-zoom {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; z-index: 100;
}
.mb-tile-zoom .mj-tile {
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(74, 111, 165, 0.2);
}
.mb-tile-zoom__label {
  font-size: 0.85rem; font-weight: 600; color: #ddd;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.mb-tile-zoom__info {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
}
.mb-tile-zoom__tag {
  font-size: 0.55rem; font-weight: 600; padding: 2px 8px;
  border-radius: 10px;
}
.mb-tile-zoom__tag--best {
  background: rgba(74, 111, 165, 0.3); color: #7ba3d4;
  border: 1px solid rgba(74, 111, 165, 0.4);
}
.mb-tile-zoom__tag--danger {
  background: rgba(220, 60, 60, 0.25); color: #e66;
  border: 1px solid rgba(220, 60, 60, 0.3);
}
.mb-tile-zoom__discard {
  margin-top: 4px;
  padding: 10px 32px; border-radius: 20px;
  background: #4a6fa5; color: #fff;
  font-size: 0.8rem; font-weight: 600;
  border: none; cursor: pointer;
  box-shadow: 0 2px 8px rgba(74, 111, 165, 0.4);
}
.mb-tile-zoom__cancel {
  padding: 6px 20px; border-radius: 16px;
  background: transparent; color: #888;
  font-size: 0.65rem; font-weight: 500;
  border: 1px solid #555; cursor: pointer;
}
.mb-selected {
  outline: 2px solid #7ba3d4;
  outline-offset: -1px;
  border-radius: 4px;
}

/* ── Sensei Badges on hand tiles ── */
.mb-sensei-wrap { position: relative; display: inline-flex; }
.mb-badge {
  position: absolute; font-size: 7px; z-index: 2;
  font-weight: 700; line-height: 1;
}
.mb-badge--best { top: -3px; right: -1px; color: #7ba3d4; text-shadow: 0 0 3px rgba(74,111,165,0.6); }
.mb-badge--danger { top: -3px; left: 0; color: #e55; text-shadow: 0 0 2px rgba(200,50,50,0.4); }
.mb-badge--uke { bottom: -5px; left: 50%; transform: translateX(-50%); font-size: 6px; color: #ccc; background: rgba(0,0,0,0.5); padding: 0 2px; border-radius: 3px; }

/* ── Popups (full-screen on mobile) ── */
@media (max-width: 768px) {
  .yaku-popup, .help-popup {
    position: fixed !important; inset: 0 !important;
    width: 100% !important; max-width: 100vw !important;
    border-radius: 0 !important; z-index: 1000 !important;
    padding: 16px !important; overflow-y: auto;
  }
}

/* ── Chi Panel (full-width on mobile) ── */
@media (max-width: 768px) {
  .mj-chi-panel {
    position: fixed !important;
    bottom: 96px !important; left: 0 !important; right: 0 !important;
    top: auto !important; width: 100% !important;
    background: rgba(10, 20, 30, 0.95) !important;
    border-radius: 12px 12px 0 0 !important;
    padding: 12px 16px 8px !important; z-index: 25;
  }
}

/* ── Yaku Paths Drawer ── */
.mb-yaku-drawer {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100vh;
  height: 100dvh;
  background: rgba(10, 18, 28, 0.98);
  z-index: 200;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: transform 0.25s ease;
  padding: 12px 10px 60px;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
}
.mb-yaku-drawer--open {
  transform: translateX(280px);
}
.mb-yaku-drawer__close {
  position: sticky;
  top: 0;
  float: right;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(123, 163, 212, 0.3);
  background: rgba(15, 23, 41, 0.9);
  color: #7ba3d4;
  font-size: 0.75rem;
  cursor: pointer;
  z-index: 201;
  margin-bottom: 4px;
}
.mb-yaku-drawer .yaku-paths,
.mb-yaku-drawer #yaku-paths-box {
  display: block !important;
  position: static !important;
  width: 100% !important;
  max-height: none !important;
  left: auto !important;
  top: auto !important;
  font-size: 0.8rem;
  background: transparent !important;
  box-shadow: none !important;
}

/* Backdrop overlay */
.mb-yaku-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 199;
}
.mb-yaku-drawer--open ~ .mb-yaku-backdrop {
  display: block;
}

/* Tab button on left edge */
.mb-yaku-tab {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 41, 0.9);
  border: 1px solid rgba(74, 111, 165, 0.4);
  border-left: none;
  border-radius: 0 8px 8px 0;
  padding: 10px 6px;
  color: #7ba3d4;
  font-size: 0.6rem;
  cursor: pointer;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  writing-mode: vertical-lr;
  letter-spacing: 1px;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
}
.mb-yaku-tab span {
  font-size: 0.45rem;
  font-weight: 600;
}

/* ── Sensei Settings Drawer (right side) ── */
.mb-sensei-drawer {
  position: fixed;
  top: 0;
  right: -260px;
  width: 260px;
  height: 100vh;
  height: 100dvh;
  background: rgba(10, 18, 28, 0.98);
  z-index: 200;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: transform 0.25s ease;
  padding: 12px 14px 60px;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
}
.mb-sensei-drawer--open {
  transform: translateX(-260px);
}
.mb-sensei-drawer__title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #7ba3d4;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(74, 111, 165, 0.2);
}
.mb-sensei-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.65rem;
  color: #ccc;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.mb-sensei-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #4a6fa5;
  flex-shrink: 0;
}
.mb-sensei-toggle span {
  flex: 1;
}

/* Backdrop */
.mb-sensei-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 199;
}
.mb-sensei-drawer--open ~ .mb-sensei-backdrop {
  display: block;
}

/* Tab on left edge, below Yaku */
.mb-sensei-tab {
  position: absolute;
  left: 0;
  top: calc(50% + 50px);
  transform: translateY(-50%);
  background: rgba(15, 23, 41, 0.9);
  border: 1px solid rgba(74, 111, 165, 0.4);
  border-left: none;
  border-radius: 0 8px 8px 0;
  padding: 10px 6px;
  color: #7ba3d4;
  font-size: 0.6rem;
  cursor: pointer;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  writing-mode: vertical-lr;
  letter-spacing: 1px;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
}
.mb-sensei-tab span {
  font-size: 0.45rem;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .mb-hand .mj-tile { transition: none; }
  .mb-eval__fill { transition: none; }
  .mb-sensei-drawer { transition: none; }
  .mb-yaku-drawer { transition: none; }
}
