/* Air Hockey Solitaire - styles */
:root{
  --bg: #0b0f14;
  --panel: #101826;
  --felt: #0e2a3a;
  --felt2:#0c2432;
  --text: #f5f7fb;
  --muted: rgba(245,247,251,.72);
  --line: rgba(255,255,255,.12);
  --shadow: 0 12px 30px rgba(0,0,0,.45);
  --radius: 16px;

  --cardW: 92px;
  --cardH: 128px;
  --gap: 12px;
  --stackOffset: 26px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: radial-gradient(1200px 800px at 30% 10%, #12243a, var(--bg));
  color: var(--text);
  overflow:hidden;
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 14px 14px 10px;
  background: rgba(8,14,24,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* Row 1: title */
.titleRow{
  display: flex;
  align-items: center;
  gap: 14px;
}

.appLogo{
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
}

.titleText{
  min-width: 0;
}

.appTitle{
  font-size: 34px;
  font-weight: 800;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appSub{
  margin-top: 4px;
  font-size: 18px;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Row 2: tools */
.toolsRow{
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;          /* key: wrap instead of squeeze */
  align-items: center;
}

.pill{
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-weight: 600;
}

/* Lo fi mobile adjustments */
@media (max-width: 760px){
  .appLogo{ width: 54px; height: 54px; }
  .appTitle{ font-size: 26px; }
  .appSub{ font-size: 16px; }

  .toolsRow .pill,
  .toolsRow button.pill{
    min-height: 44px;
  }

  /* Optional: force buttons to two columns on phone */
  #undoBtn, #autoBtn, #newGameBtn, #settingsBtn{
    flex: 1 1 calc(50% - 10px);
    text-align: center;
  }
}
.brand{
  display:flex;
  align-items:center;
  gap:12px;
}

.logo-btn{
  background:none;
  border:none;
  padding:0;
  cursor:pointer;
  display:flex;
  align-items:center;
}

.logo-btn img{
  width:75px;
  height:75px;
  border-radius:8px;
}

.brand-text{
  display:flex;
  flex-direction:column;
}

.brand .title{
  font-weight: 800;
  letter-spacing: .3px;
  font-size: 18px;
}
.brand .subtitle{
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.hud{
  display:flex;
  gap: 10px;
  align-items:center;
}
.timer{
  min-width: 88px;
  text-align:center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0,0,0,.18);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.btn{
  appearance:none;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(0,0,0,.15);
  padding: 9px 12px;
  border-radius: 999px;
  cursor:pointer;
  font-weight: 700;
}
.btn:hover{ background: rgba(255,255,255,.08); }
.btn.primary{
  background: rgba(255,255,255,.12);
}

.table{
  height: calc(100% - 60px);
  padding: 14px;
}

.row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: var(--gap);
}

.row.top{
  margin-bottom: 14px;
}

.pile-group{
  display:flex;
  gap: var(--gap);
  align-items:flex-start;
}

.pile-wrap{
  display:flex;
  flex-direction:column;
  gap: 6px;
}

.pile-label{
  font-size: 12px;
  color: var(--muted);
  padding-left: 6px;
}

.pile{
  width: var(--cardW);
  height: var(--cardH);
  border-radius: 14px;
  border: 1px dashed rgba(255,255,255,.22);
  background: linear-gradient(180deg, rgba(14,42,58,.55), rgba(12,36,50,.55));
  position: relative;
  user-select:none;
  touch-action:none;
}

.tableau{
  display:grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--gap);
}

.tableau-col{
  position: relative;
  min-height: calc(var(--cardH) + 6 * var(--stackOffset) + 12px);
  border-radius: var(--radius);
  padding: 0;
}

.tableau-col .pile{
  width: 100%;
  height: 100%;
  min-height: calc(var(--cardH) + 6 * var(--stackOffset) + 12px);
  border: 1px solid rgba(255,255,255,.10);
  background: linear-gradient(180deg, rgba(14,42,58,.35), rgba(12,36,50,.25));
}

.card{
  position:absolute;
  width: var(--cardW);
  height: var(--cardH);
  border-radius: 14px;
  overflow:hidden;
  box-shadow: 0 10px 22px rgba(0,0,0,.35);
  transform: translate3d(0,0,0);
  cursor: grab;
}
.card:active{ cursor: grabbing; }

.card img{
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
}

.card.faceDown{
  filter: saturate(1.05) contrast(1.05);
}

.card.ghost{
  opacity:.85;
  pointer-events:none;
}

.drag-layer{
  position: fixed;
  left:0; top:0;
  width:1px; height:1px;
  pointer-events:none;
  z-index: 9999;
}

.drag-stack{
  position:absolute;
  will-change: transform;
}

.hint{
  outline: 2px solid rgba(255,255,255,.28);
  outline-offset: 2px;
}

.overlay{
  position: fixed;
  inset:0;
  display:grid;
  place-items:center;
  background: rgba(0,0,0,.48);
  z-index: 10000;
}
.hidden {
  display: none !important;
  pointer-events: none !important;
}

.share-card{
  background:#0f1620;
  border-radius:14px;
  padding:20px;
  max-width:320px;
  width:90%;
  text-align:center;
  box-shadow:0 20px 60px rgba(0,0,0,.5);
}

.share-title{
  font-size:1.1em;
  margin-bottom:12px;
}

.share-qr{
  width:200px;
  height:200px;
  margin:12px auto;
  display:block;
}

.share-url{
  font-size:.85em;
  opacity:.8;
  margin-bottom:12px;
  word-break:break-all;
}

.share-actions{
  display:flex;
  flex-direction:column;
  gap:8px;
}

#confettiCanvas{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
}

.win-card{
  position:relative;
  z-index:2;
  width: min(420px, calc(100% - 36px));
  border-radius: 22px;
  background: rgba(16,24,38,.92);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: var(--shadow);
  padding: 18px 16px 16px;
  text-align:center;
}
.win-title{
  font-size: 26px;
  font-weight: 900;
  letter-spacing:.2px;
}
.win-sub{
  margin-top: 6px;
  color: var(--muted);
}
.win-actions{
  margin-top: 14px;
  display:flex;
  justify-content:center;
}

@media (max-width: 820px){
  :root{ --cardW: 78px; --cardH: 108px; --stackOffset: 22px; }
  .table{ overflow:auto; height: calc(100% - 60px); }
  body{ overflow:auto; }
}
@media (max-width: 520px){
  :root{ --cardW: 64px; --cardH: 92px; --stackOffset: 20px; --gap: 10px; }
  .brand .subtitle{ display:none; }
}

.tableauPile{ position:relative; }

.moves{
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0,0,0,.18);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--muted);
}

