:root{
  --page-bg:#000;
  --tile-bg:#141414;
  --tile-bg-2:#101010;
  --border:#2a2a2a;
  --radius:18px;
  --fg:#e9ecf1;

  --ok:#5fe39f;
  --warn:#ffd54a;
  --danger:#ff4d4d;
  --transition:#7fd8ff;

  --off-red-bg: rgba(255, 92, 92, .36);
  --off-red-br: rgba(255, 120, 120, .95);

  --btn-on-bg: rgba(52,211,153,.18);
  --btn-on-br: rgba(52,211,153,.55);
}

*{box-sizing:border-box}
html,body{height:100%}

body{
  margin:0;
  font-family:"JetBrains Mono", monospace;
  background:var(--page-bg);
  color:var(--fg);
  overflow-x:hidden;
}

body.kiosk{
  overflow:hidden;
  touch-action:manipulation;
}

.wrap{
  width:100%;
  margin:auto;
  padding:12px;
  display:grid;
  gap:10px;
}

.display{
  min-height:calc(100vh - 24px);
  display:grid;
  grid-template-rows:1fr auto auto auto;
  gap:10px;
}

.bigtime{
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:950;
  font-size:clamp(144px, 19.2vw, 504px);
  line-height:.9;
  white-space:nowrap;
  margin:0;
  text-align:center;
}
.bigtime.ok{color:var(--ok)}
.bigtime.warn{color:var(--warn)}
.bigtime.danger{color:var(--danger)}
.bigtime.transition{color:var(--transition)}

.mainRow,
.bottomTiles{
  display:grid;
  grid-template-columns:minmax(0, 2fr) minmax(0, 1fr);
  gap:12px;
  align-items:stretch;
}

.currentActivityPanel,
.nextActivityTile,
.settingsTile,
.mainRow > .panel,
.bottomTiles > .tile{
  width:100%;
  max-width:100%;
  justify-self:stretch;
}

.panel,.tile,.card{
  border-radius:16px;
  border:1px solid var(--border);
  background:var(--tile-bg);
  padding:10px 12px;
}

.label{
  text-transform:uppercase;
  font-size:12px;
  letter-spacing:.14em;
  color:rgba(233,236,241,.70);
  margin-bottom:6px;
}

.timePanel .label{
  text-align:center;
}

.currentActivityPanel .nextLine2,
.timePanel .nextLine2{
  width:100%;
  text-align:center;
}

.currentActivityPanel .nextLine2{
  text-align:left;
}

#currentPurpose{
  justify-self:stretch;
}

.panel{
  display:flex;
  flex-direction:column;
}

#whereWeAre,
#nextEventTileText,
.subHeroTime{
  font-size:clamp(36px,5.8vw,86px);
  font-weight:950;
  line-height:1.05;
  color:#fff;
}

#whereWeAre,
#nextEventTileText,
.subHeroTime{
  flex:1;
  display:flex;
  align-items:center;
}

#whereWeAre,
#nextEventTileText{
  word-break:keep-all;
}

#whereWeAre{
  width:100%;
  white-space:nowrap;
  overflow:hidden;
  text-wrap:nowrap;
  justify-content:flex-start;
}

.currentActivityPanel{
  justify-content:center;
}

.timePanel{
  justify-content:center;
}

#nextEventTileText{
  flex-direction:column;
  align-items:flex-start;
  justify-content:center;
}

#nextEventTileText .nextPrimary{
  display:block;
  width:100%;
}

#whereWeAre.transitionState,
#nextEventTileText.transitionState{color:var(--transition);}
#whereWeAre.wrapWarn,
#nextEventTileText.wrapWarn{color:var(--warn);}
#whereWeAre.wrapDanger,
#nextEventTileText.wrapDanger{color:var(--danger);}
#whereWeAre.wrapBig,
#nextEventTileText.wrapBig{
  font-size:clamp(63px, 10.15vw, 150px);
}

#whereWeAre.firstCallState,
#nextEventTileText.firstCallState{color:var(--warn);}

