* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

body {
  background: #f4f6f9;
  color: #1e293b;
  min-height: 100vh;
}

.mosaica-chrome {
  background: #1e293b;
  color: #fff;
  padding: 0.75rem 1rem 1.25rem;
  text-align: center;
}

.mosaica-chrome__brand {
  max-width: 900px;
  margin: 0 auto;
}

.mosaica-chrome__logo {
  display: inline-block;
  line-height: 0;
}

.banner-logo {
  display: block;
  max-width: min(100%, 42rem);
  max-height: 8rem;
  width: auto;
  height: auto;
  margin: 0 auto 1rem;
}

.mosaica-chrome__links a {
  color: #38bdf8;
  text-decoration: none;
}

.mosaica-chrome__links a:hover {
  text-decoration: underline;
}

.mosaica-chrome__links {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

#mosaica-hud {
  max-width: 900px;
  margin: 0.5rem auto 0;
  text-align: center;
  font-size: 0.95rem;
}

#mosaica-timer {
  font-variant-numeric: tabular-nums;
  font-weight: bold;
  font-size: 1.1rem;
}

#mosaica-status {
  margin-top: 0.35rem;
  min-height: 1.25rem;
  font-size: 0.9rem;
  color: #cbd5e1;
}

.mosaica-puzzle-date {
  opacity: 0.85;
  font-size: 0.85rem;
}

.mosaica-main {
  max-width: 900px;
  margin: 1rem auto;
  padding: 0 1rem 2rem;
}

.mosaica-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.mosaica-btn {
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 5px;
  background: #38bdf8;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.85rem;
}

.mosaica-btn:hover {
  background: #0ea5e9;
}

.mosaica-btn--active {
  background: #f59e0b;
}

.mosaica-btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.mosaica-board-area {
  display: grid;
  justify-items: center;
  gap: 1.25rem;
}

.mosaica-board-wrap {
  display: contents;
}

#mosaica-grid {
  grid-row: 1;
  display: grid;
  gap: 4px;
  background: #cbd5e1;
  padding: 4px;
  border-radius: 6px;
  width: min(92vw, 420px);
}

.mosaica-tray-label {
  grid-row: 2;
  font-size: 0.85rem;
  color: #64748b;
  text-align: center;
  max-width: min(92vw, 420px);
  background: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.mosaica-tray-panel {
  grid-row: 3;
  width: 100%;
  max-width: 100%;
}

.mosaica-cell {
  aspect-ratio: 1;
  background: #e2e8f0;
  border-radius: 3px;
  cursor: grab;
  position: relative;
  min-height: 0;
  touch-action: none;
}

.mosaica-cell:active {
  cursor: grabbing;
}

.mosaica-cell--drop-target {
  outline: 2px dashed #38bdf8;
  outline-offset: -2px;
}

.mosaica-cell .mosaica-tile {
  width: 100%;
  height: 100%;
}

#mosaica-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 100%;
  padding: 0.5rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  min-height: 4rem;
}

.mosaica-tray-slot {
  width: 52px;
  height: 52px;
  cursor: grab;
  border-radius: 4px;
  border: 2px solid transparent;
  flex-shrink: 0;
  touch-action: none;
}

.mosaica-tray-slot:active {
  cursor: grabbing;
}

.mosaica-tray-slot--selected {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}

.mosaica-tray-slot--empty {
  visibility: hidden;
  pointer-events: none;
}

.mosaica-tile {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  overflow: hidden;
  user-select: none;
}

.mosaica-tri {
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 50%, var(--p1), var(--p2));
}

.mosaica-tri--top {
  --p1: 0% 0%;
  --p2: 100% 0%;
}

.mosaica-tri--right {
  --p1: 100% 0%;
  --p2: 100% 100%;
}

.mosaica-tri--bottom {
  --p1: 100% 100%;
  --p2: 0% 100%;
}

.mosaica-tri--left {
  --p1: 0% 100%;
  --p2: 0% 0%;
}

.mosaica-c0 { background: transparent; }
.mosaica-c1 { background: #ef4444; }
.mosaica-c2 { background: #22c55e; }
.mosaica-c3 { background: #3b82f6; }
.mosaica-c4 { background: #eab308; }
.mosaica-c5 { background: #e935ef; }

.mosaica-drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 52px;
  height: 52px;
  pointer-events: none;
  z-index: 10000;
  opacity: 0.92;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
}

#mosaica-tray.mosaica-tray--drop-target {
  outline: 2px dashed #38bdf8;
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .banner-logo {
    max-height: 5rem;
  }
}

@media (orientation: landscape) and (min-width: 520px) {
  .mosaica-board-area {
    --mosaica-tray-width: calc(3 * 52px + 2 * 6px + 1rem);
    --mosaica-grid-width: min(92vw, 420px);
    width: min(100%, calc(var(--mosaica-tray-width) + 1rem + var(--mosaica-grid-width)));
    grid-template-columns: var(--mosaica-tray-width) var(--mosaica-grid-width);
    grid-template-rows: auto auto;
    column-gap: 1rem;
    row-gap: 0.75rem;
    justify-items: stretch;
  }

  .mosaica-tray-label {
    grid-column: 1 / -1;
    grid-row: 1;
    max-width: none;
    width: 100%;
  }

  .mosaica-tray-panel {
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    width: auto;
    max-width: none;
  }

  #mosaica-grid {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    height: fit-content;
    align-self: start;
    justify-self: end;
    align-content: start;
  }

  #mosaica-tray {
    display: grid;
    grid-template-columns: repeat(3, 52px);
    justify-content: center;
    width: 100%;
    max-width: none;
    min-height: 0;
    overflow: visible;
  }
}
