:root {
  color-scheme: light;
  --red: #cf1024;
  --red-dark: #ae001a;
  --navy: #0d3b6e;
  --ink: #162b49;
  --muted: #5d6c84;
  --ivory: #faf8f3;
  font-family: "Be Vietnam Pro", "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
}

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

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--ink);
  background: var(--ivory);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button,
select,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   App Shell, Trống Đồng Watermark & Vector Top/Bottom Waves
   ========================================================================== */

.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background-color: var(--ivory);
}

.app-shell::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  bottom: auto;
  width: min(100%, 150vh);
  aspect-ratio: 1586 / 992;
  transform: translate(-50%, -50%);
  z-index: 0;
  pointer-events: none;
  background: url("background.png") center center / 100% 100% no-repeat;
  mix-blend-mode: multiply;
  opacity: 0.92;
  filter: saturate(1.08) contrast(1.02);
  -webkit-mask-image: radial-gradient(
    ellipse 39% 31.5% at 50% 50%,
    #000 55%,
    rgba(0, 0, 0, 0.54) 77%,
    transparent 100%
  );
  mask-image: radial-gradient(
    ellipse 39% 31.5% at 50% 50%,
    #000 55%,
    rgba(0, 0, 0, 0.54) 77%,
    transparent 100%
  );
}

.top-banner {
  position: relative;
  z-index: 2;
  isolation: isolate;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: clamp(110px, 17vh, 168px);
  padding: clamp(10px, 1.7vh, 18px) clamp(24px, 4vw, 64px) clamp(24px, 3.8vh, 42px) clamp(28px, 6vw, 98px);
  color: #ffffff;
  background: transparent;
}

.banner-wave-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 3px 8px rgba(120, 0, 12, 0.12));
}

.header-brand {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  cursor: pointer;
}

.service-emblem {
  display: block;
  flex: 0 0 auto;
  width: clamp(58px, min(6.6vw, 10.4vh), 98px);
  height: auto;
  color: #ffffff;
}

.brand-separator {
  flex: 0 0 2px;
  height: clamp(46px, 7.6vh, 78px);
  margin-left: clamp(16px, min(2vw, 3.2vh), 32px);
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.92);
}

.brand-copy {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: clamp(16px, min(2vw, 3.2vh), 32px);
}

.agency-name {
  font-size: clamp(20px, min(2.65vw, 4.2vh), 40px);
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: 0.015em;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(90, 0, 10, 0.14);
}

.service-name {
  margin-top: 3px;
  font-size: clamp(13px, min(1.52vw, 2.42vh), 24px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.014em;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(90, 0, 10, 0.12);
}

.settings-open-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: clamp(48px, min(5vw, 7.8vh), 72px);
  height: clamp(48px, min(5vw, 7.8vh), 72px);
  margin-left: clamp(12px, 1.6vw, 24px);
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: clamp(12px, min(1.25vw, 1.95vh), 18px);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.settings-open-button svg {
  display: block;
  width: 58%;
  height: 58%;
}

@media (hover: hover) {
  .settings-open-button:hover {
    border-color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
  }
}

.settings-open-button:active {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(0.96);
}

.bottom-wave {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: clamp(64px, 11vh, 118px);
  z-index: 0;
  pointer-events: none;
}

.bottom-wave-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.main-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 0 3.5vw clamp(14px, 2.4vh, 28px);
}

.screen {
  width: 100%;
}

/* ==========================================================================
   Rating Screen (Primary Kiosk View)
   ========================================================================== */

.rating-screen {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 0;
  padding-top: 0;
  text-align: center;
}

.title-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 2.5vw, 40px);
  width: 100%;
  margin-top: clamp(-12px, -1.3vh, -4px);
  margin-bottom: clamp(4px, 0.8vh, 10px);
}

.title-rule > span {
  flex: 0 1 clamp(110px, 18.5vw, 285px);
  border-top: 1.5px solid rgba(196, 35, 44, 0.55);
}

.feedback-badge {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: clamp(68px, min(6.6vw, 10.6vh), 96px);
  height: clamp(56px, min(5.4vw, 8.6vh), 76px);
  border: 1px solid rgba(220, 226, 236, 0.7);
  border-radius: clamp(16px, 1.5vw, 22px);
  background: #ffffff;
  box-shadow: 0 6px 20px rgba(20, 38, 68, 0.09);
}

.feedback-emblem {
  display: block;
  width: 62%;
  height: 62%;
  padding: 0;
  color: var(--red);
  background: none;
  box-shadow: none;
}

#rating-title,
.rating-screen h1 {
  margin: 0;
  color: #0d3b6e;
  font-size: clamp(26px, min(3.35vw, 5.35vh), 50px);
  font-weight: 800;
  line-height: 1.16;
  letter-spacing: -0.012em;
}

