* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: Arial, sans-serif;
  background: #f3f5f7;
  color: #222;
}

img, iframe, video {
  max-width: 100%;
}

body {
  margin: 0;
}

.topbar {
  text-align: center;
  padding: 24px 16px 8px;
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  line-height: 1.15;
}

.topbar p {
  margin: 0;
  color: #555;
  font-size: 1rem;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 14px;
}

.box {
  border: 1px solid #333;
  border-radius: 18px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 140px;
  position: relative;
  overflow: hidden;
  width: 100%;
  min-width: 0;
  touch-action: manipulation;
}

.box:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.box.active {
  outline: 2px solid #222;
  transform: scale(1.02);
}

.box.static {
  cursor: default;
  opacity: 0.95;
}

.box.static:hover {
  transform: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.box.no-click {
  pointer-events: none;
  cursor: default;
}

.box.no-click:hover {
  transform: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.box-id {
  font-size: 1rem;
  font-weight: 800;
  position: relative;
  z-index: 1;
}

.box-title {
  position: relative;
  top: 45px;
  left: 70px;
  color: #333;
  background: #ddd;
  z-index: 1;
  font-size: 1.12rem;
  font-weight: 600;
  word-break: break-word;
}

.box-image {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  position: absolute;
  inset: 0;
  z-index: 0;
}

.box-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  z-index: 0;
}

.box-text {
  position: relative;
  z-index: 1;
  font-size: 0.9rem;
  margin-top: 8px;
  line-height: 1.45;
  max-width: 100%;
  word-break: break-word;
}

.box-html {
  position: relative;
  z-index: 1;
  font-size: 0.85rem;
  margin-top: 8px;
  line-height: 1.4;
  word-break: break-word;
}

.box-iframe {
  width: 100%;
  height: 100%;
  min-height: 120px;
  border: 0;
  border-radius: 12px;
  position: relative;
  z-index: 1;
  background: #fff;
}

.box-embed {
  position: relative;
  z-index: 1;
  width: 100%;
}

.box.span-2 {
  grid-column: span 2 !important;
}

.box.span-2-row {
  grid-row: span 2 !important;
}

.box.span-4 {
  grid-column: span 2 !important;
  grid-row: span 2 !important;
}

.box.span-6-cols {
  grid-column: span 3 !important;
  grid-row: span 2 !important;
}

.box.span-6-rows {
  grid-column: span 2 !important;
  grid-row: span 3 !important;
}

.rss-widget {
  width: 100%;
  height: 100%;
  overflow: auto;
  font-size: 0.85rem;
  text-align: left;
}

.rss-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.rss-item:last-child {
  border-bottom: 0;
}

.rss-item a {
  color: inherit;
  text-decoration: underline;
  font-weight: 700;
}

.rss-item p {
  margin: 4px 0 0;
  line-height: 1.35;
}

.gallery {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 240px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-image {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #000;
}

.gallery-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 52px;
  z-index: 3;
  padding: 8px 10px;
  color: #fff;
  font-size: 0.9rem;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  pointer-events: none;
}

.gallery-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  z-index: 4;
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.gallery-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.gallery-prev {
  left: 10px;
}

.gallery-next {
  right: 10px;
}