/* History game: a road through time with cards (CSS3D) + details and quiz windows. */
body.game.history {
  background:
    radial-gradient(900px 600px at 55% 35%, rgba(120, 90, 220, 0.25), transparent 65%),
    radial-gradient(700px 500px at 85% 0%, rgba(255, 170, 90, 0.12), transparent 60%),
    linear-gradient(180deg, #141433, #07081a);
}

/* 3D layer with the cards */
.world3d { position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.world3d * { pointer-events: none; }
.world3d .tl-card, .world3d .tl-gate, .world3d .tl-start { pointer-events: auto; }

.tl-card {
  /* no overflow:hidden here: in a 3D scene it stops the card from receiving clicks */
  width: 480px; border-radius: 34px; cursor: pointer;
  background: linear-gradient(180deg, #1e224a, #10122c);
  border: 3px solid color-mix(in srgb, var(--c) 55%, transparent);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .5), 0 0 40px color-mix(in srgb, var(--c) 25%, transparent);
  transition: box-shadow .3s, border-color .3s, opacity .25s;
  font-family: var(--font); color: var(--text);
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.tl-card.current { border-color: var(--c); box-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 0 70px color-mix(in srgb, var(--c) 55%, transparent); }
.tl-card:hover { border-color: var(--c); }
.tl-card .tl-img { height: 300px; background: #0a0c1e; border-radius: 31px 31px 0 0; }
.tl-card .tl-img img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 31px 31px 0 0; }
.tl-card .tl-date {
  margin: 22px 28px 0; display: inline-block; padding: 6px 18px; border-radius: 999px;
  font-size: 24px; font-weight: 900; color: #1a1430; background: var(--c);
}
.tl-card .tl-title { padding: 14px 28px 30px; font-size: 34px; font-weight: 900; line-height: 1.15; }

.tl-gate {
  width: 560px; text-align: center; padding: 30px 34px 34px; border-radius: 40px; cursor: pointer;
  font-family: var(--font); color: var(--text);
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--c) 35%, transparent), transparent 70%), #0e1028;
  border: 4px solid var(--c);
  box-shadow: 0 0 90px color-mix(in srgb, var(--c) 45%, transparent), inset 0 0 40px color-mix(in srgb, var(--c) 15%, transparent);
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.tl-gate .g-icon { font-size: 70px; line-height: 1; }
.tl-gate .g-name { font-size: 56px; font-weight: 900; margin: 8px 0 6px; color: var(--c); text-shadow: 0 2px 12px #000a; }
.tl-gate .g-open { display: flex; gap: 16px; align-items: center; text-align: left; margin: 14px 0 6px; padding: 12px; border-radius: 22px; background: rgba(255, 255, 255, .07); }
.tl-gate .g-open img { width: 120px; height: 90px; object-fit: cover; border-radius: 14px; flex: none; }
.tl-gate .g-open b { display: block; font-size: 26px; line-height: 1.15; }
.tl-gate .g-open span { font-size: 22px; font-weight: 800; color: var(--c); }
.tl-gate .g-intro { font-size: 23px; font-weight: 600; line-height: 1.4; color: #d6dbff; margin-top: 10px; }

.tl-start { width: 620px; text-align: center; font-family: var(--font); color: var(--text); }
.tl-start .s-flag { font-size: 110px; line-height: 1.1; filter: drop-shadow(0 10px 30px #0008); }
.tl-start .s-name {
  font-size: 70px; font-weight: 900; line-height: 1.05;
  background: linear-gradient(90deg, #c4ceff, #ffb8d6, #ffe09a); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tl-start .s-go { margin-top: 18px; font-size: 28px; font-weight: 800; color: var(--text-dim); }
.tl-start .s-go b { display: inline-block; animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(-8px); } }

/* Left panel */
.history-panel { width: 230px; max-height: calc(100dvh - 200px); overflow-y: auto; }
.history-panel h2 { margin-bottom: 6px; }
.periods-h { margin-top: 12px; }
.track-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.track-btn {
  font: inherit; font-size: .72rem; font-weight: 800; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px;
  background: rgba(255, 255, 255, .05); border: 2px solid transparent; line-height: 1.1; text-align: center;
}
.track-btn .f { font-size: 1.6rem; }
.track-btn.active { border-color: #c9a8ff; background: rgba(201, 168, 255, .15); }
.track-btn:hover { background: rgba(255, 255, 255, .1); }
.period-list { display: flex; flex-direction: column; gap: 4px; }
.period-btn {
  font: inherit; font-weight: 800; font-size: .92rem; color: var(--text); cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 12px;
  background: rgba(255, 255, 255, .04); border: 2px solid transparent;
}
.period-btn .ic { width: 26px; text-align: center; font-size: 1.1rem; }
.period-btn.active { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }
.period-btn:hover { background: rgba(255, 255, 255, .09); }

/* Bottom navigation */
.nav-bar {
  display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--panel-border); backdrop-filter: blur(14px);
}
.nav-arrow { width: 46px; height: 46px; font-size: 1.1rem; color: var(--text); }
.nav-now { display: flex; align-items: center; gap: 8px; min-width: 220px; justify-content: center; font-weight: 900; }
.nav-now .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c, #fff); box-shadow: 0 0 10px var(--c, #fff); }
.nav-date { color: var(--text-dim); font-weight: 800; }

/* Windows (details, quiz) */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(5, 6, 20, .6); backdrop-filter: blur(6px); animation: fadein .2s ease-out; }
.modal[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } }
.modal-card {
  position: relative; width: min(880px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  border-radius: 28px; background: linear-gradient(180deg, #1d2150, #12153a); border: 1px solid var(--panel-border);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: pop .25s ease-out;
}
.modal-close { position: absolute; top: 12px; right: 12px; z-index: 2; width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer; font-size: 1.1rem; color: #fff; background: rgba(0, 0, 0, .45); }
.detail-card { display: grid; grid-template-columns: 1.1fr 1fr; }
.detail-img { background: #090b1c; min-height: 320px; }
.detail-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-img.none { display: none; }
.detail-card.no-img { grid-template-columns: 1fr; }
.detail-body { padding: 26px 28px; display: flex; flex-direction: column; gap: 10px; }
.detail-period { align-self: flex-start; padding: 4px 12px; border-radius: 999px; font-weight: 900; font-size: .85rem; color: #1a1430; background: var(--c); }
.detail-date { font-weight: 900; font-size: 1.2rem; color: var(--c); }
.detail-title { margin: 0; font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.15; }
.detail-text { margin: 0; font-size: 1.12rem; line-height: 1.55; color: #dfe3ff; font-weight: 600; flex: 1; }
.detail-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.credit { font-size: .72rem; color: var(--text-dim); text-decoration: none; opacity: .8; }
.credit:hover { text-decoration: underline; }

.quiz-card { padding: 22px 24px 24px; }
.quiz-tabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding-right: 50px; }
.quiz-tabs .chip.active { background: linear-gradient(135deg, #ffb86b, #ff7eb3); color: #2a1030; }
.quiz-tabs .quiz-score { margin-left: auto; }
.q-text { margin: 18px 0 14px; font-size: clamp(1.2rem, 2.6vw, 1.6rem); text-align: center; }
.q-body { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.q-event { display: flex; gap: 16px; align-items: center; padding: 10px; border-radius: 20px; background: rgba(255, 255, 255, .06); max-width: 620px; width: 100%; }
.q-event img { width: 180px; height: 130px; object-fit: cover; border-radius: 14px; flex: none; }
.q-event b { font-size: 1.3rem; line-height: 1.2; }
.q-options { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; width: 100%; }
.q-opt {
  font: inherit; font-weight: 900; font-size: 1.05rem; color: var(--text); cursor: pointer;
  padding: 12px 18px; border-radius: 16px; border: 2px solid color-mix(in srgb, var(--c, #8ea6ff) 60%, transparent);
  background: color-mix(in srgb, var(--c, #8ea6ff) 14%, transparent); transition: transform .12s, background .2s;
}
.q-opt:hover { transform: translateY(-2px); }
.q-opt.good { background: rgba(126, 226, 184, .35); border-color: var(--green); }
.q-opt.bad { background: rgba(255, 120, 120, .3); border-color: #ff8a8a; animation: shake .4s; }
.q-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
.q-card {
  position: relative; font: inherit; color: var(--text); cursor: pointer; text-align: left; padding: 0; overflow: hidden;
  border-radius: 18px; border: 3px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .06);
}
.q-card img { width: 100%; height: 130px; object-fit: cover; display: block; }
.q-card b { display: block; padding: 10px 12px 12px; font-size: 1rem; line-height: 1.2; }
.q-card .q-date { display: block; padding: 0 12px 10px; font-weight: 900; color: var(--yellow); }
.q-card .q-num {
  position: absolute; top: 8px; left: 8px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.3rem; font-weight: 900; color: #1a1430; background: var(--yellow); box-shadow: 0 4px 12px #0008;
}
.q-card.good { border-color: var(--green); }
.q-card.bad { border-color: #ff8a8a; }
#qNext[hidden] { display: none; }
.q-foot { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; min-height: 48px; }
.q-feedback { font-size: 1.2rem; font-weight: 900; text-align: center; }
.q-feedback.good { color: var(--green); }
.q-feedback.bad { color: #ffb3a8; }

@media (max-width: 860px) {
  .history-panel { width: auto; max-height: none; overflow: visible; }
  .history-panel h2 { display: none; }
  .track-list { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .track-btn { min-width: 54px; font-size: .62rem; }
  .track-btn .f { font-size: 1.3rem; }
  .period-list { flex-direction: row; overflow-x: auto; margin-top: 6px; }
  .period-btn { flex: none; font-size: .78rem; padding: 5px 8px; }
  .bottom-ui { bottom: 168px; }
  .nav-now { min-width: 0; font-size: .85rem; }
  .nav-arrow { width: 40px; height: 40px; }
  .detail-card { grid-template-columns: 1fr; }
  .detail-img { min-height: 0; height: 220px; }
  .q-event { flex-direction: column; text-align: center; }
  .q-event img { width: 100%; height: 160px; }
  .q-cards { grid-template-columns: 1fr; }
  .q-card { display: flex; align-items: center; }
  .q-card img { width: 110px; height: 80px; flex: none; }
}
@media (min-width: 861px) and (max-height: 780px) {
  .history-panel { top: 76px; transform: none; max-height: calc(100dvh - 180px); }
}
