:root {
  --brand: #1a5c38;
  --brand-dark: #144a2d;
  --brand-light: #227a4a;
  --phone-bg: #ffffff;
  --phone-shadow: 0 24px 48px rgba(10, 40, 24, 0.4), 0 8px 16px rgba(0, 0, 0, 0.12);
  --text-primary: #1a2332;
  --text-muted: #64748b;
  --screen-bg: #f1f5f9;
  --screen-border: #e2e8f0;
  --screen-error-bg: #fef2f2;
  --screen-error-border: #fecaca;
  --screen-error-text: #991b1b;
  --dial-color: #1a5c38;
  --key-bg: #f8fafc;
  --key-hover: #e2e8f0;
  --key-active: #cbd5e1;
  --key-sub: #94a3b8;
  --call-bg: #1a5c38;
  --call-hover: #144a2d;
  --radius-phone: 28px;
  --radius-key: 50%;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--brand);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.2rem 1rem 1.15rem;
}

.app-header {
  text-align: center;
  color: #fff;
  margin-bottom: 0.5rem;
  padding: 0;
  width: 100%;
  max-width: 680px;
}

.app-header-logo {
  display: block;
  width: min(170px, 55vw);
  height: auto;
  margin: 0 auto;
  padding: 0;
  object-fit: contain;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-tagline {
  margin: 0.12rem 0 0;
  font-size: 0.72rem;
  opacity: 0.8;
  font-weight: 400;
}

.simulator-stage {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  max-width: 680px;
}

.msisdn-panel {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.35rem 1.25rem;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-phone);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.msisdn-panel-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.msisdn-icon-wrap {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 1.35rem;
}

.msisdn-eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.msisdn-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

.msisdn-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.75rem 0.85rem;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.msisdn-input::placeholder {
  color: rgba(255, 255, 255, 0.45);
  font-weight: 500;
}

.msisdn-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.26);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

.msisdn-hint {
  display: block;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.4;
}

.app-footer {
  margin-top: 2rem;
  width: 100%;
  max-width: 680px;
  text-align: center;
}

.app-footer-text {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

/* Phone shell */
.phone {
  flex: 1 1 320px;
  width: min(100%, 420px);
  max-width: 420px;
  background: var(--phone-bg);
  border-radius: var(--radius-phone);
  box-shadow: var(--phone-shadow);
  padding: 1.5rem 1.25rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.phone-screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 220px;
}

.screen {
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text-primary);
  text-align: left;
  white-space: pre-wrap;
  word-wrap: break-word;
  flex: 1 1 auto;
  min-height: 11rem;
  max-height: 16rem;
  overflow-y: auto;
  margin: 0;
  padding: 1rem 1.125rem;
  background: var(--screen-bg);
  border: 1px solid var(--screen-border);
  border-radius: 12px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.screen:empty::before {
  content: "Resposta USSD";
  color: #94a3b8;
  font-style: italic;
  font-size: 0.95rem;
}

.screen.is-error {
  background: var(--screen-error-bg);
  border-color: var(--screen-error-border);
  color: var(--screen-error-text);
}

.screen.is-loading {
  color: var(--text-muted);
  font-style: italic;
}

.dial-display {
  border-bottom: 2px solid var(--screen-border);
  padding-bottom: 0.75rem;
  flex-shrink: 0;
}

.input {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: clamp(1.65rem, 5vw, 2rem);
  font-weight: 600;
  color: var(--dial-color);
  text-align: center;
  letter-spacing: 0.06em;
  padding: 0.25rem 0;
}

.input::placeholder {
  color: #cbd5e1;
  font-weight: 500;
}

.input:focus {
  outline: none;
}

/* Keypad grid */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0 0.25rem;
}

.key {
  aspect-ratio: 1;
  max-height: 72px;
  border: none;
  border-radius: var(--radius-key);
  background: var(--key-bg);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  font-family: var(--font);
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.key:hover {
  background: var(--key-hover);
}

.key:active {
  background: var(--key-active);
  transform: scale(0.96);
}

.key-main {
  font-size: 1.65rem;
  font-weight: 500;
  line-height: 1;
  color: var(--text-primary);
}

.key-sub {
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--key-sub);
  text-transform: uppercase;
}

/* Bottom actions */
.actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem;
}

.action-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-muted);
  padding: 0.5rem;
  border-radius: 12px;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.action-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.action-fav {
  justify-self: start;
}

.action-back {
  justify-self: end;
  font-size: 1.4rem;
}

.action-back:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--key-bg);
}

.action-call {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--call-bg);
  color: #fff;
  font-size: 1.35rem;
  box-shadow: 0 4px 14px rgba(26, 92, 56, 0.45);
  justify-self: center;
}

.action-call:hover {
  background: var(--call-hover);
  box-shadow: 0 6px 18px rgba(26, 92, 56, 0.5);
}

.action-call:active {
  transform: scale(0.95);
}

.action-call.is-busy {
  opacity: 0.7;
  pointer-events: none;
}

@media (max-width: 720px) {
  .simulator-stage {
    flex-direction: column;
    align-items: stretch;
    max-width: 420px;
  }

  .msisdn-panel {
    flex: none;
    width: 100%;
  }
}

@media (max-width: 380px) {
  .phone {
    padding: 1rem 0.75rem 1.25rem;
  }

  .key {
    max-height: 64px;
  }

  .key-main {
    font-size: 1.45rem;
  }

  .action-call {
    width: 50px;
    height: 50px;
  }
}

@media (min-height: 800px) {
  .app {
    justify-content: flex-start;
    padding-top: 0.2rem;
  }
}
