@font-face {
  font-family: 'TAYBang';
  src: url('../assets/fonts/TAYBang!.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #faf6f0;
  --text: #3d3229;
  --accent-sage: #8a9a7b;
  --accent-rose: #c4a08a;
  --accent-gold: #c9a84c;
  --border: #6b5744;
  --square-size: 90px;
  --font-display: 'TAYBang', 'Caveat', cursive;
  --font-body: 'Geist Mono', monospace;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  border-bottom: 2px dashed var(--border);
}

header h1 {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: normal;
  color: var(--text);
  -webkit-text-stroke: 0;
}

.subtitle {
  font-style: italic;
  color: var(--text);
  margin-top: 0.25rem;
}

main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Quilt Grid */
.quilt-container {
  margin-bottom: 3rem;
}

.quilt-grid {
  display: inline-grid;
  grid-template-columns: repeat(auto-fit, var(--square-size));
  gap: 0;
  max-width: 600px;
  border-top: 2px dashed var(--border);
  border-left: 2px dashed var(--border);
}

.quilt-grid:empty {
  border: none;
}

.quilt-container {
  text-align: center;
}


.quilt-empty {
  text-align: center;
  font-style: italic;
  color: var(--accent-rose);
  padding: 3rem 1rem;
}

.quilt-square {
  aspect-ratio: 1;
  position: relative;
  border-right: 2px dashed var(--border);
  border-bottom: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

.quilt-square:nth-child(odd) {
  transform: rotate(-0.5deg);
}

.quilt-square:nth-child(3n) {
  transform: rotate(0.8deg);
}

.quilt-square:nth-child(5n+2) {
  transform: rotate(-0.3deg);
}

.quilt-square img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.quilt-square .square-overlay {
  position: absolute;
  inset: 0;
  background: rgba(61, 50, 41, 0.88);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  font-size: clamp(0.45rem, 1.2vw, 0.65rem);
  line-height: 1.3;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  word-break: break-word;
  overflow-y: auto;
}

.quilt-square:hover .square-overlay,
.quilt-square:focus .square-overlay {
  opacity: 1;
}

/* Submission Form */
.submission-form {
  padding-top: 2rem;
}

.submission-form h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: normal;
  -webkit-text-stroke: 0;
  margin-bottom: 1.5rem;
  text-align: center;
  color: #74c0fd;
}

#square-form {
  max-width: 500px;
  margin: 0 auto;
}

.icon-picker {
  border: none;
  margin-bottom: 1.5rem;
}

.icon-picker legend {
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: block;
}

.icon-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.icon-option {
  position: relative;
}

.icon-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.icon-option label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border: 2px dashed var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, transform 0.2s;
}

.icon-option label:hover {
  border-color: #74c0fd;
  background-color: rgba(138, 154, 123, 0.1);
}

.icon-option input[type="radio"]:checked + label {
  border-color: var(--accent-gold);
  background-color: rgba(201, 168, 76, 0.15);
  border-style: solid;
  transform: scale(1.08);
}

.icon-option label img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.text-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.textarea-wrap {
  position: relative;
  margin-bottom: 1.5rem;
}

.textarea-wrap textarea {
  width: 100%;
  padding: 0.75rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  border: 2px dashed var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  resize: vertical;
  min-height: 80px;
}

.textarea-wrap textarea:focus {
  outline: none;
  border-color: #74c0fd;
  border-style: solid;
}

.char-count {
  position: absolute;
  bottom: 0.5rem;
  right: 0.75rem;
  font-size: 0.75rem;
  color: var(--accent-rose);
}

.submit-btn {
  display: block;
  width: 100%;
  padding: 1.1rem 1.5rem 0.5rem;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--bg);
  background-color: #74c0fd;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  line-height: 1;
}

.submit-btn:hover {
  background-color: #5aaee6;
}

.submit-btn:active {
  transform: scale(0.98);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-error {
  margin-top: 1rem;
  color: #a04040;
  font-size: 0.9rem;
  text-align: center;
}

.form-success {
  margin-top: 1rem;
  color: #74c0fd;
  font-size: 0.9rem;
  text-align: center;
  font-weight: 600;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  border-top: 2px dashed var(--border);
  font-style: italic;
  color: var(--accent-rose);
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 600px) {
  :root {
    --square-size: 70px;
  }

  .quilt-grid {
    grid-template-columns: repeat(5, var(--square-size));
  }

  header h1 {
    font-size: 2.2rem;
  }

  .icon-option label {
    width: 50px;
    height: 50px;
  }

  .icon-option label img {
    width: 32px;
    height: 32px;
  }
}
