:root {
  --bg-main: #050608;
  --bg-card: #050608;
  --text-main: #f8fbff;
  --text-dim: #9aa0b4;
  --green: #39ffb6;
  --cyan: #00e7ff;
  --orange: #ff9a3c;
  --blue: #27a9ff;
  --yellow: #ffd74a;
  --font-main: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  min-height: 100vh;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-main);
  padding: 1rem;
}

/* contenidor general */
.bds-display {
  background: var(--bg-main);
  color: var(--text-main);
  width: 100%;
  max-width: 600px;
  aspect-ratio: 4 / 3;
  padding: 0.8rem 1rem;
  border-radius: 18px;
  box-shadow: 0 0 0 4px #222, 0 12px 30px rgba(0,0,0,0.9);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* FILA 1: header logo | countdown | selector */
.bds-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 0.5rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
}

.bds-logo {
  justify-self: flex-start;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.bds-logo img {
  height: 40px;        
  width: auto;         /* Mantiene proporcions */
  max-width: 200px;    /* Límit màxim */
  object-fit: contain; 
  border-radius: 3px;  /* Lleu cantonada arrodonida */
}

.bds-countdown {
  justify-self: center;
}

.bds-countdown span {
  font-weight: 600;
  color: var(--green);
}

.bds-station-select {
  justify-self: flex-end;
}

.bds-station-select label {
  margin-right: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.bds-station-select select {
  background: #394961;
  color: var(--text-main);
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 0.1rem 0.3rem;
  font-size: 0.8rem;
}

/* GRID PRINCIPAL: files 2–4 */
.bds-main-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1.2fr 1.1fr 1.1fr;
  grid-template-rows: 1.1fr 1.1fr 0.9fr;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.bds-card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
}

/* POSICIONAMENT GRID segons descripció */
.bds-wind { grid-column: 1; grid-row: 1 / span 2; }
.bds-clock { grid-column: 2; grid-row: 1; }
.bds-out  { grid-column: 3; grid-row: 1; }
.bds-rain { grid-column: 2; grid-row: 2; }
.bds-in   { grid-column: 3; grid-row: 2; }
.bds-uvi  { grid-column: 1; grid-row: 3; }
.bds-light{ grid-column: 2; grid-row: 3; }
.bds-baro { 
  grid-column: 3; 
  grid-row: 3; 
  justify-self: end !important;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.bds-baro-main {
  justify-content: flex-end;
  width: 100%;
}

.bds-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-bottom: 0.15rem;
  color: var(--text-dim);
}

/* WIND */
.bds-wind .bds-section-title { color: var(--cyan); }
.bds-wind-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
}

.bds-wind-gauge-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.bds-wind-gauge-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* text al damunt del disc */
.bds-wind-dir {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  color: var(--cyan);
  font-weight: 600;
  z-index: 10;
}

.bds-wind-speed {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  z-index: 10;
}

.bds-wind-unit {
  position: absolute;
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: var(--text-dim);
  z-index: 10;
}

/* CLOCK + DATA */
.bds-clock-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.4rem;
}

.bds-time {
  font-size: 2.6rem;
  font-weight: 700;
}

.bds-time-small {
  font-size: 0.75rem;
  color: var(--cyan);
}

.bds-date-row {
  margin-top: 0.15rem;
  display: flex;
  justify-content: center;
  font-size: 0.9rem;
}

/* OUT / IN */
.bds-out .bds-section-title,
.bds-in .bds-section-title {
  color: var(--green);
  text-align: right;
}

.bds-out, .bds-in {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.bds-out-temp, .bds-in-temp {
  display: flex;
  align-items: baseline;
  gap: 0.1rem;
}

.bds-out-temp-value { font-size: 2.4rem; font-weight: 700; }
.bds-in-temp-value  { font-size: 2.0rem; font-weight: 700; }

.bds-out-temp-unit, .bds-in-temp-unit {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.bds-out-hum, .bds-in-hum {
  font-size: 1.5rem;
  color: var(--blue);
}

/* RAIN */
.bds-rain .bds-section-title { color: var(--blue); }
.bds-rain-main,
.bds-rain24-main {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.bds-rain-value,
.bds-rain24-value {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--blue);
}

/* UVI / LIGHT / BARO */
.bds-uvi .bds-section-title { color: var(--yellow); }
.bds-light .bds-section-title,
.bds-baro .bds-section-title { color: var(--cyan); }

.bds-uvi-main,
.bds-light-main,
.bds-baro-main {
  display: flex;
  align-items: baseline;
  gap: 0.2rem;  
}

.bds-uvi-value { font-size: 1.5rem; color: var(--yellow); }
.bds-light-value,
.bds-baro-value { font-size: 1.4rem; }

/* Responsivitat bàsica */
@media (max-width: 840px) {
  .bds-display {
    max-width: 100%;
    aspect-ratio: auto;
    height: auto;
  }
}

@media (max-width: 700px) {
  .bds-main-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .bds-wind,
  .bds-clock,
  .bds-out,
  .bds-rain,
  .bds-in,
  .bds-uvi,
  .bds-light,
  .bds-baro {
    grid-column: 1;
    grid-row: auto;
  }

  .bds-out, .bds-in {
    align-items: center;
  }
}