* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "Helvetica Neue", Arial, sans-serif;
  background-color: #ffcd00;
  color: #000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

body.index-page {
  height: auto;
  min-height: 100lvh;
  background: #fff;
  color: #000;
}

body:not(.display-page):not(.index-page) {
  overflow-y: auto;
}

body.display-page {
  overflow: hidden;
  align-items: stretch;
  padding: 0;
}

h1,
h2 {
  margin: 0 0 1.5rem;
  font-weight: 700;
  text-align: center;
}

p {
  margin: 0 0 1rem;
  line-height: 1.5;
}

.container {
  background: #ffcd00;
  border-radius: 16px;
  padding: 16px;
  width: 100%;
  max-width: 480px;
}

.index-wrapper {
  width: 100%;
  min-height: 100lvh;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  background-image: url("../images/background.png");
  background-size: cover;
  background-position: center center;
}

.index-card {
  position: relative;
}

.index-card-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  padding: 20px 20px 20px;
}

.brand-line {
  display: flex;
  width: 100%;
  margin-bottom: 20px;
}

.brand-line img {
  max-width: 70%;
  height: auto;
}

.brand-sub {
  font-weight: 600;
}

.index-page .field-label {
  display: block;
  font-weight: normal;
  margin-bottom: 16px;
  color: #111827;
  font-size: 19px;
}

.index-page .field-group {
  margin-bottom: 0;
}

.index-page .form-control {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #000;
  border-radius: 0;
  color: #111827;
  padding: 8px 12px;
  font-size: 16px;
  line-height: 1.5em;
}

.index-page .form-control:focus {
  border-color: #727272;
  box-shadow: 0 0 0 0px;
}

.index-page .form-control::placeholder {
  color: #959595;
}

.index-page textarea.form-control {
  height: 100px;
  resize: none;
}

.index-page .char-counter {
  color: #4b5563;
  font-size: 0.85rem;
  text-align: right;
}

.index-page .char-counter.over-limit {
  color: #d32f2f;
}

.index-page #message-form {
  display: flex;
  flex-direction: column;
  padding: 8px 24px;
  gap: 16px;
  max-width: 400px;
  width: 100%;
}

.index-page .btn {
  border-radius: 0;
  background: #111827;
  color: #ffffff;
  font-weight: 700;
  margin-top: 16px;
  padding: 12px 64px;
  font-size: 16px;
  width: fit-content;
  align-self: center;
}

.index-page .btn:hover:not(:disabled) {
  opacity: 0.95;
}

#success-view {
  width: 100%;
  min-height: 100lvh;
}

#success-view .index-card-inner {
  height: 100lvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px 20px 40px;
}

.success-card {
  background: #f7cf28;
  color: #000;
  text-align: center;
}

.success-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  gap: 24px;
}

.success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-card h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.success-card p {
  margin: 0;
  font-size: 20px;
  line-height: 1.6;
}

.success-card .btn {
  align-self: center;
  border-radius: 0;
  background: #111827;
  color: #ffffff;
  font-weight: 700;
  margin-top: 16px;
  padding: 12px 64px;
  font-size: 16px;
}

.field-group {
  margin-bottom: 1.5rem;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: 12px;
  border: 1px solid #000;
  background-color: #fff;
  color: #000;
  font-size: 16px;
}

.char-counter {
  font-size: 12px;
  color: #94a3b8;
  text-align: right;
}

.char-counter.over-limit {
  color: #f87171;
  font-weight: 600;
}

.form-control:focus {
  border-color: #38bdf8;
  outline: none;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}

textarea.form-control {
  height: 80px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 8px 24px;
  border-radius: 9999px;
  border: none;
  color: #000;
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease;
}

.btn:hover:not(:disabled) {
  opacity: 0.95;
}

.btn:disabled {
  cursor: not-allowed;
}

.hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Display page styles */
#marquee-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #ffcd00;
}

.marquee-message {
  position: absolute;
  left: 0;
  display: flex;
  align-items: center;
  white-space: nowrap;
  padding: 0 4vw;
  animation-name: marquee-left;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  transition: all 0.45s ease;
  opacity: 0;
  will-change: transform, top, opacity;
}

.marquee-message.removing {
  opacity: 0;
}

@keyframes marquee-left {
  from {
    transform: translateX(100vw);
  }
  to {
    transform: translateX(-120%);
  }
}

.msg-level-1 {
  font-size: 60px;
  color: #000;
  background-color: #fb9ab2;
  font-weight: bold;
  padding: 32px 24px 40px;
}

.msg-level-2 {
  font-size: 42px;
  color: #fff;
  background-color: #fe4714;
  font-weight: bold;
  padding: 20px 20px 24px;
}

.msg-level-3 {
  font-size: 28px;
  color: #fff;
  background-color: #000000;
  font-weight: bold;
  padding: 16px 16px 20px;
}

.msg-level-4 {
  font-size: 20px;
  color: #000;
  font-weight: bold;
}

#sparkle-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 0;
}

.sparkle {
  width: 28vw;
  height: 28vw;
  position: absolute;
  background-image: url("../images/sparkle.png");
  background-size: contain;
  background-repeat: no-repeat;
}

.sparkle:nth-child(1) {
  top: 3%;
  left: 3%;
}

.sparkle:nth-child(2) {
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
}

.sparkle:nth-child(3) {
  right: 4%;
  top: 40%;
  transform: translateY(-50%);
}

#qrcode-card {
  position: absolute;
  bottom: 24px;
  left: 24px;
  background: #ffffff;
  padding: 12px;
  border-radius: 12px;
  text-align: center;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0px;
}

#qrcode-card img {
  width: max(10vw, 120px);
  height: auto;
}

#qrcode-card p {
  font-size: 20px;
  color: #000;
  font-weight: bold;
  margin: 0;
  padding: 0;
}

/* Admin page styles */

.admin-controls {
  display: flex;
}

#message-list {
  display: flex;
  margin-top: 24px;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.message-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  background: #ffffff91;
  border: 1px solid #fff;
}

.message-content {
  flex: 1;
  color: #000000;
  line-height: 1.4;
}

.message-meta {
  display: block;
  font-size: 0.85rem;
  color: #9f9f9f;
  margin-bottom: 0.35rem;
}

.delete-btn {
  padding: 0.5rem 0.9rem;
  border-radius: 9999px;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  color: #ff6c6c;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.delete-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ff6c6c;
}

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