.intro-copy {
  max-width: 1180px;
  margin: clamp(5px, 0.85vh, 10px) 0 clamp(8px, 1.35vh, 14px);
  color: #253c59;
  font-size: clamp(15px, min(1.58vw, 2.52vh), 23px);
  font-style: italic;
  font-weight: 400;
  line-height: 1.32;
}

.service-location {
  margin: 0 0 clamp(10px, 1.8vh, 18px);
  padding: 7px 22px;
  border: 1px solid rgba(18, 61, 131, 0.10);
  border-radius: 999px;
  color: #162b49;
  background: #ffffff;
  box-shadow: 0 3px 12px rgba(18, 45, 82, 0.07);
  font-size: clamp(13px, min(1.2vw, 1.92vh), 18px);
  font-weight: 700;
  line-height: 1.35;
}

.rating-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(10px, 1.25vw, 20px);
  width: min(88vw, 144vh, 1220px);
}

.rating-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.35vh, 14px);
  min-width: 0;
  min-height: clamp(164px, 25vh, 232px);
  padding: clamp(12px, 1.7vh, 18px) 10px clamp(12px, 1.8vh, 20px);
  border: 1.5px solid var(--card-border);
  border-radius: clamp(15px, 1.3vw, 20px);
  color: var(--card-ink);
  background: var(--card-bg);
  box-shadow: 0 5px 15px rgba(24, 39, 64, 0.045);
  cursor: pointer;
  transition:
    transform 0.16s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.16s ease,
    border-color 0.16s ease;
}

@media (hover: hover) {
  .rating-card:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 11px 24px rgba(20, 38, 68, 0.10);
  }
}

.rating-card:active:not(:disabled) {
  transform: translateY(0) scale(0.975);
  box-shadow: 0 3px 9px rgba(20, 38, 68, 0.09);
}

.rating-card:disabled {
  opacity: 0.86;
  cursor: default;
}

.rating-card.selected {
  border-width: 2.5px;
  border-color: var(--card-ink);
  transform: translateY(-2px);
  box-shadow:
    0 10px 24px rgba(13, 59, 110, 0.12),
    0 0 0 4px rgba(13, 59, 110, 0.10);
}

.rating-1 {
  --card-bg: #fceeee;
  --card-border: #e6bfc3;
  --card-ink: #9c2229;
}

.rating-2 {
  --card-bg: #fdf3e7;
  --card-border: #e6ccb0;
  --card-ink: #8f4e1c;
}

.rating-3 {
  --card-bg: #fefbe6;
  --card-border: #e6dc9c;
  --card-ink: #705914;
}

.rating-4 {
  --card-bg: #ebf3fc;
  --card-border: #aec6e6;
  --card-ink: #15407a;
}

.rating-5 {
  --card-bg: #f3edfb;
  --card-border: #cbbbe2;
  --card-ink: #5a2b78;
}

.face {
  display: block;
  position: relative;
  flex: 0 0 auto;
  width: clamp(72px, min(7.6vw, 12.2vh), 112px);
  aspect-ratio: 1;
  overflow: visible;
  border-radius: 0;
  background: transparent;
}

.face img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: contain;
}

.face-with-rays {
  overflow: visible;
}

.face-rays {
  position: absolute;
  top: -5%;
  right: -5%;
  display: block;
  width: 36%;
  height: 36%;
  overflow: visible;
}

.rating-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.32em;
  font-size: clamp(16px, min(1.68vw, 2.68vh), 24px);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.01em;
  text-align: center;
}

.thanks-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.1vw, 16px);
  width: min(82vw, 860px);
  margin-top: clamp(14px, 2.7vh, 28px);
  color: #0d3b6e;
  font-size: clamp(18px, min(1.95vw, 3.1vh), 28px);
  font-style: italic;
  white-space: nowrap;
}

.thanks-line::before,
.thanks-line::after {
  content: "";
  flex: 1 1 auto;
  border-top: 1px solid rgba(18, 61, 131, 0.28);
}

.thanks-line strong {
  flex: 0 0 auto;
  color: #0d3b6e;
  font-weight: 800;
  font-style: italic;
}

.check-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: clamp(32px, min(3.2vw, 5.1vh), 46px);
  aspect-ratio: 1;
  border-radius: 50%;
  color: #ffffff;
  background: #1dc14e;
  box-shadow: 0 3px 10px rgba(29, 193, 78, 0.24);
  font-size: clamp(18px, min(1.85vw, 2.95vh), 26px);
  font-style: normal;
  font-weight: 900;
  line-height: 1;
}

