:root {
  --bg-page: #FFF4E6;
  --bg-panel: #FFFFFF;
  --text-main: #1A1A2E;
  --accent-primary: #E94560;
  --accent-secondary: #0F3460;
  --accent-tertiary: #16213E;
  --accent-highlight: #F9A03F;
  --border: #D8E0EC;
  --space-unit: 8px;
  --font-body: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --font-mono: "Courier New", Courier, monospace;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

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

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-weight: normal;
  line-height: 1.2;
  color: var(--text-main);
}

h1 { font-size: 42px; margin-bottom: calc(var(--space-unit) * 3); }
h2 { font-size: 30px; margin-bottom: calc(var(--space-unit) * 2); margin-top: calc(var(--space-unit) * 5); }
h3 { font-size: 24px; margin-bottom: calc(var(--space-unit) * 2); margin-top: calc(var(--space-unit) * 4); }

p {
  margin-bottom: calc(var(--space-unit) * 2.5);
  max-width: 72ch;
}

a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 150ms ease, color 150ms ease;
}

a:hover, a:focus {
  text-decoration-color: var(--accent-highlight);
  color: var(--accent-secondary);
}

ul, ol {
  margin-bottom: calc(var(--space-unit) * 2.5);
  padding-left: calc(var(--space-unit) * 3);
  max-width: 72ch;
}

li {
  margin-bottom: calc(var(--space-unit) * 1);
}

.site-container, .layout-wrapper {
  display: grid;
  grid-template-columns: 224px 940px;
  gap: 32px;
  max-width: 1196px;
  margin: 0 auto;
  padding: 40px 0;
}

.masthead {
  grid-column: 1 / -1;
  height: auto;
  min-height: 92px;
  border-bottom: 4px solid var(--accent-highlight);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40px;
  background: linear-gradient(135deg, var(--accent-secondary), var(--accent-tertiary));
  color: #fff;
  padding: 16px 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.masthead-title {
  font-size: 24px;
  font-weight: bold;
  text-decoration: none;
  color: #fff;
}
.masthead-title:hover {
  color: var(--accent-highlight);
}

.site-title {
  font-size: 24px;
  font-weight: bold;
  color: #fff;
}

.masthead-inner {
  display: flex;
  justify-content: space-between;
  width: 100%;
  align-items: center;
}

.latest-draw {
  color: #fff;
}

.masthead-newest {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 15px;
}

.nav-rail, .sidebar {
  background-color: var(--bg-panel);
  padding: 24px;
  border: none;
  border-top: 4px solid var(--accent-primary);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  align-self: start;
  position: sticky;
  top: 40px;
}

.nav-rail h2, .sidebar h2, .sidebar strong {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 24px 0 16px 0;
  color: var(--accent-secondary);
  border-bottom: 2px solid var(--accent-primary);
  padding-bottom: 8px;
  display: block;
}

.nav-rail h2:first-child, .sidebar h2:first-child, .sidebar strong:first-child {
  margin-top: 0;
}

.nav-rail ul, .sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
}

.nav-rail li, .sidebar li {
  margin-bottom: 8px;
}

.nav-rail a, .primary-nav a, .toc-nav a {
  text-decoration: none;
  color: var(--text-main);
  display: block;
  padding: 4px 0;
}

.nav-rail a:hover, .nav-rail a[aria-current="page"], .primary-nav a:hover, .toc-nav a:hover {
  color: var(--accent-primary);
  font-weight: bold;
}

