.cell.called.highlight {
  background: linear-gradient(180deg, #22c55e, #16a34a);
  border-color: #fff200;
  box-shadow: 0 0 0 4px rgba(255, 242, 0, 0.5), 0 0 16px 2px #fff200;
  animation: pulse-border 1s infinite;
  z-index: 10;
}
@keyframes pulse-border {
  0% {
    box-shadow: 0 0 0 4px rgba(255, 242, 0, 0.5), 0 0 16px 2px #fff200;
    border-color: #fff200;
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 242, 0, 0.2), 0 0 24px 4px #fff200;
    border-color: #facc15;
  }
  100% {
    box-shadow: 0 0 0 4px rgba(255, 242, 0, 0.5), 0 0 16px 2px #fff200;
    border-color: #fff200;
  }
}
body.dark-theme .cell.called.highlight {
  background: linear-gradient(180deg, #22c55e, #166534);
  border-color: #fff200;
  box-shadow: 0 0 0 4px rgba(255, 242, 0, 0.5), 0 0 16px 2px #fff200;
  animation: pulse-border 1s infinite;
}
body.dark-theme button.menu-btn {
  background: linear-gradient(180deg, #23232a, #18181b);
  color: #f3f4f6;
  border-color: #27272a;
}
body.dark-theme button.menu-btn:hover {
  border-color: #22c55e;
}
body.dark-theme button.menu-btn-icon img {
  filter: invert(1) brightness(1.2);
}
body.dark-theme .display .value {
  color: #f3f4f6;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}
body.dark-theme .cell {
  background: linear-gradient(180deg, #23232a, #18181b);
  color: #f3f4f6;
  border-color: #27272a;
}
body.dark-theme .cell.called {
  background: linear-gradient(180deg, #166534, #065f46);
  color: #ffffff;
  border-color: #22c55e;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.2),
    0 0 0 2px rgba(34, 197, 94, 0.25);
}
body.dark-theme .previous-list {
  background: #23232a;
  border-radius: 8px;
}
body.dark-theme .previous-item {
  border-bottom: 1px solid #27272a;
}
/* Tema scuro */
body.dark-theme {
  --bg: #18181b;
  --panel: #23232a;
  --panel-2: #1e1e23;
  --text: #f3f4f6;
  --muted: #a1a1aa;
  --accent: #22c55e;
  --accent-2: #16a34a;
  --danger: #ef4444;
  --border: #27272a;
  background: radial-gradient(
      1200px 800px at 10% -10%,
      #23232a 0%,
      #18181b 40%,
      #18181b 100%
    ),
    var(--bg);
  color: var(--text);
}
:root {
  --bg: #f7fafc;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #22c55e;
  --accent-2: #16a34a;
  --danger: #ef4444;
  --border: #e5e7eb;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: radial-gradient(
      1200px 800px at 10% -10%,
      #ffffff 0%,
      #eef2ff 40%,
      #f8fafc 100%
    ),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
    Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  height: 100svh;
}

@supports (height: 100dvh) {
  body {
    min-height: 100dvh;
    height: 100dvh;
  }
}

/* Header (menu) */
header {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0)
  );
  backdrop-filter: blur(6px);
  color: var(--text);
}
.menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  width: 100%;
}
.menu h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.5px;
  color: var(--text);
}
.menu-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
button.menu-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #f5f7fb);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease,
    border-color 120ms ease;
}
button.menu-btn:hover {
  transform: translateY(-1px);
  border-color: #cbd5e1;
}
button.menu-btn-icon {
  padding: 0px 8px;
  align-items: center;
}
button.menu-btn-icon img {
  width: 15px;
  margin-top: 4px;
}

main.app {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 12px;
  display: grid;
  gap: 12px;
}

/* Status panel and board containers */
.status-panel {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 12px;
}
.board-wrapper {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.01), rgba(0, 0, 0, 0));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Number displays and action button */
/* .displays {
  display: contents;
} */
.display {
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: 10px;
  padding: 12px;
  gap: 4px;
}
.display .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.display .value {
  font-size: clamp(24px, 6vw, 40px);
  font-weight: 800;
  line-height: 1.1;
  color: #111827;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  display: grid;
  align-items: center;
  justify-items: center;
  text-align: center;
}

.display .value img.estrazione-gif {
  width: 50%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Dissolvenza per la gif del numero estratto */
.fade-in {
  opacity: 0;
  animation: fadeIn 0.6s forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.display .smorfia-napoletano {
  font-size: 0.6em;
  color: var(--accent-2);
  font-style: italic;
}
.previous-list {
  max-height: 180px;
  overflow-y: auto;
  background: #f8fafc;
  border-radius: 8px;
  padding: 4px 0;
  font-size: 1.1em;
  min-height: 2em;
}
.previous-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  padding: 2px 8px;
  border-bottom: 1px solid #e5e7eb;
}
.previous-item-details {
  display: flex;
  flex-direction: column;
}
.previous-item:last-child {
  border-bottom: none;
}
.previous-empty {
  color: #bbb;
  text-align: center;
  padding: 8px 0;
}

.actions {
  display: contents; /* overridden per orientation */
}
button#extractBtn {
  width: 100%;
  border: 1px solid #14532d;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: white;
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 120ms ease, transform 120ms ease, opacity 120ms ease;
}
button#extractBtn:hover {
  filter: brightness(1.05);
}
button#extractBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

/* Assign prize button */
button#assignPrizeBtn {
  width: 100%;
  border: 1px solid #581c87;
  background: linear-gradient(180deg, #a855f7, #7c3aed);
  color: white;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 120ms ease, transform 120ms ease, opacity 120ms ease;
}
button#assignPrizeBtn:hover { filter: brightness(1.05); }
button#assignPrizeBtn:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.3); }

/* Prize text in previous list */
.prize-badge {
  font-size: 0.6em;
  color: #a855f7;
  font-style: italic;
}

/* Board grid */
.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) 10px repeat(
      5,
      minmax(0, 1fr)
    );
  grid-auto-rows: 1fr 1fr 1fr 10px 1fr 1fr 1fr 10px 1fr 1fr 1fr;
  gap: 3px;
  flex: 1;
  min-height: 0;
  height: 100%;
}
.cell {
  position: relative;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #f3f4f6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  color: #1f2937;
  font-weight: 700;
  user-select: none;
  transition: transform 120ms ease, background 120ms ease,
    border-color 120ms ease, box-shadow 120ms ease;
}
.cell.called {
  background: linear-gradient(180deg, #166534, #065f46);
  color: #ffffff;
  border-color: #16a34a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2),
    0 0 0 2px rgba(34, 197, 94, 0.25);
}
.empty {
  width: 10px;
  height: 10px;
}

/* Orientation-specific layout */
/* Portrait: status (c | d | b) on top, board below */
@media (orientation: portrait) {
  .display .value img.estrazione-gif {
    max-height: 50px;
    width: auto;
  }
}

/* Landscape: board 80%, side panel 20% with b, c, d stacked */
@media (orientation: landscape) {
  main.app {
    grid-template-columns: 8fr 2fr;
    grid-template-rows: 1fr;
    gap: 12px;
  }
  .board-wrapper {
    grid-column: 1;
    grid-row: 1;
  }
  .status-panel {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-rows: auto auto auto 1fr;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 12px;
  }
}

/* Footer helper (optional) */
footer {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 8px 0;
}