.subHeroTime{
  text-align:center;
  white-space:nowrap;
  display:flex;
  align-items:center;
  justify-content:center;
  flex:1;
}

.timeSyncMeta{
  margin-top:4px;
}

.settingsTile{
  width:100%;
  max-width:100%;
  justify-self:stretch;
}

.settingsTile .label{
  white-space:nowrap;
}

.nextLine2{
  display:block;
  width:100%;
  margin-top:4px;
  clear:both;
  font-size:clamp(14px, 2.0vw, 22px);
  font-weight:800;
  opacity:.6;
}

.btnRow{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
  font-size:2.3em;
}

button,select,input[type="range"]{
  border-radius:14px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(255,255,255,.06);
  color:var(--fg);
  padding:8px 6px;
  font-weight:900;
  cursor:pointer;
}

button,
select{
  font-size:clamp(13px, 1.7vw, 28px);
}

.toggleBtn.on,
.volBtn.on{
  background:var(--btn-on-bg);
  border-color:var(--btn-on-br);
}

.toggleBtn.kioskOff,
.volBtn.muted{
  background:var(--off-red-bg);
  border-color:var(--off-red-br);
}

.settingsLayout{
  display:grid;
  grid-template-columns:minmax(0, 1fr) clamp(88px, 11vw, 132px);
  gap:12px;
  align-items:stretch;
}

.settingsLeft{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "schedule schedule"
    "kiosk slider";
  gap:10px;
  align-items:stretch;
}

.scheduleWideBtn{grid-area:schedule;}
.sliderWrap{grid-area:slider;}
#kioskBtn{grid-area:kiosk;}

.settingsControl,
.sliderWrap{
  width:100%;
  min-width:0;
  height:58px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:clamp(18px, 2.2vw, 34px);
  line-height:1;
  white-space:nowrap;
  text-align:center;
}

.sliderWrap{
  padding:0 8px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(255,255,255,.06);
}

.settingsLayout,
.settingsLeft,
.settingsLeft > *,
.settingsControl,
.sliderWrap,
.soundBig{
  min-width:0;
}

.sliderWrap.on{
  background:var(--btn-on-bg);
  border-color:var(--btn-on-br);
}

.sliderWrap.muted{
  background:var(--off-red-bg);
  border-color:var(--off-red-br);
}

.volumeSlider{
  -webkit-appearance:none;
  appearance:none;
  width:100%;
  min-width:0;
  height:18px;
  padding:0;
  background:transparent;
  border:none;
  box-shadow:none;
}

.soundBig{
  width:clamp(88px, 11vw, 132px);
  min-width:clamp(88px, 11vw, 132px);
  height:130px;
  border-radius:18px;
  font-size:clamp(36px, 4.3vw, 56px);
  font-weight:900;
  display:flex;
  align-items:center;
  justify-content:center;
  line-height:1;
}

.scheduleWideBtn{
  letter-spacing:.04em;
  display:flex;
  flex-wrap:wrap;
  align-content:center;
  justify-content:center;
  gap:0 .45em;
  white-space:normal;
  line-height:.95;
  padding:8px 10px;
}

.scheduleWideBtn .scheduleDay,
.scheduleWideBtn .scheduleTime{
  display:inline-block;
}

@media (max-width: 980px){
  .scheduleWideBtn{
    flex-direction:column;
    gap:2px;
  }
}

.modal select option{
  background:#000;
  color:#fff;
  font-weight:900;
}

.card{
  border-radius:var(--radius);
  background:var(--tile-bg);
  border:1px solid var(--border);
  padding:14px;
}
.timelineCard{
  margin-top:16px;
}
.hiddenCard{
  display:none;
}
.errorText{
  font-size:18px;
  line-height:1.4;
  color:var(--danger);
}

table{width:100%;border-collapse:collapse}
th,td{padding:6px 6px;border-bottom:1px solid rgba(255,255,255,.1); vertical-align:middle;}
.timelineCard td:last-child{line-height:1.25;}
th{text-transform:uppercase;font-size:12px;color:rgba(233,236,241,.7)}
.right{text-align:right}
.center{text-align:center}