.rating-submit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 0.9vh, 10px);
  min-height: 0;
  margin-top: clamp(10px, 1.6vh, 18px);
}

.selection-summary {
  color: #162b49;
  font-size: clamp(14px, min(1.3vw, 2.05vh), 19px);
  font-weight: 700;
  line-height: 1.25;
}

.selection-summary.error {
  color: #b51c2b;
}

.send-rating-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: clamp(240px, 24vw, 360px);
  min-height: clamp(48px, 6.6vh, 64px);
  padding: 10px 28px;
  border: 0;
  border-radius: clamp(14px, 1.2vw, 18px);
  color: #ffffff;
  background: linear-gradient(105deg, #df102d, #bd001d);
  box-shadow: 0 6px 18px rgba(194, 0, 28, 0.22);
  font-size: clamp(17px, min(1.65vw, 2.6vh), 24px);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.send-rating-button svg {
  display: block;
  flex: 0 0 auto;
  width: clamp(20px, 1.8vw, 26px);
  height: clamp(20px, 1.8vw, 26px);
}

@media (hover: hover) {
  .send-rating-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 9px 22px rgba(194, 0, 28, 0.28);
    filter: brightness(1.03);
  }
}

.send-rating-button:active:not(:disabled) {
  transform: scale(0.98);
}

.send-rating-button:disabled {
  opacity: 0.72;
  cursor: wait;
}

/* ==========================================================================
   Thank You Screen
   ========================================================================== */

.thank-you-screen {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: clamp(10px, 2vh, 22px) 12px clamp(16px, 3vh, 28px);
  text-align: center;
}

.thank-you-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 760px);
  padding: clamp(22px, 3.6vh, 38px) clamp(20px, 3vw, 42px);
  border: 1px solid rgba(18, 61, 131, 0.10);
  border-radius: clamp(22px, 2.2vw, 32px);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 14px 36px rgba(20, 38, 68, 0.09);
}

.thank-you-check {
  display: grid;
  place-items: center;
  width: clamp(72px, min(7.6vw, 12vh), 108px);
  aspect-ratio: 1;
  border-radius: 50%;
  color: #ffffff;
  background: #1dc14e;
  box-shadow: 0 8px 20px rgba(29, 193, 78, 0.22);
}

.thank-you-check svg {
  display: block;
  width: 64%;
  height: 64%;
}

.thank-you-screen h1 {
  margin: clamp(12px, 2vh, 18px) 0 0;
  color: var(--navy);
  font-size: clamp(26px, min(3.4vw, 5.4vh), 48px);
  font-weight: 800;
  line-height: 1.16;
}

.thank-you-copy {
  margin: 8px 0 0;
  color: #253c59;
  font-size: clamp(16px, min(1.65vw, 2.6vh), 23px);
  line-height: 1.35;
}

.countdown-instruction {
  margin: clamp(14px, 2.4vh, 24px) 0 6px;
  color: var(--muted);
  font-size: clamp(15px, min(1.4vw, 2.2vh), 20px);
}

.countdown-display {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  min-width: 120px;
  color: var(--red);
}

.countdown-display strong {
  font-size: clamp(40px, min(4.8vw, 7.6vh), 64px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.countdown-display span {
  color: #8b1730;
  font-size: clamp(18px, min(1.7vw, 2.7vh), 24px);
  font-weight: 800;
}

.return-home-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(100%, 400px);
  min-height: clamp(52px, 7.2vh, 66px);
  margin-top: clamp(14px, 2.4vh, 24px);
  padding: 10px 24px;
  border: 0;
  border-radius: 18px;
  color: #ffffff;
  background: linear-gradient(105deg, #df102d, #bd001d);
  box-shadow: 0 7px 18px rgba(194, 0, 28, 0.22);
  font-size: clamp(17px, min(1.65vw, 2.6vh), 23px);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.return-home-button svg {
  display: block;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
}

@media (hover: hover) {
  .return-home-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(194, 0, 28, 0.28);
  }
}

.return-home-button:active {
  transform: scale(0.985);
}

/* ==========================================================================
   Settings Screen & Commune Picker Modal
   ========================================================================== */

.settings-screen {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 0;
  width: min(80vw, 1040px);
  margin: 0 auto;
  padding: 0 0 clamp(10px, 1.8vh, 20px);
}

.settings-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 0.5vh, 6px);
  margin-top: clamp(-8px, -1vh, -2px);
  margin-bottom: clamp(8px, 1.5vh, 16px);
  color: var(--navy);
}

.settings-title-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 2.8vw, 44px);
  width: min(56vw, 680px);
  height: clamp(42px, 6.4vh, 62px);
}

