/* Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #12471b;
  --primary-variant: #1a5d23;
  --secondary: #d1a42e;
  --secondary-variant: #a88525;
  --surface: #ffffff;
  --on-surface: #1a3018;
  --outline: #c0d8c0;
  --shadow: 0 6px 20px rgba(18, 71, 27, 0.12);
  --elevation-2: 0 4px 12px rgba(18, 71, 27, 0.1);
  --elevation-4: 0 8px 24px rgba(18, 71, 27, 0.15);
  --radius: 30px;
  --btn-radius: 100px;
}

body {
  font-family: 'Inter', sans-serif;
  background: #f5f9f5;
  color: var(--on-surface);
  line-height: 1.6;
  min-height: 100vh;
  padding: 20px;
  display: flex;
  justify-content: center;
}

.app {
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0 auto;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-icon {
  background: var(--primary);
  color: white;
  border: none;
  width: 52px;
  height: 52px;
  border-radius: var(--btn-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--elevation-2);
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-icon.small {
  width: 40px;
  height: 40px;
}

.btn-icon:hover {
  background: var(--primary-variant);
  transform: scale(1.05);
}

/* Date */
.date {
  text-align: center;
  font-size: 0.95rem;
  color: #556853;
  font-weight: 500;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--elevation-2);
  border: 1px solid var(--outline);
  transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--elevation-4);
  transform: translateY(-3px);
}

.card.current {
  border-top: 4px solid var(--primary);
}

.card.next {
  border-top: 4px solid var(--secondary);
}

.card .label {
  display: block;
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 500;
  margin-bottom: 6px;
}

.card .name {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--on-surface);
}

.card .time {
  display: block;
  font-size: 1rem;
  color: #556853;
  margin-top: 4px;
}

/* Countdown */
.countdown {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 30px 0;
  font-weight: 700;
  color: var(--secondary);
  font-size: 2.2rem;
}

.box {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
  background: white;
  border-radius: 20px;
  padding: 8px 0;
  box-shadow: 0 4px 14px rgba(209, 164, 46, 0.15);
  border: 1px solid rgba(209, 164, 46, 0.2);
}

.box span {
  font-variant-numeric: tabular-nums;
  font-size: 1.6rem;
}

.sep {
  font-size: 2rem;
  display: flex;
  align-items: center;
  color: #aaa;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content {
  background: var(--surface);
  width: 95%;
  max-width: 900px;
  height: 90vh;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--elevation-4);
  display: flex;
  flex-direction: column;
}

.modal-header {
  background: var(--primary);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h2 {
  font-size: 1.4rem;
  font-weight: 600;
}

.table-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--surface);
  color: var(--on-surface);
}

/* Custom Scrollbar */
.table-wrapper::-webkit-scrollbar {
  width: 10px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--primary-variant);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th {
  background: var(--primary);
  color: white;
  padding: 16px 10px;
  text-align: center;
  font-weight: 500;
}

td {
  padding: 14px 8px;
  text-align: center;
  border-bottom: 1px solid var(--outline);
  color: var(--on-surface);
}

tbody tr:hover {
  background: rgba(209, 164, 46, 0.06);
}

/* Footer */
footer {
  text-align: center;
  font-size: 0.8rem;
  color: #666;
  margin-top: auto;
  padding: 16px 0;
}

footer a {
  color: var(--secondary);
  text-decoration: none;
  font-weight: 500;
}

footer a:hover {
  text-decoration: underline;
}

/* ===== DARK THEME ===== */
:root[data-theme="dark"] {
  --primary: #2e8b57;
  --primary-variant: #3cb371;
  --secondary: #d1a42e;
  --secondary-variant: #f0e08c;
  --surface: #1a1f1a;
  --on-surface: #e0ebe0;
  --outline: #3a503a;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  --elevation-2: 0 4px 12px rgba(0, 0, 0, 0.2);
  --elevation-4: 0 8px 24px rgba(0, 0, 0, 0.3);
  --radius: 30px;
  --btn-radius: 100px;
}

[data-theme="dark"] body {
  background: #121812;
  color: #e0ebe0;
}

[data-theme="dark"] .app {
  color: var(--on-surface);
}

[data-theme="dark"] .card {
  background: var(--surface);
  border-color: var(--outline);
  color: var(--on-surface);
}

[data-theme="dark"] .card .name,
[data-theme="dark"] .card .time {
  color: var(--on-surface);
}

[data-theme="dark"] .card .label {
  color: var(--primary-variant);
}

[data-theme="dark"] .date {
  color: #8faa8f;
}

[data-theme="dark"] table {
  color: var(--on-surface);
}

[data-theme="dark"] th {
  background: var(--primary);
}

[data-theme="dark"] td {
  border-bottom-color: var(--outline);
  color: var(--on-surface);
}

[data-theme="dark"] tbody tr:hover {
  background: rgba(209, 164, 46, 0.1);
}

[data-theme="dark"] .table-wrapper {
  background: var(--surface);
  color: var(--on-surface);
}

[data-theme="dark"] .table-wrapper::-webkit-scrollbar-track {
  background: #1a1f1a;
}

[data-theme="dark"] .table-wrapper::-webkit-scrollbar-thumb {
  background: var(--primary-variant);
}

[data-theme="dark"] .table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #3cb371;
}

[data-theme="dark"] .btn-icon {
  background: var(--primary);
}

[data-theme="dark"] .btn-icon:hover {
  background: var(--primary-variant);
}

[data-theme="dark"] .modal-header {
  background: var(--primary);
}

[data-theme="dark"] footer a {
  color: var(--secondary-variant);
}

[data-theme="dark"] .countdown {
  color: var(--secondary-variant);
}

[data-theme="dark"] .box {
  background: #242b24;
  border: 1px solid var(--primary);
  box-shadow: 0 4px 14px rgba(46, 139, 87, 0.2);
}

/* Smooth transitions */
* {
  transition: background 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Mobile Responsiveness */
@media (max-width: 500px) {
  header {
    gap: 8px;
  }

  .btn-icon {
    width: 46px;
    height: 46px;
  }

  .btn-icon.small {
    width: 36px;
    height: 36px;
  }

  header h1 {
    font-size: 1.6rem;
    min-width: 0;
  }

  .countdown {
    font-size: 1.8rem;
  }

  .box {
    min-width: 52px;
    padding: 6px 0;
  }

  .box span {
    font-size: 1.4rem;
  }
}