tbody td:first-child{font-weight:900; white-space:nowrap;}

tbody td:nth-child(2),
tbody td:nth-child(3),
tbody td:nth-child(4){text-align:center;}

.durationCol{
  white-space:nowrap;
}

.dashCell{
  opacity:.65;
}

.soundChip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:4px 8px;
  font-size:12px;
  line-height:1;
  white-space:nowrap;
}

.soundChip.playing{
  background:var(--btn-on-bg);
  border-color:var(--btn-on-br);
}

.soundChipLabel{
  display:inline-block;
}

.soundChipIcon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:16px;
  font-size:12px;
}

tr.current td { background: rgba(255,255,255,.06); }
tr.next td { background: rgba(255,255,255,.10); }
tr.past { opacity: .6; }

body.kiosk .timelineCard{
  display:none !important;
}

.modalOverlay{
  position:fixed; inset:0;
  background:rgba(0,0,0,.7);
  display:none; align-items:center; justify-content:center;
  padding:16px;
  z-index:100000;
}
.modalOverlay.open{display:flex}

.modal{
  width:min(620px, 96vw);
  background:var(--tile-bg-2);
  border:1px solid rgba(255,255,255,.16);
  padding:16px;
  border-radius:18px;
}

.modalTitle,
.modalFieldLabel{
  text-transform:uppercase;
  letter-spacing:.14em;
}
.modalTitle{font-size:18px;margin-bottom:14px;}
.modalFieldLabel{font-size:12px;margin-bottom:8px;color:rgba(233,236,241,.7)}
.modalGrid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:14px;
}
.modalGrid select{width:100%;font-size:28px;padding:12px 10px;}
.modalActions{display:flex;justify-content:flex-end;gap:12px;margin-top:16px;}
.modalActions button{font-size:18px;padding:10px 16px;}

@media (max-width: 900px){
  .settingsLayout{
    grid-template-columns:minmax(0, 1fr) clamp(76px, 10vw, 104px);
    gap:8px;
  }
  .settingsLeft{
    gap:6px;
  }
  .settingsControl,
  .sliderWrap{
    padding-left:4px;
    padding-right:4px;
    font-size:clamp(11px, 1.45vw, 22px);
  }
  .soundBig{
    width:clamp(76px, 10vw, 104px);
    min-width:clamp(76px, 10vw, 104px);
    font-size:clamp(28px, 3.9vw, 44px);
  }
}


@media (max-width: 900px) and (orientation: landscape){
  .wrap{padding:12px;}
  .display{min-height:calc(100vh - 24px);}
  .panel,.tile,.card{padding:10px 12px;}
  .mainRow,
  .bottomTiles{
    grid-template-columns:minmax(0, 2fr) minmax(0, 1fr);
    gap:10px;
  }
  .settingsLayout{
    grid-template-columns:minmax(0, 1fr) clamp(68px, 10vw, 92px);
    gap:8px;
  }
  .settingsLeft{
    grid-template-columns:repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "schedule schedule"
      "kiosk slider";
    gap:6px;
  }
  .settingsControl,
  .sliderWrap{
    height:50px;
    padding-left:4px;
    padding-right:4px;
    font-size:clamp(11px, 1.8vw, 18px);
  }
  .soundBig{
    width:clamp(68px, 10vw, 92px);
    min-width:clamp(68px, 10vw, 92px);
    height:106px;
    font-size:clamp(24px, 3.6vw, 40px);
  }
}

@media (max-width: 700px) and (orientation: portrait){
  .wrap{padding:12px;}
  .display{min-height:auto;}
  .btnRow{font-size:2em;}
  .modalGrid{grid-template-columns:1fr;}
  .settingsLayout{grid-template-columns:1fr;}
  .settingsLeft{grid-template-columns:1fr 1fr; grid-template-areas:
    "schedule schedule"
    "kiosk slider";}
  .soundBig{
    width:100%;
    min-width:0;
    height:90px;
  }
  .settingsControl,
  .sliderWrap{
    width:100%;
    min-width:0;
  }
}