.settings-title-rule > span {
  flex: 1 1 auto;
  border-top: 1.5px solid rgba(196, 35, 44, 0.55);
}

.settings-heading-icon {
  display: block;
  flex: 0 0 auto;
  width: clamp(38px, min(4.2vw, 6.4vh), 58px);
  height: auto;
  color: var(--red);
}

.settings-heading h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(24px, min(2.85vw, 4.5vh), 42px);
  font-weight: 800;
  line-height: 1.15;
}

.settings-card {
  position: relative;
  width: 100%;
  padding: clamp(44px, 6.2vh, 60px) clamp(18px, 2.6vw, 36px) 8px;
  border: 1px solid rgba(18, 61, 131, 0.12);
  border-radius: clamp(18px, 1.8vw, 26px);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 26px rgba(20, 38, 68, 0.06);
}

.card-tab {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: clamp(8px, 0.9vw, 14px);
  min-height: clamp(38px, 5.4vh, 52px);
  padding: 0 clamp(16px, 2vw, 28px);
  border-radius: clamp(17px, 1.7vw, 25px) 0 clamp(16px, 1.6vw, 22px) 0;
  color: #ffffff;
  background: linear-gradient(105deg, #df102d, #be001c);
  font-size: clamp(15px, min(1.55vw, 2.45vh), 22px);
  font-weight: 800;
}

.card-tab svg {
  display: block;
  width: clamp(22px, min(2.2vw, 3.4vh), 30px);
  height: clamp(22px, min(2.2vw, 3.4vh), 30px);
}

.setting-row {
  display: grid;
  grid-template-columns: clamp(38px, 4vw, 52px) minmax(145px, 0.72fr) minmax(210px, 1.38fr);
  align-items: center;
  gap: clamp(10px, 1.2vw, 20px);
  min-height: clamp(56px, 8vh, 78px);
  padding: 6px 0;
  border-bottom: 1px solid #eceff4;
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-icon {
  display: block;
  width: clamp(30px, min(3.1vw, 4.8vh), 44px);
  height: clamp(30px, min(3.1vw, 4.8vh), 44px);
  color: var(--navy);
  justify-self: center;
}

.setting-label {
  color: #162b49;
  font-size: clamp(16px, min(1.55vw, 2.45vh), 22px);
  font-weight: 700;
}

.control-wrap {
  display: block;
  min-width: 0;
}

.control-wrap select,
.value-field {
  width: 100%;
  min-height: clamp(46px, 6.4vh, 60px);
  padding: 0 clamp(14px, 1.5vw, 22px);
  border: 1.5px solid #cfd7e3;
  border-radius: clamp(12px, 1.2vw, 18px);
  color: #162b49;
  background-color: #ffffff;
  font-size: clamp(15px, min(1.48vw, 2.35vh), 21px);
  font-weight: 700;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.control-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 48px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230d3b6e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right clamp(14px, 1.5vw, 22px) center;
  background-size: 22px 22px;
  cursor: pointer;
}

@media (hover: hover) {
  .control-wrap select:hover:not(:disabled) {
    border-color: #9cb2d4;
    background-color: #fafcff;
  }
}

.control-wrap select:disabled {
  color: var(--muted);
  background-color: #f6f8fb;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c8aa1' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  cursor: not-allowed;
}

.picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-width: 0;
  min-height: clamp(46px, 6.4vh, 60px);
  padding: 0 clamp(14px, 1.5vw, 22px);
  border: 1.5px solid #cfd7e3;
  border-radius: clamp(12px, 1.2vw, 18px);
  color: #162b49;
  background: #ffffff;
  font-size: clamp(15px, min(1.48vw, 2.35vh), 21px);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

@media (hover: hover) {
  .picker-trigger:hover {
    border-color: #9cb2d4;
    background: #fafcff;
  }
}

.picker-trigger span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-trigger svg {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  color: var(--navy);
  transition: transform 0.16s ease;
}

.picker-trigger[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.picker-trigger.has-selection {
  border-color: #b4c6e2;
}

.load-more-button {
  align-self: flex-start;
  min-height: 40px;
  padding: 6px 16px;
  border: 1px solid #c8d3e4;
  border-radius: 10px;
  color: var(--navy);
  background: #f4f7fc;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.load-more-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.counter-details {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  max-height: calc(2 * 1.32em);
  margin-top: 4px;
  padding: 0 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(12px, min(1.05vw, 1.7vh), 14px);
  line-height: 1.32;
  text-overflow: ellipsis;
  white-space: pre-line;
}

.counter-details:empty {
  display: none;
  margin: 0;
  padding: 0;
}

.value-field {
  display: flex;
  align-items: center;
  border-color: #e6ebf2;
  background: #f2f4f8;
  color: #42526b;
}

.device-field-group {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.device-field-group .value-field {
  display: block;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: clamp(46px, 6.4vh, 60px);
  line-height: calc(clamp(46px, 6.4vh, 60px) - 3px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(14px, min(1.32vw, 2.1vh), 18px);
  font-variant-numeric: tabular-nums;
}

.pin-manage-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: clamp(46px, 6.4vh, 60px);
  padding: 0 clamp(14px, 1.45vw, 20px);
  border: 1.5px solid rgba(13, 59, 110, 0.24);
  border-radius: clamp(12px, 1.2vw, 18px);
  color: var(--navy);
  background: #f3f7fd;
  font-size: clamp(14px, min(1.35vw, 2.15vh), 18px);
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

@media (hover: hover) {
  .pin-manage-button:hover {
    border-color: var(--navy);
    background: #e7effc;
  }
}

.pin-manage-button:active {
  transform: scale(0.975);
}

.pin-manage-button.has-pin {
  border-color: rgba(23, 131, 58, 0.36);
  color: #156c2f;
  background: #ecf9ef;
}

@media (hover: hover) {
  .pin-manage-button.has-pin:hover {
    border-color: #17833a;
    background: #dff4e4;
  }
}

.connection-card {
  display: grid;
  grid-template-columns: clamp(38px, 4vw, 52px) 1fr auto;
  align-items: center;
  gap: clamp(10px, 1.2vw, 20px);
  width: 100%;
  min-height: clamp(54px, 7.6vh, 74px);
  margin-top: clamp(8px, 1.4vh, 16px);
  padding: 8px clamp(18px, 2.4vw, 34px);
  border: 1px solid #efd8a5;
  border-radius: clamp(16px, 1.6vw, 22px);
  background: #fff9eb;
}

.connection-icon {
  display: block;
  width: clamp(32px, min(3.3vw, 5.1vh), 46px);
  height: auto;
  color: #bd7a00;
  justify-self: center;
}

.connection-label {
  color: #162b49;
  font-size: clamp(15px, min(1.5vw, 2.4vh), 21px);
  font-weight: 700;
}

.connection-pill {
  padding: clamp(6px, 0.9vh, 10px) clamp(14px, 1.6vw, 22px);
  border-radius: 999px;
  color: #8b5b00;
  background: #fff0c2;
  font-size: clamp(13px, min(1.25vw, 2vh), 18px);
  font-weight: 800;
  white-space: nowrap;
}

.connection-card.connected {
  border-color: #c7e9cb;
  background: #effbef;
}

.connection-card.connected .connection-icon {
  color: #18a94b;
}

.connection-card.connected .connection-pill {
  color: #187a33;
  background: #d8f5dc;
}

.connection-card.disconnected {
  border-color: #efb1b9;
  background: #fff0f0;
}

.connection-card.disconnected .connection-icon {
  color: #b51c2b;
}

.connection-card.disconnected .connection-pill {
  color: #a31326;
  background: #fbdde1;
}

.pending-sync {
  width: 100%;
  min-height: 0;
  margin: 4px 4px 0;
  color: var(--muted);
  font-size: clamp(12px, 1.1vw, 15px);
  text-align: right;
}

.pending-sync.has-pending {
  color: #986000;
  font-weight: 700;
}

.settings-message {
  min-height: 1.3em;
  margin: 6px 4px 0;
  color: #162b49;
  font-size: clamp(13px, min(1.25vw, 2vh), 17px);
  font-weight: 700;
  text-align: center;
}

.settings-message:empty {
  display: none;
  min-height: 0;
  margin: 0;
}

.settings-message.error {
  color: #ad1428;
}

.settings-actions {
  display: flex;
  justify-content: center;
  gap: clamp(14px, 2vw, 28px);
  width: min(82%, 680px);
  margin-top: clamp(10px, 1.8vh, 20px);
}

.button {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 0.9vw, 12px);
  min-height: clamp(48px, 7vh, 66px);
  padding: 0 20px;
  border: 2px solid var(--red);
  border-radius: clamp(14px, 1.4vw, 20px);
  font-size: clamp(16px, min(1.7vw, 2.7vh), 24px);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
}

.button svg {
  display: block;
  flex: 0 0 auto;
  width: clamp(22px, min(2.3vw, 3.6vh), 32px);
  height: clamp(22px, min(2.3vw, 3.6vh), 32px);
}

.button-back {
  flex-grow: 0.92;
  color: var(--red);
  background: rgba(255, 255, 255, 0.9);
}

.button-save {
  flex-grow: 1.08;
  border-color: var(--red);
  color: #ffffff;
  background: linear-gradient(105deg, #df102d, #bd001d);
  box-shadow: 0 6px 16px rgba(194, 0, 28, 0.18);
}

@media (hover: hover) {
  .button-back:hover {
    background: #fff5f6;
    transform: translateY(-1px);
  }

  .button-save:hover:not(:disabled) {
    box-shadow: 0 9px 20px rgba(194, 0, 28, 0.25);
    transform: translateY(-1px);
  }
}

.button:active:not(:disabled) {
  transform: scale(0.985);
}

.button:disabled {
  opacity: 0.68;
  cursor: wait;
}

.picker-overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(12, 25, 45, 0.52);
  backdrop-filter: blur(2px);
  overscroll-behavior: contain;
}

.commune-picker {
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: min(680px, calc(100vh - 40px));
  max-height: min(680px, calc(100dvh - 40px));
  overflow: hidden;
  border: 1px solid rgba(18, 61, 131, 0.12);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 22px 64px rgba(10, 24, 46, 0.26);
}

.picker-handle {
  display: none;
}

.picker-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 12px;
}

.picker-header h2 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 800;
  line-height: 1.2;
}

.picker-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: clamp(13px, 1.2vw, 15px);
}

.picker-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #e0e5ed;
  border-radius: 13px;
  color: #243957;
  background: #ffffff;
  cursor: pointer;
  transition: background-color 0.14s ease;
}