.main-content, .content {
  background-color: var(--bg-panel);
  padding: 40px;
  border: none;
  border-top: 4px solid var(--accent-highlight);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.content-image {
  width: 100%;
  height: auto;
  max-height: 350px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 32px;
  border: 2px solid var(--accent-highlight);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

/* Mystery Box Component */
.mystery-wrapper {
  position: relative;
  margin: calc(var(--space-unit) * 4) 0;
  padding: calc(var(--space-unit) * 4);
  background: linear-gradient(135deg, rgba(233, 69, 96, 0.15) 0%, rgba(249, 160, 63, 0.15) 100%), url('images/colourful-confetti-background-pattern.png') center/cover;
  border: 3px dashed var(--accent-highlight);
  border-radius: 12px;
  text-align: center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
}

.mystery-box-btn {
  background: linear-gradient(135deg, #ffd700, #ffeb3b);
  color: #192532;
  border: 3px solid #9b51e0;
  border-radius: 8px;
  padding: 12px 24px;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 0 #9b51e0;
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
  z-index: 2;
  outline: none;
}

.mystery-box-btn:hover, .mystery-box-btn:focus {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #9b51e0;
  background: linear-gradient(135deg, #ffeb3b, #ffd700);
}

.mystery-box-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #9b51e0;
}

.mystery-box-btn.anim-bounce {
  animation: boxBounce 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes boxBounce {
  0% { transform: scale(1) translateY(0); box-shadow: 0 4px 0 #9b51e0; }
  40% { transform: scale(0.8) translateY(10px); box-shadow: 0 0 0 #9b51e0; }
  60% { transform: scale(1.1) translateY(-10px); box-shadow: 0 14px 0 #9b51e0; }
  80% { transform: scale(0.95) translateY(2px); box-shadow: 0 2px 0 #9b51e0; }
  100% { transform: scale(1) translateY(0); box-shadow: 0 4px 0 #9b51e0; }
}

.mystery-result {
  margin-top: 16px;
  font-size: 18px;
  font-weight: bold;
  color: #9b51e0;
  min-height: 28px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.4s ease;
  z-index: 2;
  position: relative;
}

.mystery-result.show {
  opacity: 1;
  transform: translateY(0);
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 1;
  animation: confettiBurst 1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes confettiBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) rotate(var(--rot)) scale(0.5);
  }
}

/* Date Spine & Ledger Component */
.archive-spine {
  border-left: 4px solid var(--accent-highlight);
  padding-left: 24px;
  margin-top: 32px;
  margin-bottom: 40px;
}

.ledger-row {
  position: relative;
  padding: 24px;
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.ledger-row::before {
  content: "";
  position: absolute;
  left: -34px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-color: var(--accent-primary);
  border: 3px solid var(--accent-highlight);
  border-radius: 50%;
}

.draw-date {
  font-weight: bold;
  font-size: 18px;
  min-width: 140px;
}

.draw-numbers {
  display: flex;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 18px;
  align-items: center;
}

.num-pool {
  display: flex;
  gap: 8px;
}

.num-cell {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--accent-secondary);
  color: var(--accent-secondary);
  font-weight: bold;
  background-color: var(--bg-panel);
  border-radius: 50%;
}

.num-cell.euro {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background-color: #FFF0F5;
}

.draw-meta {
  font-size: 14px;
  text-align: right;
}

/* Tools & Filters */
.tools-panel {
  background-color: var(--bg-page);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-group label {
  font-size: 14px;
  font-weight: bold;
}

.filter-group select, .filter-group input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  font-size: 16px;
  background-color: var(--bg-panel);
  color: var(--text-main);
}

.btn, .button {
  background-color: var(--bg-panel);
  color: var(--accent-secondary);
  border: 2px solid var(--accent-secondary);
  padding: 8px 16px;
  font-size: 16px;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 150ms ease;
}

.btn:hover, .btn:focus, .button:hover, .button:focus {
  background-color: var(--accent-secondary);
  color: #fff;
}

.btn-primary, .button-accent {
  background-color: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.btn-primary:hover, .button-accent:hover {
  background-color: #c93a52;
  border-color: #c93a52;
}

/* Matrix */
.matrix-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 40px;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.matrix-table caption {
  text-align: left;
  font-weight: bold;
  margin-bottom: 12px;
}

.matrix-table th, .matrix-table td {
  border: 1px solid var(--border);
  padding: 8px;
  text-align: center;
  font-family: var(--font-mono);
}

.matrix-table th {
  background-color: var(--accent-secondary);
  color: #fff;
  font-family: var(--font-body);
  font-weight: bold;
  border-color: var(--accent-secondary);
}

.matrix-table td.active {
  background-color: var(--accent-highlight);
  color: var(--text-main);
  font-weight: bold;
}

.matrix-table td.euro-active {
  background-color: var(--accent-primary);
  color: #fff;
  font-weight: bold;
}

/* FAQ */
details {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

summary {
  font-weight: bold;
  cursor: pointer;
  font-size: 18px;
  padding-right: 24px;
  position: relative;
}

summary:hover {
  color: var(--accent-primary);
}

details p {
  margin-top: 16px;
  margin-bottom: 0;
}

/* Forms */
.form-draft, .standard-form {
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-draft input, .form-draft textarea, .standard-form input, .standard-form textarea, .standard-form select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  font-family: var(--font-body);
  font-size: 16px;
}

.form-draft textarea, .standard-form textarea {
  min-height: 150px;
  resize: vertical;
}

.notice, .warning-panel {
  background-color: #FFF0F5;
  border-left: 4px solid var(--accent-primary);
  padding: 16px;
  margin-bottom: 24px;
  font-size: 15px;
  border-radius: 0 8px 8px 0;
}
.warning-panel {
  background-color: #FFF4E6;
  border-color: var(--accent-highlight);
}

/* Footer */
.site-footer {
  margin-top: 64px;
  background-color: var(--accent-tertiary);
  color: #fff;
  border-top: 4px solid var(--accent-primary);
  padding: 40px 0;
  font-size: 14px;
}

.site-footer h3, .site-footer strong, .site-footer .footer-brand {
  color: var(--accent-highlight);
  font-size: 16px;
  margin-top: 0;
  margin-bottom: 16px;
  text-transform: uppercase;
}

.site-footer a {
  color: #fff;
}
.site-footer a:hover {
  color: var(--accent-primary);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  max-width: 1196px;
  margin: 0 auto;
  padding: 0 24px;
}

.footer-col ul {
  list-style: none;
  padding: 0;
}

.footer-col li {
  margin-bottom: 8px;
}

.empty-state {
  display: none;
  padding: 40px;
  text-align: center;
  background-color: var(--bg-page);
  border: 1px solid var(--border);
}

/* Cookie Banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: var(--bg-panel);
  border-top: 2px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  z-index: 9999;
  display: none;
  padding: 16px 24px;
}

.cookie-banner.show {
  display: block;
}

.cookie-banner-content {
  max-width: 1196px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cookie-banner p {
  margin: 0;
  font-size: 15px;
  flex: 1 1 300px;
}

.cookie-banner-actions {
  display: flex;
  gap: 12px;
}

/* Responsive */
@media (max-width: 1279px) {
  .site-container, .layout-wrapper {
    padding: 24px;
    gap: 24px;
    grid-template-columns: 200px 1fr;
  }
  .main-content, .content {
    padding: 24px;
  }
}

@media (max-width: 999px) {
  .matrix-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .site-container, .layout-wrapper {
    display: block;
    padding: 0;
  }
  .masthead {
    margin-bottom: 0;
    flex-direction: column;
    height: auto;
    padding: 16px;
    align-items: flex-start;
    gap: 16px;
  }
  
  /* Left rail becomes horizontal date/nav selector */
  .nav-rail, .sidebar {
    position: static;
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    padding: 0 16px;
    height: 48px;
    align-items: center;
    border-top: none;
    border-left: none;
    border-right: none;
    border-radius: 0;
    margin-bottom: 16px;
    box-shadow: none;
  }
  
  .nav-rail h2, .sidebar h2, .sidebar strong {
    display: none;
  }
  
  .nav-rail ul, .sidebar nav {
    display: flex;
    margin: 0;
    gap: 16px;
  }
  
  .nav-rail li {
    margin: 0;
  }
  
  .main-content, .content {
    padding: 16px;
    border-left: none;
    border-right: none;
    border-radius: 0;
  }
  
  body {
    font-size: 16px;
  }

  .draw-numbers {
    flex-wrap: wrap;
  }
  
  .ledger-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .cookie-banner-actions {
    width: 100%;
    justify-content: flex-end;
  }
}