/* v39 portrait layout fix: full-width stacked tiles, timer fits, settings row stays at bottom */
@media (max-width: 900px) and (orientation: portrait){
  html, body{
    overflow-x:hidden;
  }

  .wrap{
    width:100%;
    max-width:100%;
    padding:10px;
  }

  .wrap,
  .display,
  .mainRow,
  .bottomTiles,
  .panel,
  .tile,
  .settingsTile,
  .settingsLayout,
  .settingsLeft,
  .settingsLeft > *,
  .settingsControl,
  .sliderWrap,
  .soundBig,
  #whereWeAre,
  #nextEventTileText,
  .subHeroTime,
  .bigtime{
    min-width:0;
    max-width:100%;
  }

  .display{
    min-height:calc(100svh - 20px);
    grid-template-rows:minmax(0, 1fr) auto auto auto;
    gap:8px;
  }

  .bigtime{
    width:100%;
    font-size:clamp(62px, 18vw, 132px);
    line-height:.86;
    overflow:hidden;
    text-align:center;
  }

  .mainRow,
  .bottomTiles{
    grid-template-columns:minmax(0, 1fr);
    gap:8px;
    width:100%;
  }

  .bottomTiles{
    margin-top:auto;
  }

  .panel,
  .tile,
  .card{
    width:100%;
    padding:10px;
  }

  #whereWeAre,
  #nextEventTileText,
  .subHeroTime{
    font-size:clamp(28px, 7.2vw, 52px);
    line-height:1;
  }

  #whereWeAre.wrapBig,
  #nextEventTileText.wrapBig{
    font-size:clamp(34px, 8.6vw, 62px);
  }

  .label{
    margin-bottom:4px;
  }

  .nextLine2{
    margin-top:2px;
    font-size:clamp(12px, 3.1vw, 18px);
  }

  .settingsLayout{
    grid-template-columns:minmax(0, 1fr);
    gap:8px;
  }

  .settingsLeft{
    grid-template-columns:repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "schedule schedule"
      "kiosk slider";
    gap:8px;
  }

  .settingsControl,
  .sliderWrap{
    height:52px;
    padding-left:6px;
    padding-right:6px;
    font-size:clamp(14px, 3.6vw, 20px);
  }

  .soundBig{
    width:100%;
    min-width:0;
    height:72px;
    font-size:clamp(28px, 8vw, 40px);
  }
}

@media (max-width: 420px) and (orientation: portrait){
  .wrap{
    padding:8px;
  }

  .display{
    min-height:calc(100svh - 16px);
    gap:6px;
  }

  .mainRow,
  .bottomTiles,
  .settingsLayout,
  .settingsLeft{
    gap:6px;
  }

  .panel,
  .tile,
  .card{
    padding:8px;
  }

  .bigtime{
    font-size:clamp(52px, 16vw, 96px);
  }

  #whereWeAre,
  #nextEventTileText,
  .subHeroTime{
    font-size:clamp(24px, 6.7vw, 40px);
  }

  #whereWeAre.wrapBig,
  #nextEventTileText.wrapBig{
    font-size:clamp(28px, 7.2vw, 46px);
  }

  .settingsControl,
  .sliderWrap{
    height:46px;
    font-size:clamp(12px, 3.5vw, 16px);
  }

  .soundBig{
    height:64px;
    font-size:clamp(24px, 7vw, 34px);
  }
}