@media (hover: hover) {
  .picker-close:hover {
    background: #f3f6fb;
  }
}

.picker-close svg {
  width: 22px;
  height: 22px;
}

.picker-search {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  margin: 0 22px 10px;
  padding: 0 14px;
  border: 1.5px solid #cfd7e3;
  border-radius: 14px;
  color: var(--muted);
  background: #f9fbfe;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.picker-search svg {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
}

.picker-search input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0;
  border: 0;
  outline: 0;
  color: #162b49;
  background: transparent;
  font-size: 16px;
  font-weight: 600;
  user-select: text;
}

.picker-search:focus-within {
  border-color: #6f8fc0;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(13, 59, 110, 0.10);
}

.commune-results {
  flex: 1 1 auto;
  min-height: 120px;
  overflow: auto;
  padding: 0 14px 8px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.commune-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid #eef1f6;
  border-radius: 12px;
  color: #162b49;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

@media (hover: hover) {
  .commune-option:hover {
    background: #f4f8ff;
  }
}

.commune-option:active {
  background: #eaf1fd;
}

.commune-option[aria-selected="true"] {
  color: var(--navy);
  background: #edf4ff;
}

.commune-option-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.commune-option-copy strong {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.commune-option-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commune-option-check {
  flex: 0 0 auto;
  color: #17833a;
  font-size: 21px;
  font-weight: 900;
}

.picker-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px 20px 12px;
  border-top: 1px solid #edf0f5;
  background: #fcfdff;
}

.picker-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.3;
}

