*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 20px;
  --control-stack-gap: 0.35rem;
  --board-gap: 6px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #000;
  color: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
}

.container {
  margin: 0;
  padding: 0.45rem 0.55rem 0.65rem;
  width: fit-content;
  max-width: 100%;
  overflow-x: visible;
}

.app-stack {
  width: fit-content;
  max-width: 100%;
}

header {
  text-align: left;
  margin-bottom: 0.45rem;
}

h1 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.display-date {
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
  color: #aaa;
  letter-spacing: 0.02em;
}

.control-row {
  display: flex;
  gap: 0.35rem;
  width: fit-content;
}

fieldset {
  border: 1px solid #444;
  border-radius: 4px;
  margin: 0;
  padding: 0.32rem 0.48rem 0.42rem;
  width: fit-content;
}

legend {
  padding: 0 0.2rem;
  color: #ccc;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.78rem;
  white-space: nowrap;
}

.hosts-grid {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 0.24rem 0.55rem;
}

.misc-stack {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.controls,
.game,
.suggest-section {
  width: 100%;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid #666;
  background: #111;
  color: #fff;
  padding: 0.4rem 0.55rem;
}

button:hover:not(:disabled):not(.cell):not(.instant-win-cell) {
  background: #222;
  border-color: #888;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.primary-btn {
  width: 100%;
  margin-top: var(--control-stack-gap);
  font-weight: 600;
  font-size: 0.85rem;
  border-color: #fff;
}

.status-msg {
  min-height: 1rem;
  margin: 0.3rem 0 0;
  font-size: 0.75rem;
  color: #f88;
}

.status-msg:empty {
  min-height: 0;
  margin: 0;
}

.game {
  margin-top: var(--control-stack-gap);
  min-width: 0;
}

.grid-column {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--board-gap);
}

.bingo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--board-gap);
  width: 100%;
  min-width: 0;
}

.instant-win-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: auto;
  margin-top: calc(0.65rem * 1.25 / 2 + 1px);
  padding: 0.38rem 0.48rem 0.42rem;
  border: 1px solid #ff00ff;
  border-radius: 4px;
  background: #111;
  color: #fff;
  text-align: center;
  line-height: 1.1;
  cursor: pointer;
  overflow: visible;
  min-width: 0;
  min-height: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.instant-win-legend {
  position: absolute;
  top: 0;
  left: 0.48rem;
  transform: translateY(-50%);
  padding: 0 0.2rem;
  background: #000;
  border: 1px solid #ff00ff;
  border-radius: 2px;
  color: #ff00ff;
  font-size: 0.65rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.25;
  pointer-events: none;
  z-index: 1;
}

.instant-win-cell:hover:not(.instant-win-marked) {
  background: #1a1a1a;
  border-color: #ff66ff;
}

.instant-win-cell:hover:not(.instant-win-marked) .instant-win-legend {
  border-color: #ff66ff;
}

.cell {
  aspect-ratio: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.24rem;
  border: 1px solid #555;
  background: #111;
  text-align: center;
  line-height: 1.1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.cell-text {
  display: block;
  width: 100%;
  max-height: 100%;
  hyphens: none;
  word-break: normal;
  overflow-wrap: normal;
}

.cell:hover:not(.marked) {
  background: #222;
  border-color: #888;
}

.cell.marked,
.cell.marked:hover {
  background: #ff8800;
  color: #000;
  border-color: #ff8800;
}

.instant-win-cell.instant-win-marked,
.instant-win-cell.instant-win-marked:hover {
  background: #ff00ff;
  color: #000;
  border-color: #ff00ff;
}

.instant-win-cell.instant-win-marked .instant-win-legend {
  background: #000;
  color: #ff00ff;
  border-color: #ff00ff;
}

.confirm-btn {
  display: block;
  width: 100%;
  font-weight: 700;
  letter-spacing: 0.03em;
  font-size: 0.8rem;
  padding: 0.45rem;
}

.confirm-btn[hidden] {
  display: none;
}

.confirm-btn.turbo-bingo {
  background: linear-gradient(
    90deg,
    #ff0000,
    #ff8800,
    #ffee00,
    #00dd44,
    #0088ff,
    #aa44ff,
    #ff0000
  );
  background-size: 200% 100%;
  animation: turbo-rainbow 2.5s linear infinite;
  color: #000;
  border-color: #fff;
  font-weight: 800;
}

.confirm-btn.turbo-bingo:hover:not(:disabled) {
  background: linear-gradient(
    90deg,
    #ff0000,
    #ff8800,
    #ffee00,
    #00dd44,
    #0088ff,
    #aa44ff,
    #ff0000
  );
  background-size: 200% 100%;
  filter: brightness(1.08);
}

@keyframes turbo-rainbow {
  0% {
    background-position: 0% 50%;
  }

  100% {
    background-position: 200% 50%;
  }
}

.share-block {
  display: none;
}

.share-block.is-visible {
  display: block;
}

.victory-entry + .victory-entry {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #333;
}

.share-message {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  word-break: break-word;
  cursor: pointer;
}

.share-message:hover {
  color: #ddd;
}

#instant-win-message {
  color: #ff00ff;
}

#instant-win-message:hover {
  color: #ff66ff;
}

.copy-btn {
  width: 100%;
  font-size: 0.75rem;
  text-align: left;
}

.copy-feedback {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: #8f8;
  min-height: 1rem;
}

.suggest-section {
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid #333;
}

.suggest-label {
  display: block;
  font-size: 0.78rem;
  color: #ccc;
  margin-bottom: 0.3rem;
}

.suggest-row {
  display: flex;
  gap: 0.3rem;
}

.suggest-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.35rem 0.45rem;
  border-radius: 4px;
  border: 1px solid #555;
  background: #111;
  color: #fff;
}

.suggest-input:focus {
  outline: none;
  border-color: #888;
}

.suggest-input:disabled {
  opacity: 0.5;
}

.suggest-submit {
  flex-shrink: 0;
  font-size: 0.78rem;
  white-space: nowrap;
}

.suggest-feedback {
  min-height: 1rem;
  margin: 0.3rem 0 0;
  font-size: 0.72rem;
  color: #bbb;
}

.suggest-feedback.suggest-success {
  color: #8f8;
}

.suggest-feedback.suggest-error {
  color: #f88;
}

@media (max-width: 380px) {
  h1 {
    font-size: 1.55rem;
  }

  .hosts-grid {
    grid-template-columns: repeat(2, auto);
  }
}
