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

body {
  font-family: Tahoma, Arial, sans-serif;
  background: #120000;
  color: #fff;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  padding: 18px;
}

.page-header {
  margin-bottom: 18px;
}

.lotto-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 8px;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.lotto-flag {
  width: 32px;
  height: 22px;
  object-fit: cover;
  border-radius: 3px;
}

/* กระพริบเฉพาะ LIVE */
.live .lotto-flag {
  animation: flagBlink 1.2s infinite ease-in-out;
}

@keyframes flagBlink {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

.page-header h1 {
  margin: 0;
  color: #ffd11a;
  font-size: 34px;
  line-height: 1.1;
}

.page-header p {
  margin: 8px 0 0;
  color: #ffe1e1;
  font-size: 14px;
}

.top-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 0;
  flex-wrap: wrap;
}

.top-action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.welcome-text {
  color: #ffe082;
  font-size: 14px;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 700;
  background: #6a2d00;
  border: 1px solid #c49500;
  color: #ffd94b;
}

.logout-btn:hover {
  opacity: 0.95;
}

.grid-lotto {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.lotto-card {
  background: #6a0000;
  border: 1.5px solid #ff1f1f;
  border-radius: 18px;
  padding: 12px;
  min-height: 255px;
  box-shadow: inset 0 0 0 1px rgba(255, 120, 0, 0.08);
}

.lotto-card.has-result {
  box-shadow: 0 0 18px rgba(255, 210, 0, 0.22), inset 0 0 0 1px rgba(255, 214, 10, 0.15);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 24px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: #ffd94b;
  background: #6a2d00;
  border: 1px solid #c49500;
  border-radius: 999px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #19ff7b;
  box-shadow: 0 0 8px rgba(25,255,123,0.8);
}

.lotto-title {
  margin: 0 0 18px;
  font-size: 18px;
  line-height: 1.1;
  min-height: auto;
  padding: 0;
}

.lotto-time {
  margin: 2px 0 8px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  color: #ffe082;
}

.result-boxes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.result-box {
  background: #8a4300;
  border: 1px dashed #c28b00;
  border-radius: 14px;
  min-height: 96px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lotto-card.has-result .result-box {
  background: linear-gradient(180deg, #ffdf52 0%, #efb500 100%);
  color: #5b0000;
  border-style: solid;
}

.result-label {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
}

.result-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 14px;
  color: #fff2f2;
}

.status-text.error { color: #ffd1d1; }

.result-date {
  font-size: 12px;
  color: #ffcbcb;
}

.debug-panel {
  margin-top: 18px;
  background: #1d1d1d;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 14px;
}

.debug-panel h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

#debugOutput {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d6f7ff;
  font-size: 13px;
}

.bottom-datetime-box {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.bottom-now {
  text-align: left;
  padding-left: 24px;
}

.bottom-now-time {
  font-size: 40px;
  font-weight: 800;
  color: #ffd11a;
  line-height: 1;
}

.bottom-now-date {
  margin-top: 8px;
  font-size: 16px;
  color: #ffe1e1;
}

.bottom-now-date {
  margin-top: 8px;
  font-size: 16px;
  color: #ffe1e1;
}

/* login */
.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(255, 180, 0, 0.15), transparent 35%),
    linear-gradient(180deg, #220000 0%, #120000 100%);
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(106, 0, 0, 0.95);
  border: 1.5px solid #ff1f1f;
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}

.login-logo {
  width: 70px;
  height: 70px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ffdf52 0%, #efb500 100%);
  font-size: 30px;
}

.login-title {
  margin: 0;
  text-align: center;
  color: #ffd11a;
  font-size: 30px;
  line-height: 1.1;
}

.login-subtitle {
  margin: 8px 0 22px;
  text-align: center;
  color: #ffe1e1;
  font-size: 14px;
}

.login-alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 60, 60, 0.16);
  border: 1px solid rgba(255, 120, 120, 0.45);
  color: #ffd5d5;
  font-size: 14px;
}

.login-form .form-group {
  margin-bottom: 16px;
}

.login-form label {
  display: block;
  margin-bottom: 8px;
  color: #ffe082;
  font-size: 14px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 48px;
  border: 1px solid #c28b00;
  border-radius: 12px;
  background: #2a0000;
  color: #fff;
  padding: 0 14px;
  font-size: 15px;
  outline: none;
}

.login-form input:focus {
  border-color: #ffd11a;
  box-shadow: 0 0 0 3px rgba(255, 209, 26, 0.12);
}

.login-btn {
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffdf52 0%, #efb500 100%);
  color: #5b0000;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.login-btn:hover {
  transform: translateY(-1px);
  opacity: 0.96;
}

.login-demo {
  margin-top: 14px;
  text-align: center;
  color: #ffcbcb;
  font-size: 13px;
}

/* dashboard */
.dashboard-grid .dashboard-card {
  min-height: 210px;
  display: block;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.dashboard-grid .dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 18px rgba(255, 210, 0, 0.22), inset 0 0 0 1px rgba(255, 214, 10, 0.15);
}

.dashboard-count-box {
  margin: 18px 0;
  padding: 18px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffdf52 0%, #efb500 100%);
  color: #5b0000;
  text-align: center;
}

.dashboard-count-number {
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
}

.dashboard-count-text {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
}

@media (max-width: 1200px) {
  .grid-lotto { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .grid-lotto { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .grid-lotto { grid-template-columns: 1fr; }

  .top-action-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .top-action-buttons {
    width: 100%;
  }

  .logout-btn {
    width: 100%;
  }

  .page-header h1 {
    font-size: 28px;
  }
}