.picker-footer-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.picker-retry {
  min-height: 40px;
  padding: 6px 16px;
  border: 1px solid #c8d3e4;
  border-radius: 10px;
  color: var(--navy);
  background: #f4f7fc;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.pin-dialog {
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  overflow: hidden;
  border: 1px solid rgba(18, 61, 131, 0.12);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 22px 64px rgba(10, 24, 46, 0.26);
}

.pin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 22px 22px;
}

.pin-input {
  width: 100%;
  height: 58px;
  padding: 0 16px;
  border: 2px solid #cfd7e3;
  border-radius: 15px;
  outline: 0;
  color: #0d3b6e;
  background: #f9fbfe;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  user-select: text;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.pin-input:placeholder-shown {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: normal;
}

.pin-input::placeholder {
  color: #8795aa;
  font-weight: 600;
  letter-spacing: normal;
}

.pin-input:focus {
  border-color: #0d3b6e;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(13, 59, 110, 0.12);
}

.pin-error {
  margin: 0;
  min-height: 1.3em;
  color: #ad1428;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.pin-error:empty {
  display: none;
  min-height: 0;
}

.pin-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.pin-clear-button,
.pin-submit-button {
  display: inline-flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
}

.pin-clear-button {
  border: 1.5px solid rgba(207, 16, 36, 0.45);
  color: var(--red);
  background: #fff7f8;
}

@media (hover: hover) {
  .pin-clear-button:hover {
    border-color: var(--red);
    background: #ffecef;
  }
}

.pin-submit-button {
  border: 0;
  color: #ffffff;
  background: linear-gradient(105deg, #df102d, #bd001d);
  box-shadow: 0 6px 16px rgba(194, 0, 28, 0.20);
}

@media (hover: hover) {
  .pin-submit-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 9px 20px rgba(194, 0, 28, 0.28);
  }
}