.settings{
  position: fixed;
  inset:0;
  display:grid;
  place-items:center;
  background: rgba(0,0,0,.45);
  z-index: 10001;
}
.settings-card{
  width: min(420px, calc(100% - 32px));
  background: rgba(16,24,38,.96);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.14);
  padding: 16px;
}
.settings-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.settings-title{
  font-weight:900;
}
.settings-block{
  margin-top:12px;
}
.settings-label{
  font-size:12px;
  color: var(--muted);
  margin-bottom:6px;
}
.settings-help{
  font-size:12px;
  color: rgba(245,247,251,.6);
  margin-top:6px;
}
.select{
  width:100%;
  padding:10px;
  border-radius:12px;
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.18);
  color: var(--text);
}

.check{
  display:flex;
  align-items:center;
  gap:10px;
  margin:6px 0;
  font-size:14px;
}
.check input{
  transform: scale(1.15);
}
/* ---- Must-fix: prevent rightmost foundation cutoff on small phones ---- */

/* Allow flex children to shrink instead of forcing overflow */
.row,
.pile-group,
.pile-wrap{
  min-width: 0;
}

/* Make sure the top row doesn't push content offscreen */
.row.top{
  flex-wrap: nowrap;
}

/* On narrow screens, lay foundations out as a tight 4-col grid */
@media (max-width: 520px){
  .row.top{
    align-items: flex-start;
  }

  /* Left side (stock/waste) stays flex, right side becomes grid */
  .pile-group.right{
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;              /* tighter than var(--gap) */
    justify-items: center; /* centers piles in their cells */
  }

  /* Keep pile widths from forcing overflow */
  .pile-group.right .pile{
    width: var(--cardW);
    max-width: 100%;
  }

  /* Slightly tighten overall spacing for this breakpoint */
  :root{
    --gap: 8px;
  }
}

/* Extra tiny phones */
@media (max-width: 360px){
  :root{
    --cardW: 58px;
    --cardH: 84px;
    --gap: 6px;
  }

  .pile-group.right{
    gap: 4px;
  }
}