/* v48 - Portrait phone schedule cards consolidated into main stylesheet
   Replaces the earlier v41-v47 schedule portrait patches.
*/
@media (max-width: 700px) and (orientation: portrait){
  .timelineCard{
    margin-top:12px;
    padding:12px;
    overflow-x:hidden;
  }

  .timelineCard table,
  .timelineCard thead,
  .timelineCard tbody,
  .timelineCard tr,
  .timelineCard th,
  .timelineCard td{
    display:block;
    width:100%;
    max-width:100%;
    box-sizing:border-box;
  }

  .timelineCard thead{
    position:absolute;
    width:1px;
    height:1px;
    padding:0;
    margin:-1px;
    overflow:hidden;
    clip:rect(0,0,0,0);
    white-space:nowrap;
    border:0;
  }

  .timelineCard tbody{
    display:flex;
    flex-direction:column;
    gap:12px;
  }

  .timelineCard tr{
    border:1px solid rgba(255,255,255,.12);
    border-radius:14px;
    background:rgba(255,255,255,.03);
    padding:10px 12px 8px;
    overflow:hidden;
  }

  .timelineCard tr.current td,
  .timelineCard tr.next td,
  .timelineCard tr.past td{
    background:transparent;
  }

  .timelineCard td{
    display:flex;
    align-items:flex-start;
    gap:10px;
    border-bottom:1px solid rgba(255,255,255,.08);
    padding:8px 0;
    text-align:left !important;
    white-space:normal;
    word-break:normal;
    overflow-wrap:break-word;
    min-width:0;
  }

  .timelineCard td:last-child{
    border-bottom:0;
    padding-bottom:2px;
  }

  .timelineCard td::before{
    content:"";
    flex:0 0 6.25rem;
    width:6.25rem;
    font-size:11px;
    line-height:1.25;
    text-transform:uppercase;
    letter-spacing:.06em;
    color:rgba(233,236,241,.68);
    font-weight:700;
    white-space:nowrap;
    padding-top:2px;
  }

  .timelineCard td:nth-child(1)::before{ content:"Event"; }
  .timelineCard td:nth-child(2)::before{ content:"Time"; }
  .timelineCard td:nth-child(3)::before{ content:"Duration"; }
  .timelineCard td:nth-child(4)::before{ content:"Sound Effect"; }
  .timelineCard td:nth-child(5)::before{ content:none; display:none; }

  .timelineCard td:nth-child(2),
  .timelineCard td:nth-child(3){
    white-space:nowrap;
    overflow-wrap:normal;
  }

  .timelineCard tbody td:first-child{
    font-weight:900;
    white-space:normal;
    overflow-wrap:break-word;
    line-height:1.2;
  }

  .timelineCard td:nth-child(4){
    align-items:center;
  }

  .timelineCard .soundChip{
    display:inline-flex;
    align-items:center;
    justify-content:flex-start;
    gap:8px;
    width:auto;
    min-width:0;
    max-width:100%;
    padding:5px 8px;
    white-space:normal;
    line-height:1.15;
    vertical-align:top;
  }

  .timelineCard .soundChipLabel{
    display:inline;
    min-width:0;
    overflow:visible;
    text-overflow:clip;
    white-space:normal;
    overflow-wrap:break-word;
    word-break:normal;
  }

  .timelineCard .soundChipIcon{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    flex:0 0 auto;
    width:auto;
    min-width:1rem;
  }

  .timelineCard td:nth-child(5){
    display:block;
    width:100%;
    max-width:100%;
    padding-left:0;
    white-space:normal;
    overflow-wrap:break-word;
    word-break:normal;
  }
}

@media (max-width: 420px) and (orientation: portrait){
  .timelineCard{
    padding:10px;
  }

  .timelineCard tr{
    padding:9px 10px 7px;
  }

  .timelineCard td{
    gap:8px;
    padding:7px 0;
  }

  .timelineCard td::before{
    flex:0 0 5.5rem;
    width:5.5rem;
    font-size:10px;
  }

  .timelineCard .soundChip{
    gap:6px;
    padding:4px 7px;
    font-size:11px;
  }
}


/* v51 - phone portrait settings alignment only */
@media (max-width: 700px) and (orientation: portrait){
  .settingsLayout{
    grid-template-columns:repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "schedule kiosk"
      "slider sound";
    gap:6px;
    align-items:stretch;
  }

  .settingsLeft{
    display:contents;
  }

  .scheduleWideBtn{grid-area:schedule;}
  #kioskBtn{grid-area:kiosk;}
  .sliderWrap{grid-area:slider;}
  .soundBig{
    grid-area:sound;
    width:100%;
    min-width:0;
    height:46px;
  }
}

@media (max-width: 420px) and (orientation: portrait){
  .soundBig{
    height:46px;
  }
}