.pin-clear-button:active,
.pin-submit-button:active {
  transform: scale(0.98);
}

.toast {
  position: fixed;
  z-index: 30;
  right: 24px;
  bottom: 24px;
  padding: 12px 20px;
  border-radius: 14px;
  color: #ffffff;
  background: #0d3b6e;
  box-shadow: 0 10px 26px rgba(13, 59, 110, 0.24);
  font-size: 16px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid #0d3b6e;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Compact Landscape Viewports (e.g., Small Tablets / Short Browser Windows)
   ========================================================================== */

@media (orientation: landscape) and (max-height: 700px) {
  .top-banner {
    min-height: clamp(92px, 16vh, 118px);
    padding: 8px 3.5vw 20px 5vw;
  }

  .title-rule {
    margin-top: -8px;
    margin-bottom: 4px;
  }

  .service-location {
    margin-bottom: 8px;
    padding: 5px 18px;
  }

  .rating-card {
    min-height: clamp(136px, 24vh, 178px);
    padding: 10px 8px 12px;
    gap: 6px;
  }

  .thanks-line {
    margin-top: 10px;
  }

  .rating-submit {
    margin-top: 8px;
    gap: 5px;
  }

  .send-rating-button {
    min-height: 44px;
    padding: 8px 24px;
  }

  .settings-heading {
    margin-bottom: 6px;
  }

  .settings-title-rule {
    height: 38px;
  }

  .settings-card {
    padding-top: 40px;
  }

  .setting-row {
    min-height: 50px;
    padding: 4px 0;
  }

  .control-wrap select,
  .value-field,
  .picker-trigger,
  .pin-manage-button {
    min-height: 42px;
  }

  .device-field-group .value-field {
    height: 42px;
    line-height: 39px;
  }

  .connection-card {
    min-height: 48px;
    margin-top: 6px;
  }

  .settings-actions {
    margin-top: 8px;
  }

  .button {
    min-height: 44px;
  }
}

/* ==========================================================================
   Portrait Responsive Layout (Phones & Portrait Tablets, e.g., 390x844)
   ========================================================================== */

@media (orientation: portrait) {
  .app-shell::before {
    width: min(146vw, 740px);
  }

  .top-banner {
    min-height: 98px;
    padding: 10px 14px 22px 16px;
  }

  .service-emblem {
    width: 44px;
  }

  .brand-separator {
    height: 44px;
    margin-left: 10px;
  }

  .brand-copy {
    margin-left: 10px;
  }

  .agency-name {
    font-size: clamp(14px, 4.1vw, 20px);
    white-space: normal;
  }

  .service-name {
    margin-top: 2px;
    font-size: clamp(10px, 2.65vw, 13.5px);
    white-space: normal;
  }

  .settings-open-button {
    width: 42px;
    height: 42px;
    margin-left: 8px;
    border-radius: 11px;
  }

  .main-content {
    padding: 0 14px 68px;
  }

  .title-rule {
    gap: 12px;
    margin-top: -6px;
    margin-bottom: 6px;
  }

  .title-rule > span {
    flex: 1 1 auto;
    max-width: 96px;
  }

  .feedback-badge {
    width: 64px;
    height: 50px;
    border-radius: 14px;
  }

  #rating-title,
  .rating-screen h1 {
    font-size: clamp(22px, 5.8vw, 32px);
  }

  .intro-copy {
    margin: 6px 0 10px;
    font-size: clamp(13.5px, 3.6vw, 17px);
  }

  .service-location {
    max-width: 100%;
    margin: 0 0 12px;
    padding: 6px 14px;
    border-radius: 18px;
    font-size: clamp(12px, 3.15vw, 14.5px);
    white-space: normal;
    text-align: center;
  }

  .rating-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
  }

  .rating-card {
    min-height: 128px;
    padding: 10px 8px 12px;
    gap: 6px;
    border-radius: 16px;
  }

  .face {
    width: clamp(62px, 16.8vw, 84px);
  }

  .rating-label {
    min-height: 0;
    font-size: clamp(15px, 4vw, 18px);
  }

  .rating-5 {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: center;
    gap: 14px;
    min-height: 92px;
    padding: 10px 16px;
  }

  .thanks-line {
    width: 100%;
    gap: 8px;
    margin-top: 14px;
    font-size: clamp(15px, 4vw, 19px);
  }

  .check-mark {
    width: 30px;
    font-size: 16px;
  }

  .rating-submit {
    width: 100%;
    margin-top: 12px;
  }

  .selection-summary {
    font-size: 14.5px;
  }

  .send-rating-button {
    width: 100%;
    min-width: 0;
    min-height: 52px;
    font-size: 18px;
  }

  .bottom-wave {
    height: clamp(50px, 7.5vh, 76px);
  }

  .thank-you-screen {
    padding: 12px 0 20px;
  }

  .thank-you-content {
    padding: 22px 16px;
    border-radius: 22px;
  }

  .thank-you-check {
    width: 72px;
  }

  .thank-you-screen h1 {
    margin-top: 12px;
    font-size: clamp(24px, 6.5vw, 34px);
  }

  .thank-you-copy {
    font-size: 16px;
  }

  .countdown-instruction {
    margin: 16px 0 6px;
    font-size: 15px;
  }

  .countdown-display strong {
    font-size: 48px;
  }

  .return-home-button {
    min-height: 54px;
    margin-top: 16px;
    padding: 10px 16px;
    font-size: 17px;
  }

  .settings-screen {
    width: 100%;
    padding-top: 4px;
  }

  .settings-heading {
    margin: 0 0 12px;
  }

  .settings-title-rule {
    width: 90vw;
    height: 44px;
  }

  .settings-heading h1 {
    font-size: 24px;
  }

  .settings-heading-icon {
    width: 36px;
  }

  .settings-card {
    padding: 44px 12px 6px;
    border-radius: 18px;
  }

  .card-tab {
    min-height: 38px;
    padding: 0 14px;
    border-radius: 17px 0 15px 0;
    font-size: 15px;
  }

  .card-tab svg {
    width: 22px;
    height: 22px;
  }

  .setting-row {
    grid-template-columns: 38px 1fr;
    gap: 4px 8px;
    min-height: 70px;
  }

  .setting-icon {
    grid-row: span 2;
    width: 30px;
    height: 30px;
  }

  .setting-label {
    align-self: end;
    font-size: 14.5px;
  }

  .control-wrap,
  .value-field,
  .picker-trigger,
  .device-field-group {
    grid-column: 2;
    align-self: start;
  }

  .control-wrap select,
  .value-field,
  .picker-trigger {
    min-height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    font-size: 14.5px;
  }

  .device-field-group {
    gap: 8px;
  }

  .device-field-group .value-field {
    height: 42px;
    line-height: 39px;
    font-size: 13px;
  }

  .pin-manage-button {
    min-height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    font-size: 13.5px;
  }

  .control-wrap select {
    padding-right: 38px;
    background-position: right 12px center;
    background-size: 19px 19px;
  }

  .picker-trigger svg {
    width: 19px;
    height: 19px;
  }

  .connection-card {
    grid-template-columns: 38px 1fr;
    gap: 4px 8px;
    padding: 10px 12px;
  }

  .connection-icon {
    grid-row: span 2;
    width: 30px;
  }

  .connection-label {
    font-size: 14.5px;
  }

  .connection-pill {
    justify-self: start;
    padding: 5px 12px;
    font-size: 13px;
  }

  .settings-actions {
    width: 100%;
    gap: 10px;
    margin-top: 12px;
  }

  .button {
    min-height: 48px;
    padding: 0 12px;
    gap: 6px;
    border-radius: 14px;
    font-size: 15px;
  }

  .button svg {
    width: 22px;
    height: 22px;
  }

  .picker-overlay {
    align-items: flex-end;
    padding: 0;
  }

  #pin-overlay {
    align-items: center;
    padding: 16px;
  }

  .pin-dialog {
    border-radius: 22px;
  }

  .pin-form {
    padding: 4px 18px 18px;
  }

  .pin-input {
    height: 52px;
    font-size: 22px;
  }

  .pin-clear-button,
  .pin-submit-button {
    min-height: 46px;
    padding: 0 14px;
    font-size: 15px;
  }

  .commune-picker {
    width: 100%;
    max-height: 86vh;
    max-height: 86dvh;
    padding-bottom: env(safe-area-inset-bottom);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 24px 24px 0 0;
  }

  .picker-handle {
    display: block;
    flex: 0 0 auto;
    width: 42px;
    height: 5px;
    margin: 9px auto 0;
    border-radius: 99px;
    background: #d5dbe5;
  }

  .picker-header {
    padding: 12px 18px 10px;
  }

  .picker-header h2 {
    font-size: 20px;
  }

  .picker-search {
    min-height: 48px;
    margin: 0 16px 8px;
  }

  .picker-search input {
    height: 44px;
    font-size: 16px;
  }

  .commune-results {
    padding: 0 10px 8px;
  }

  .commune-option {
    min-height: 56px;
    padding: 8px 12px;
  }

  .picker-footer {
    min-height: 54px;
    padding: 8px 14px 12px;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 18px;
    text-align: center;
  }
}
