.diairesi-page .app {
  padding-bottom: calc(24px + var(--safe-bottom));
}

a.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 44px;
}

.brand-link {
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-link:hover h1 {
  color: var(--gold);
}

.diairesi-topbar {
  gap: 10px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.diairesi-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 12px 28px;
  display: grid;
  gap: 12px;
}

.diairesi-hud {
  display: grid;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(7, 26, 20, 0.72);
  border: 1px solid rgba(224, 195, 106, 0.22);
  box-shadow: var(--shadow);
}

.hud-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.hud-stat {
  display: grid;
  gap: 2px;
  text-align: center;
  padding: 8px 6px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.hud-stat span {
  font-size: 11px;
  opacity: 0.72;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hud-stat strong {
  font-family: "EB Garamond", Georgia, serif;
  font-size: 26px;
  color: var(--gold);
  line-height: 1;
}

.hud-stat.is-danger strong {
  color: #ff8a80;
}

.hud-status {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: rgba(243, 234, 215, 0.92);
}

.grid-scroll {
  overflow: auto;
  border-radius: 16px;
  border: 6px solid var(--rail);
  background:
    linear-gradient(180deg, rgba(22, 69, 54, 0.55), rgba(7, 26, 20, 0.9)),
    var(--felt);
  box-shadow: var(--shadow);
  max-height: min(62dvh, 720px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  transition: filter 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  touch-action: pan-x pan-y;
}

.grid-scroll.is-blasting {
  animation: board-shake 0.45s ease;
  filter: saturate(1.3) brightness(1.08);
}

.grid-scroll.is-complete {
  border-color: #57d392;
  box-shadow: 0 0 0 2px rgba(87, 211, 146, 0.35), var(--shadow);
}

.grid-scroll.is-dead {
  border-color: #ff7a6e;
}

@keyframes board-shake {
  0%,
  100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(7px, -4px); }
  60% { transform: translate(-5px, -2px); }
  80% { transform: translate(4px, 3px); }
}

.div-grid {
  border-collapse: separate;
  border-spacing: 3px;
  min-width: 640px;
  width: max-content;
  margin: 6px;
}

.div-grid th,
.div-grid td {
  min-width: 48px;
  height: 42px;
  text-align: center;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.div-grid tbody tr.zebra-a td .cell-btn {
  background: rgba(255, 250, 242, 0.1);
}

.div-grid tbody tr.zebra-b td .cell-btn {
  background: rgba(0, 0, 0, 0.22);
}

.div-grid tbody tr.zebra-a th {
  background: #154336;
}

.div-grid tbody tr.zebra-b th {
  background: #0f2f26;
}

.div-grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #12372c;
  color: var(--gold);
  font-weight: 700;
  font-size: 13px;
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  padding: 0;
}

.div-grid thead th.corner {
  left: 0;
  z-index: 4;
  background: #0c281f;
  color: rgba(243, 234, 215, 0.7);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 6px;
  line-height: 1.15;
}

.div-grid thead th.corner .corner-label {
  display: block;
  font-size: 14px;
  color: var(--gold);
}

.div-grid thead th.corner small {
  display: block;
  font-size: 9px;
  opacity: 0.7;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.rule-btn {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--gold);
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  text-decoration: underline;
  text-decoration-color: rgba(224, 195, 106, 0.35);
  text-underline-offset: 3px;
}

.rule-btn:hover,
.rule-btn:focus-visible {
  background: rgba(224, 195, 106, 0.18);
  outline: none;
}

.rule-btn:active {
  background: rgba(224, 195, 106, 0.28);
  transform: scale(0.96);
}

.explain-modal.is-rule .explain-card {
  background: linear-gradient(180deg, #1a3d52 0%, #0d2433 100%);
  border-color: rgba(120, 190, 230, 0.35);
}

.explain-modal.is-rule .explain-badge {
  background: rgba(120, 190, 230, 0.16);
  color: #9fd4f0;
}

.div-grid tbody th {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #12372c;
  color: var(--cream);
  font-weight: 700;
  font-size: 12px;
  border-radius: 10px;
  padding: 0 6px;
  white-space: nowrap;
  min-width: 88px;
}

.div-grid .cell-btn {
  width: 100%;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid rgba(243, 234, 215, 0.12);
  border-radius: 10px;
  color: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.12s ease, border-color 0.15s ease, color 0.15s ease;
}

.div-grid .cell-btn:hover:not(:disabled) {
  background: rgba(224, 195, 106, 0.22);
  border-color: rgba(224, 195, 106, 0.45);
}

.div-grid .cell-btn:active:not(:disabled) {
  transform: scale(0.96);
  background: rgba(224, 195, 106, 0.28);
}

.div-grid .cell-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.div-grid .cell-btn.is-ok {
  background: rgba(46, 160, 98, 0.45);
  border-color: #57d392;
  color: #e8fff1;
}

.div-grid .cell-btn.is-ok::after {
  content: "✓";
}

.div-grid .cell-btn.is-mine {
  background: rgba(198, 40, 40, 0.55);
  border-color: #ff7a6e;
  color: #ffe8e5;
}

.div-grid .cell-btn.is-mine::after {
  content: "☢";
  font-size: 16px;
}

.div-grid .cell-btn.is-boom-cell {
  animation: cell-boom 0.55s ease;
}

.div-grid .cell-btn:disabled {
  cursor: default;
  transform: none;
}

@keyframes cell-boom {
  0% { transform: scale(1); box-shadow: none; }
  40% { transform: scale(1.25); box-shadow: 0 0 24px rgba(255, 90, 74, 0.7); }
  100% { transform: scale(1); }
}

.diairesi-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.diairesi-actions .gold-btn {
  min-width: min(100%, 220px);
  min-height: 48px;
  width: min(100%, 320px);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  justify-content: center;
  font-size: 13px;
  color: rgba(243, 234, 215, 0.8);
}

.legend i {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: -2px;
  border: 1px solid transparent;
}

.lg-ok {
  background: rgba(46, 160, 98, 0.55);
  border-color: #57d392;
}

.lg-bad {
  background: rgba(198, 40, 40, 0.5);
  border-color: #ff7a6e;
}

.explain-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 12px 12px calc(12px + var(--safe-bottom));
  background: rgba(3, 12, 9, 0.72);
  backdrop-filter: blur(6px);
}

.explain-modal[hidden] {
  display: none;
}

.explain-card {
  width: min(520px, 100%);
  max-height: min(88dvh, 720px);
  overflow: auto;
  padding: 18px 16px 14px;
  border-radius: 18px 18px 14px 14px;
  background: linear-gradient(180deg, #1a4738 0%, #0d2a21 100%);
  border: 1px solid rgba(224, 195, 106, 0.35);
  box-shadow: var(--shadow);
  animation: modal-pop 0.28s ease;
  overscroll-behavior: contain;
}

.explain-modal.is-wrong .explain-card {
  background: linear-gradient(180deg, #4a1d1d 0%, #2a1010 100%);
  border-color: rgba(255, 122, 110, 0.45);
}

@keyframes modal-pop {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.explain-badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(224, 195, 106, 0.18);
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.explain-modal.is-wrong .explain-badge {
  background: rgba(255, 122, 110, 0.18);
  color: #ffb4ab;
}

.explain-card h2 {
  font-size: clamp(22px, 5vw, 28px);
  margin-bottom: 10px;
  color: var(--cream);
  word-break: break-word;
}

.explain-body {
  font-size: 15px;
  line-height: 1.5;
  color: rgba(243, 234, 215, 0.95);
}

.explain-body p {
  margin: 0 0 12px;
}

.explain-body ul {
  margin: 0 0 12px;
  padding-left: 1.2em;
}

.explain-body li {
  margin-bottom: 6px;
}

.explain-lead {
  font-size: 16px;
}

.explain-gameover {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 90, 74, 0.18);
  border: 1px solid rgba(255, 122, 110, 0.4);
  color: #ffb4ab;
  text-align: center;
  letter-spacing: 0.02em;
}

.explain-tip {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(224, 195, 106, 0.12);
  border: 1px solid rgba(224, 195, 106, 0.22);
  color: var(--gold);
}

.explain-modal.is-wrong .explain-tip {
  background: rgba(255, 122, 110, 0.12);
  border-color: rgba(255, 122, 110, 0.25);
  color: #ffc7c0;
}

.explain-timer {
  margin: 0 0 10px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  color: #ffb4ab;
}

.explain-card .primary-btn {
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
  position: sticky;
  bottom: 0;
}

.explain-card .primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.boom-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.boom-overlay[hidden] {
  display: none;
}

.boom-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 90, 74, 0.55), transparent 55%);
  opacity: 0;
}

.boom-overlay.is-on .boom-flash {
  animation: flash-boom 0.7s ease;
}

.boom-icon {
  position: relative;
  z-index: 1;
  font-size: clamp(64px, 18vw, 84px);
  line-height: 1;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.55));
  opacity: 0;
  transform: scale(0.4);
}

