* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inconsolata', monospace;
}

body {
  background: #2b2b3b;
  min-height: 100vh;
  font-family: 'Inconsolata', monospace;

  /* Column layout: wrapper grows, donate-hint always at bottom */
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- Side controls (hamburger + sound) ---- */
.side-controls {
  position: absolute;
  top: 0;
  right: -42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.hamburger,
.sound-btn {
  background: none;
  border: none;
  color: rgb(181, 181, 181);
  cursor: pointer;
  width: 36px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sound-btn {
  position: relative;
}

/* Diagonal cross when muted */
.sound-btn.muted::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 2px;
  background: rgb(181, 181, 181);
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* ---- Logo ---- */
.site-logo {
  width: 160px;
  height: auto;
}

/* ---- Wrapper: card-container + start button stacked vertically ---- */
.wrapper {
  display: flex;
  flex-direction: column;  /* stack children top-to-bottom */
  align-items: center;     /* center children horizontally */
  gap: 24px;
  margin: 24px;
}

/* ---- Card container: positions hamburger relative to the card ---- */
.card-container {
  position: relative;
  /* Width locked to start view's card size so it never changes between views */
  width: calc(
    2 * clamp(20px, 4vh, 40px) +
    clamp(80px, 17vh, 120px) +
    clamp(8px, 1.5vh, 12px) +
    clamp(14px, 2.5vh, 22px) +
    30px
  );
}

/* ---- Card ---- */
.card {
  width: 100%;
  background: #3a3a4a;
  border-radius: 16px;
  padding: clamp(20px, 4vh, 40px);

  /* Stack the 4 rows vertically */
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vh, 20px);
}

/* ---- Row: big box + small boxes side by side ---- */
.row {
  display: flex;
  flex-direction: row;   /* children side by side */
  align-items: center;   /* vertically center them */
  justify-content: center;
  gap: clamp(8px, 1.5vh, 12px);
}

/* ---- Big box ---- */
.big-box {
  width: clamp(80px, 17vh, 120px);
  height: clamp(80px, 17vh, 120px);
  border-radius: 10px;
  cursor: pointer;

  /* Center the label text */
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 14px;
  font-family: inherit;
  font-weight: bold;

  transition: opacity 0.2s;
}

/* ---- Small boxes: stack 4 dots vertically ---- */
.small-boxes {
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 1vh, 8px);
}

.small-box {
  width: clamp(14px, 2.5vh, 22px);
  height: clamp(14px, 2.5vh, 22px);
  border-radius: 6px;
  transition: opacity 0.2s;
}

/* ---- Colors per row (nth-child counts from 1) ---- */
.row:nth-child(1) .big-box,
.row:nth-child(1) .small-box { background: #e05555; }

.row:nth-child(2) .big-box,
.row:nth-child(2) .small-box { background: #55c55a; }

.row:nth-child(3) .big-box,
.row:nth-child(3) .small-box { background: #5577e0; }

.row:nth-child(4) .big-box,
.row:nth-child(4) .small-box { background: #e0c040; }

/* ---- Inactive = grayed out ---- */
.inactive {
  opacity: 0.2;
}

/* ---- Start button ---- */
.start-btn {
  width: 36px;
  height: 28px;
  font-size: 11px;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  background: rgb(181, 181, 181);
  cursor: pointer;
  margin-top: 6px;
}

.start-btn:hover {
  background: #ddd;
}

.reset-btn {
  width: 36px;
  height: 28px;
  font-size: 11px;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  background: rgb(181, 181, 181);
  cursor: pointer;
  margin-top: 4px;
}

.reset-btn:hover {
  background: #ddd;
}

/* ---- Menu ---- */
.menu {
  position: absolute;
  top: 0;
  right: 0;
  background: #3a3a4a;
  border: 1px solid rgb(110, 110, 110);
  border-radius: 16px;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  z-index: 10;
}

.menu-item {
  font-family: inherit;
  font-size: 16px;
  color: white;
  opacity: 0.4;
  cursor: pointer;
  white-space: nowrap;
}

.menu-item--active {
  opacity: 1;
  font-weight: bold;
}

.menu-divider {
  width: 100%;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.15);
  margin: 4px 0;
}

/* ---- Locked card (timer running) ---- */
.card.locked {
  pointer-events: none;
}

/* ---- Views ---- */
.view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.om-card {
  padding: 28px 32px;
}

.om-content {
  columns: 280px auto;
  column-gap: 32px;
}

.om-content h1,
.om-content h2 {
  break-after: avoid;
}

.om-content p,
.om-content blockquote {
  break-inside: avoid;
}

.om-h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
  letter-spacing: 0.5px;
}

.om-card h1 { color: #e05555; }


.om-h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 20px 0 6px;
  letter-spacing: 0.5px;
}

.om-card h2 { color: #5577e0; }

.om-p {
  color: white;
  font-size: 13px;
  line-height: 1.7;
  opacity: 0.75;
  margin: 0 0 10px;
}

.om-p strong {
  opacity: 1;
  font-weight: 700;
}

.tt {
  color: #e0c040;
  font-weight: 700;
  opacity: 1;
}

.om-quote {
  border-left: 3px solid rgba(255,255,255,0.2);
  margin: 12px 0 16px 8px;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.om-quote p {
  color: white;
  font-size: 13px;
  line-height: 1.6;
  opacity: 0.6;
  margin: 0;
  font-style: italic;
}

/* hidden utility class */
.hidden {
  display: none !important;
}

.start-btn.dimmed {
  opacity: 0.3;
  cursor: default;
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.small-box.pulse-top {
  animation: timer-pulse 1.5s ease-in-out infinite;
}

/* ---- Donate hint ---- */
.donate-hint {
  text-align: center;
  opacity: 0.25;
  transition: opacity 0.2s;
  padding: 4px 24px 16px;
}

.donate-hint:hover {
  opacity: 0.7;
}

.donate-hint p {
  color: white;
  font-size: 10px;
  margin-bottom: 6px;
  white-space: nowrap;
}

.donate-hint img {
  height: 28px;
  width: auto;
}

/* ---- Mät view ---- */
#mat-rows {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vh, 20px);
  width: 100%;
}

/* ---- Bygg layout ---- */
.bygg-layout {
  display: flex;
  flex-direction: row;
  gap: 16px;
  align-items: flex-start;
}

.bygg-right-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}


.card-container.bygg-mode {
  width: auto;
}

.card-container.om-mode {
  width: min(90vw, 960px);
}

.bygg-preview-card {
  min-width: calc(
    2 * clamp(20px, 4vh, 40px) +
    clamp(80px, 17vh, 120px) +
    clamp(8px, 1.5vh, 12px) +
    clamp(14px, 2.5vh, 22px) +
    30px
  );
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.bygg-builder-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: calc(
    2 * clamp(20px, 4vh, 40px) +
    clamp(80px, 17vh, 120px) +
    clamp(8px, 1.5vh, 12px) +
    clamp(14px, 2.5vh, 22px) +
    30px
  );
}

.bygg-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bygg-label {
  color: white;
  font-size: 13px;
}

.bygg-time-btn {
  background: #4a4a5a;
  border: 1px solid #666;
  border-radius: 6px;
  color: white;
  font-family: inherit;
  font-size: 13px;
  padding: 3px 8px;
  cursor: pointer;
  text-align: center;
  width: 4.4em;
}

.bygg-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.bygg-ctrl {
  background: #4a4a5a;
  border: none;
  border-radius: 8px;
  color: white;
  font-family: inherit;
  font-size: 13px;
  padding: 10px 6px;
  cursor: pointer;
}

.bygg-ctrl:hover {
  background: #5a5a6a;
}

.bygg-add-btn {
  background: #5577e0;
  border: none;
  border-radius: 8px;
  color: white;
  font-family: inherit;
  font-size: 13px;
  padding: 10px;
  cursor: pointer;
}

.bygg-add-btn:hover {
  background: #6688f0;
}

.bygg-markers-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.bygg-marker-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: white;
  font-size: 13px;
}

.bygg-marker-remove {
  background: none;
  border: none;
  color: rgb(181, 181, 181);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  margin-left: auto;
  line-height: 1;
}

.bygg-hint {
  color: white;
  font-size: 11px;
  opacity: 0.45;
  line-height: 1.5;
  margin-top: -6px;
  margin-bottom: auto;
}

.bygg-klar-btn {
  background: #55c55a;
  border: none;
  border-radius: 8px;
  color: white;
  font-family: inherit;
  font-size: 14px;
  padding: 10px;
  cursor: pointer;
}

.bygg-klar-btn:hover {
  background: #66d066;
}

.bygg-klar-btn:disabled {
  opacity: 0.3;
  cursor: default;
}


/* ---- Bygg preview rows (same structure as start view) ---- */
#bygg-preview-content {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vh, 20px);
  align-items: flex-start;
}

.bygg-preview-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: clamp(8px, 1.5vh, 12px);
}


/* Modifier on .big-box for bygg: show hour+time top/bottom */
.bygg-big-box {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  cursor: default;
}

.bygg-slot-col {
  display: grid;
  grid-template-columns: clamp(14px, 2.5vh, 22px) auto;
  column-gap: 6px;
  row-gap: clamp(5px, 1vh, 8px);
  align-items: center;
}

.bygg-slot-row {
  display: contents;
}

.bygg-hour-num {
  font-size: 16px;
  font-weight: bold;
  font-family: inherit;
  color: white;
}

.bygg-time-lbl {
  font-size: 11px;
  font-family: inherit;
  color: rgba(255, 255, 255, 0.5);
}

.bygg-emoji-slot {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bygg-marker-entry {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  line-height: 1;
}

.timer-active .bygg-marker-entry {
  font-size: 20px;
}

.bygg-marker-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.bygg-empty {
  color: white;
  opacity: 0.4;
  font-size: 13px;
  padding: 8px 0;
  align-self: center;
  
}

/* ---- Emoji popup ---- */
.emoji-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #3a3a4a;
  border: 1px solid #666;
  border-radius: 16px;
  padding: 16px;
  z-index: 100;
  flex-direction: column;
  gap: 12px;
  width: 280px;
}

.emoji-popup:not(.hidden) {
  display: flex;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.emoji-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: 6px;
  font-size: 20px;
  cursor: pointer;
  padding: 2px;
  line-height: 1;
}

.emoji-btn.selected {
  border-color: #5577e0;
  background: rgba(85, 119, 224, 0.2);
}

.emoji-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.emoji-time-label {
  color: white;
  font-size: 13px;
}

.emoji-time-input {
  background: #4a4a5a;
  border: 1px solid #666;
  border-radius: 6px;
  color: white;
  font-size: 13px;
  padding: 4px 8px;
  width: 70px;
}

.emoji-text-input {
  background: #4a4a5a;
  border: 1px solid #666;
  border-radius: 6px;
  color: white;
  font-size: 13px;
  padding: 4px 8px;
  width: 80px;
}

.emoji-popup-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.emoji-cancel-btn {
  background: none;
  border: 1px solid #666;
  border-radius: 8px;
  color: white;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
}

.emoji-confirm-btn {
  background: #5577e0;
  border: none;
  border-radius: 8px;
  color: white;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
}

.emoji-confirm-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ---- Mobile ---- */
@media (max-width: 520px) {
  .wrapper {
    margin: 12px;
    gap: 12px;
  }

  .card {
    padding: 10px;
    gap: 10px;
  }

  .card-container.om-mode {
    width: calc(
      2 * clamp(20px, 4vh, 40px) +
      clamp(80px, 17vh, 120px) +
      clamp(8px, 1.5vh, 12px) +
      clamp(14px, 2.5vh, 22px) +
      30px
    );
  }

  .row {
    gap: 8px;
  }

  .bygg-layout {
    flex-direction: column-reverse;
  }

  .emoji-popup {
    width: calc(100vw - 32px);
  }

  .emoji-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}
