* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05060f;
  color: #fff;
  font-family: 'Roboto', system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(3, 4, 12, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10;
}
.overlay.clear { background: rgba(3, 4, 12, 0.2); backdrop-filter: none; -webkit-backdrop-filter: none; }
.overlay.show { display: flex; animation: fade .35s ease; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: 100%;
  max-width: 600px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 28px 28px 22px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(20, 24, 52, 0.92), rgba(10, 10, 26, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 1px rgba(45, 226, 255, 0.15), 0 20px 60px rgba(0, 0, 0, 0.6),
              -20px 0 60px -30px rgba(45, 226, 255, 0.6), 20px 0 60px -30px rgba(255, 45, 149, 0.6);
  text-align: center;
  touch-action: pan-y;
}
.small-panel { max-width: 340px; }

h1, h2 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  letter-spacing: 2px;
}
h1 {
  font-size: clamp(1.9rem, 6vw, 2.9rem);
  color: #2de2ff;
  text-shadow: 0 0 18px rgba(45, 226, 255, 0.7);
}
h1 span { color: #ff2d95; text-shadow: 0 0 18px rgba(255, 45, 149, 0.7); }
h2 { font-size: 1.8rem; margin-bottom: 14px; }

.tag { color: rgba(255, 255, 255, 0.72); margin: 10px 0 16px; line-height: 1.45; }

.rules {
  list-style: none;
  text-align: left;
  font-size: 0.92rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.85);
  margin: 0 0 18px;
  display: grid;
  gap: 6px;
}
.rules li {
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid rgba(45, 226, 255, 0.6);
}
.rules li:nth-child(even) { border-left-color: rgba(255, 45, 149, 0.6); }
.rules b { color: #fff; }

.opt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 16px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.8);
}

.options {
  margin: 0 0 16px;
  padding: 14px 12px 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.options h3 { font: 700 0.8rem 'Orbitron', sans-serif; letter-spacing: 3px; color: rgba(255, 255, 255, 0.55); margin-bottom: 12px; }
.options .opt { justify-content: space-between; margin-bottom: 10px; padding: 0 6px; }
.hint { font-size: 0.8rem; color: rgba(255, 255, 255, 0.55); margin: 2px 0 6px; min-height: 1em; }

.seg { display: inline-flex; border-radius: 12px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.2); }
.seg button {
  background: transparent;
  color: #fff;
  border: 0;
  padding: 9px 16px;
  font: 700 0.9rem 'Orbitron', sans-serif;
  cursor: pointer;
}
.seg button + button { border-left: 1px solid rgba(255, 255, 255, 0.2); }
.seg button.on { background: linear-gradient(135deg, #2de2ff, #8a2dff); }

.btn {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font: 700 1.05rem 'Orbitron', sans-serif;
  letter-spacing: 1px;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  border: 0;
  font-size: 1.3rem;
  padding: 18px;
  background: linear-gradient(135deg, #2de2ff 0%, #8a2dff 50%, #ff2d95 100%);
  box-shadow: 0 6px 28px rgba(138, 45, 255, 0.5);
}
.btn.small { font-size: 0.78rem; padding: 10px 8px; margin: 0; }

.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin-top: 10px; }
.row.two { grid-template-columns: 1fr 1fr; }
.btn.off { opacity: 0.5; }

.keys { margin-top: 14px; font-size: 0.74rem; color: rgba(255, 255, 255, 0.45); line-height: 1.5; }

/* ---------- tema Storico 1800 ---------- */
body.hist .overlay { background: rgba(40, 28, 12, 0.45); }
body.hist .overlay.clear { background: rgba(40, 28, 12, 0.15); }
body.hist .panel {
  background: linear-gradient(160deg, #f3e6c4, #e2cf9f);
  color: #3b2a17;
  border: 3px solid #6b4423;
  box-shadow: 0 0 0 4px #e2cf9f, 0 0 0 7px #6b4423, 0 20px 60px rgba(0, 0, 0, 0.5);
}
body.hist h1, body.hist h2, body.hist .options h3, body.hist .opt { font-family: 'Rye', Georgia, serif; }
body.hist h1 { color: #2f5fb3; text-shadow: 2px 2px 0 #3b2a17; }
body.hist h1 span { color: #c4302b; text-shadow: 2px 2px 0 #3b2a17; }
body.hist .tag, body.hist .rules, body.hist .hint, body.hist .keys, body.hist .opt, body.hist .options h3 { color: #3b2a17; }
body.hist .rules li { background: rgba(107, 68, 35, 0.08); border-left-color: #2f5fb3; }
body.hist .rules li:nth-child(even) { border-left-color: #c4302b; }
body.hist .rules b { color: #1f160b; }
body.hist .options { background: rgba(107, 68, 35, 0.08); border-color: rgba(107, 68, 35, 0.3); }
body.hist .seg { border-color: #6b4423; }
body.hist .seg button { color: #3b2a17; font-family: 'Rye', Georgia, serif; }
body.hist .seg button + button { border-left-color: #6b4423; }
body.hist .seg button.on { background: linear-gradient(135deg, #2f5fb3, #c4302b); color: #fff; }
body.hist .btn { font-family: 'Rye', Georgia, serif; color: #3b2a17; border-color: #6b4423; background: rgba(107, 68, 35, 0.1); }
body.hist .btn.primary { color: #fff; background: linear-gradient(135deg, #2f5fb3, #6b4423 50%, #c4302b); box-shadow: 0 6px 20px rgba(60, 30, 10, 0.4); }