.boom-overlay.is-on .boom-icon {
  animation: icon-boom 0.85s ease forwards;
}

.boom-text {
  position: relative;
  z-index: 1;
  margin: 8px 0 0;
  font-family: "EB Garamond", Georgia, serif;
  font-size: clamp(28px, 10vw, 42px);
  font-weight: 700;
  color: #ffb4ab;
  letter-spacing: 0.08em;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.65);
  opacity: 0;
}

.boom-overlay.is-on .boom-text {
  animation: text-boom 0.85s ease forwards;
}

@keyframes flash-boom {
  0% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes icon-boom {
  0% { opacity: 0; transform: scale(0.3) rotate(-12deg); }
  35% { opacity: 1; transform: scale(1.2) rotate(6deg); }
  100% { opacity: 0.15; transform: scale(1) rotate(0); }
}

@keyframes text-boom {
  0% { opacity: 0; transform: translateY(10px); }
  40% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; }
}

@media (min-width: 761px) {
  .explain-modal {
    place-items: center;
    padding: 20px;
  }

  .explain-card {
    border-radius: 18px;
    padding: 22px 22px 18px;
  }

  .diairesi-hud {
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .hud-stats {
    min-width: 280px;
  }

  .hud-stat {
    text-align: left;
    background: transparent;
    padding: 0;
  }
}

@media (max-width: 760px) {
  .diairesi-topbar {
    flex-wrap: wrap;
    padding-left: 12px;
    padding-right: 12px;
  }

  .diairesi-topbar .brand h1 {
    font-size: 22px;
  }

  .diairesi-topbar .brand p {
    font-size: 12px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .ghost-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
  }

  /* Χωρίς εσωτερικό scroll: ο πίνακας χωράει στο πλάτος */
  .grid-scroll {
    overflow: visible;
    max-height: none;
    border-width: 4px;
    margin-inline: 0;
    touch-action: manipulation;
  }

  .div-grid {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-spacing: 2px;
    margin: 4px 0;
  }

  .div-grid th,
  .div-grid td {
    min-width: 0;
    width: auto;
    height: auto;
    padding: 0;
  }

  .div-grid thead th {
    position: static;
    font-size: 10px;
    border-radius: 6px;
  }

  .div-grid thead th.corner {
    position: static;
    font-size: 9px;
    padding: 2px;
  }

  .div-grid thead th.corner small {
    display: none;
  }

  .div-grid tbody th {
    position: static;
    min-width: 0;
    width: 16%;
    font-size: 9px;
    padding: 0 2px;
    border-radius: 6px;
    line-height: 1.1;
  }

  .rule-btn {
    min-height: 34px;
    font-size: 10px;
    border-radius: 6px;
    padding: 2px 0;
    text-decoration: none;
  }

  .div-grid .cell-btn {
    min-width: 0;
    min-height: 34px;
    border-radius: 6px;
  }

  .div-grid .cell-btn.is-mine::after,
  .div-grid .cell-btn.is-ok::after {
    font-size: 12px;
  }

  .help-panel .help-card {
    margin: 12px;
    max-height: calc(100dvh - 24px);
    overflow: auto;
  }
}

@media (max-width: 420px) {
  .hud-stat strong {
    font-size: 22px;
  }

  .hud-status {
    font-size: 13px;
  }
}
