/* PC double-click operation guide — desktop only (hidden ≤767px) */
.pc-guide-toggle,
.pc-guide {
  display: none !important;
}

@media (min-width: 768px) {
  /* Match PC action bar weighted grid (last col = Guide) */
  body.is-playing.play .game-shell:has(#battle-table:not([hidden])) .player-rail .game-actions {
    grid-template-columns:
      minmax(132px, 1.35fr)
      minmax(124px, 1.2fr)
      minmax(124px, 1.2fr)
      minmax(88px, 0.82fr)
      minmax(112px, 1.05fr)
      70px !important;
    max-width: 960px !important;
    column-gap: 12px !important;
  }

  body.is-playing .pc-guide-toggle:not([hidden]) {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 3px;
    grid-column: 6;
    width: 70px !important;
    min-width: 70px !important;
    max-width: 70px !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    margin: 0 !important;
    padding: 0 4px !important;
    border-radius: 12px;
    border: 2px solid #fbbf24;
    background: linear-gradient(180deg, rgba(18, 90, 64, .98), rgba(4, 48, 36, .99));
    color: #fef3c7;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
    line-height: 1;
    cursor: pointer;
    box-shadow:
      0 0 0 2px rgba(251, 191, 36, .22),
      0 4px 12px rgba(0, 0, 0, .35);
    overflow: hidden;
    white-space: nowrap;
    z-index: 2;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
  }
  body.is-playing .pc-guide-toggle .pc-guide-ico {
    font-size: 1.05rem;
    line-height: 1;
    color: #fde68a;
  }
  body.is-playing .pc-guide-toggle .pc-guide-txt {
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .03em;
  }
  body.is-playing .pc-guide-toggle:not([hidden]):hover {
    border-color: #fcd34d;
    transform: translateY(-1px);
    box-shadow:
      0 0 0 2px rgba(251, 191, 36, .35),
      0 6px 14px rgba(0, 0, 0, .4);
  }
  body.is-playing .pc-guide-toggle[aria-expanded="true"] {
    border-color: #fcd34d;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, .4), 0 6px 14px rgba(0, 0, 0, .35);
  }

  /* Fixed popover above action bar, right-aligned */
  body.is-playing .pc-guide:not([hidden]) {
    display: block !important;
    position: fixed !important;
    right: 12px;
    left: auto;
    bottom: auto;
    z-index: 120;
    width: min(400px, calc(100vw - 20px));
    max-width: 400px;
    pointer-events: none;
  }

  .pc-guide-panel {
    pointer-events: auto;
    border-radius: 12px;
    border: 1.5px solid rgba(251, 191, 36, .5);
    background:
      radial-gradient(ellipse at 20% 0%, rgba(251, 191, 36, .08), transparent 45%),
      linear-gradient(165deg, rgba(10, 74, 54, .98), rgba(3, 40, 28, .98));
    box-shadow:
      0 14px 28px rgba(0, 0, 0, .45),
      inset 0 1px 0 rgba(255, 236, 180, .18);
    color: #f7f3e8;
    overflow: hidden;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .24s ease, transform .24s ease;
    max-height: min(42vh, 300px);
  }
  .pc-guide.is-open .pc-guide-panel {
    opacity: 1 !important;
    transform: translateY(0) !important;
  }

  .pc-guide-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px 6px;
    border-bottom: 1px solid rgba(251, 191, 36, .22);
  }
  .pc-guide-head h3 {
    margin: 0;
    font-size: .84rem;
    font-weight: 800;
    letter-spacing: .04em;
    color: #fde68a;
  }
  .pc-guide-close {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    border: 1px solid rgba(251, 191, 36, .35);
    background: rgba(0, 0, 0, .25);
    color: #f7f3e8;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
  }
  .pc-guide-close:hover {
    border-color: #fbbf24;
    color: #fff;
  }

  .pc-guide-body {
    padding: 8px 10px 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    align-items: stretch;
  }
  .pc-guide-step {
    margin: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  .pc-guide-label {
    margin: 0 0 2px;
    font-size: .72rem;
    font-weight: 700;
    color: #fff;
    min-height: 2.1em;
    line-height: 1.25;
  }
  .pc-guide-desc {
    margin: 0 0 6px;
    font-size: .66rem;
    line-height: 1.35;
    color: rgba(245, 250, 247, .78);
    min-height: 2.7em;
  }
  .pc-guide-note {
    grid-column: 1 / -1;
    margin: 0;
    font-size: .62rem;
    color: rgba(253, 230, 138, .75);
    text-align: center;
  }

  .pc-guide-demo {
    margin-top: auto;
    border-radius: 8px;
    border: 1px solid rgba(251, 191, 36, .22);
    background: linear-gradient(165deg, rgba(12, 90, 56, .85), rgba(4, 40, 28, .9));
    padding: 6px;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
  }
  .pg-stage {
    position: relative;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
  }

  .pg-pile {
    position: relative;
    z-index: 1;
    width: 28px;
    height: 40px;
    border-radius: 5px;
  }
  .pg-back,
  .pg-open {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 5px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, .35);
  }
  .pg-back {
    border: 1.5px solid rgba(212, 175, 55, .85);
    background: #0c2a4a url("../images/card-back-india.webp?v=2") center / cover no-repeat;
  }
  .pg-open {
    border: 1.5px dashed rgba(251, 191, 36, .4);
    background: rgba(4, 24, 16, .35);
  }
  .pg-hand-slot {
    width: 28px;
    height: 40px;
    border-radius: 5px;
    border: 1px dashed rgba(255, 255, 255, .18);
  }
  .pg-card,
  .pg-fly {
    width: 28px;
    height: 40px;
    border-radius: 5px;
    border: 1.5px solid rgba(201, 162, 39, .65);
    background: linear-gradient(180deg, #fff, #faf6ee);
    color: #9f1239;
    font-size: .58rem;
    font-weight: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.05;
    box-shadow: 0 3px 8px rgba(0, 0, 0, .3);
  }
  .pg-hand-card { position: relative; z-index: 1; }

  .pg-cursor {
    position: absolute;
    z-index: 5;
    width: 10px;
    height: 14px;
    left: 34%;
    top: 42%;
    background: #f8fafc;
    clip-path: polygon(0 0, 0 100%, 35% 72%, 55% 100%, 65% 94%, 42% 64%, 100% 64%);
    box-shadow: 1px 2px 4px rgba(0, 0, 0, .5);
    opacity: 0;
    pointer-events: none;
  }

  .pg-ripple {
    position: absolute;
    z-index: 4;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid rgba(251, 191, 36, .85);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(.4);
  }

  .pg-fly {
    position: absolute;
    z-index: 3;
    left: 50%;
    top: 50%;
    margin-left: -14px;
    margin-top: -20px;
    opacity: 0;
    pointer-events: none;
  }

  .pc-guide.is-open .demo-draw .pg-cursor {
    animation: pgCursorDraw 3.4s ease-in-out infinite;
  }
  .pc-guide.is-open .demo-draw .pg-ripple.r1 {
    left: 38%;
    top: 52%;
    animation: pgRipple 3.4s ease-in-out infinite;
  }
  .pc-guide.is-open .demo-draw .pg-ripple.r2 {
    left: 38%;
    top: 52%;
    animation: pgRipple 3.4s ease-in-out infinite .2s;
  }
  .pc-guide.is-open .demo-draw .pg-stock {
    animation: pgGlow 3.4s ease-in-out infinite;
  }
  .pc-guide.is-open .demo-draw .pg-fly-draw {
    background: #0c2a4a url("../images/card-back-india.webp?v=2") center / cover no-repeat;
    border-color: rgba(212, 175, 55, .85);
    animation: pgFlyDraw 3.4s ease-in-out infinite;
  }

  .pc-guide.is-open .demo-discard .pg-cursor {
    left: 32%;
    animation: pgCursorDiscard 3.4s ease-in-out infinite;
  }
  .pc-guide.is-open .demo-discard .pg-ripple.r1 {
    left: 34%;
    top: 52%;
    animation: pgRipple 3.4s ease-in-out infinite;
  }
  .pc-guide.is-open .demo-discard .pg-ripple.r2 {
    left: 34%;
    top: 52%;
    animation: pgRipple 3.4s ease-in-out infinite .2s;
  }
  .pc-guide.is-open .demo-discard .pg-hand-card {
    animation: pgCardSelect 3.4s ease-in-out infinite;
  }
  .pc-guide.is-open .demo-discard .pg-fly-discard {
    animation: pgFlyDiscard 3.4s ease-in-out infinite;
  }

  @keyframes pgCursorDraw {
    0% { opacity: 0; transform: translate(-22px, -12px); }
    12% { opacity: 1; transform: translate(0, 0); }
    28% { opacity: 1; transform: translate(0, 0) scale(.92); }
    34% { opacity: 1; transform: translate(0, 0); }
    42% { opacity: 1; transform: translate(0, 0) scale(.92); }
    50% { opacity: 1; transform: translate(0, 0); }
    78% { opacity: .85; transform: translate(30px, 3px); }
    90%, 100% { opacity: 0; transform: translate(36px, 6px); }
  }
  @keyframes pgCursorDiscard {
    0% { opacity: 0; transform: translate(-18px, -12px); }
    12% { opacity: 1; transform: translate(0, 0); }
    28% { opacity: 1; transform: translate(0, 0) scale(.92); }
    34% { opacity: 1; transform: translate(0, 0); }
    42% { opacity: 1; transform: translate(0, 0) scale(.92); }
    50% { opacity: 1; transform: translate(0, 0); }
    78% { opacity: .85; transform: translate(32px, 2px); }
    90%, 100% { opacity: 0; transform: translate(38px, 5px); }
  }
  @keyframes pgRipple {
    0%, 24% { opacity: 0; transform: translate(-50%, -50%) scale(.35); }
    28% { opacity: .95; transform: translate(-50%, -50%) scale(.55); }
    40% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(.35); }
  }
  @keyframes pgGlow {
    0%, 40% { box-shadow: none; }
    48%, 62% { box-shadow: 0 0 0 2px rgba(251, 191, 36, .45), 0 0 12px rgba(251, 191, 36, .35); }
    78%, 100% { box-shadow: none; }
  }
  @keyframes pgCardSelect {
    0%, 40% {
      transform: translateY(0) scale(1);
      box-shadow: 0 3px 8px rgba(0, 0, 0, .3);
      border-color: rgba(201, 162, 39, .65);
    }
    48%, 62% {
      transform: translateY(-2px) scale(1.04);
      box-shadow: 0 0 0 2px rgba(251, 191, 36, .45), 0 6px 12px rgba(0, 0, 0, .35);
      border-color: #fbbf24;
    }
    72%, 100% {
      transform: translateY(0) scale(1);
      box-shadow: 0 3px 8px rgba(0, 0, 0, .3);
      border-color: rgba(201, 162, 39, .65);
      opacity: 1;
    }
  }
  @keyframes pgFlyDraw {
    0%, 48% { opacity: 0; transform: translate(-20px, 0) scale(.92); }
    55% { opacity: 1; transform: translate(-20px, 0) scale(1); }
    78% { opacity: 1; transform: translate(20px, 3px) scale(1); }
    90%, 100% { opacity: 0; transform: translate(26px, 6px) scale(.94); }
  }
  @keyframes pgFlyDiscard {
    0%, 48% { opacity: 0; transform: translate(-20px, 0) scale(1); }
    55% { opacity: 1; transform: translate(-20px, -3px) scale(1.04); }
    78% { opacity: 1; transform: translate(20px, 0) scale(1); }
    90%, 100% { opacity: 0; transform: translate(26px, 4px) scale(.94); }
  }

  @media (max-width: 1100px) {
    body.is-playing .pc-guide:not([hidden]) {
      width: min(360px, calc(100vw - 20px));
      max-width: 360px;
    }
    .pc-guide-panel { max-height: min(36vh, 260px); }
    .pg-stage { height: 56px; }
  }

  @media (prefers-reduced-motion: reduce) {
    .pc-guide-panel { transition: none; }
    .pc-guide.is-open .demo-draw .pg-cursor,
    .pc-guide.is-open .demo-draw .pg-ripple,
    .pc-guide.is-open .demo-draw .pg-stock,
    .pc-guide.is-open .demo-draw .pg-fly-draw,
    .pc-guide.is-open .demo-discard .pg-cursor,
    .pc-guide.is-open .demo-discard .pg-ripple,
    .pc-guide.is-open .demo-discard .pg-hand-card,
    .pc-guide.is-open .demo-discard .pg-fly-discard {
      animation: none !important;
    }
  }
}
