@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,300..900;1,300..900&display=swap');

:root {
  --teal:          #16a34a;       /* Fresh emerald / ninja green */
  --teal-dark:     #15803d;       /* Deep tea green */
  --teal-subtle:   #f0fdf4;       /* Soft mint background */
  --app-bg:        #000000;       /* Game black background */
  --topbar-bg:     #0c1b14;       /* Synchronized dark emerald header */
  --topbar-border: #184230;       /* Border matching tea brand */
  --text-light:    #f8fafc;
  --text-muted:    #94a3b8;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #050c08;
  background: radial-gradient(ellipse at center, #0e1e16 0%, #030604 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-light);
  font-family: 'Nunito', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

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

button, input, select, textarea, dialog {
  font-family: inherit;
}

.hidden { display: none !important; }

/* Fullscreen Shell - Expanded Portrait HD */
.fullscreen-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(680px, 100vw);
  height: 100%;
  height: 100dvh;
  position: relative;
  margin: 0 auto;
  background: #000000;
  overflow: hidden;
  box-shadow: 0 0 70px rgba(0, 0, 0, 0.98), 0 0 0 1px rgba(74, 222, 128, 0.25);
  border-radius: 16px;
}
@media (max-width: 680px) {
  .fullscreen-app {
    max-width: 100vw;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Synchronized Top Bar */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 42px;
  min-height: 42px;
  padding: 0 10px;
  background: var(--topbar-bg);
  border-bottom: 1.5px solid var(--topbar-border);
  z-index: 100;
  gap: 8px;
  flex-shrink: 0;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), margin-top 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}
.app-topbar.collapsed {
  transform: translateY(-100%);
  margin-top: -42px;
  opacity: 0;
  pointer-events: none;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.top-link, .top-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--topbar-border);
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 11.5px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.top-link:hover, .top-btn:hover {
  background: rgba(22, 163, 74, 0.2);
  color: #ffffff;
  border-color: var(--teal);
}
.top-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.top-btn.btn-park {
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  border-color: var(--teal);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}
.top-btn.btn-park:hover {
  filter: brightness(1.1);
}
.top-btn.active, .floating-btn.active {
  background: rgba(22, 163, 74, 0.35);
  border-color: var(--teal);
  color: #4ade80;
}
.top-btn.square {
  width: 28px;
  min-width: 28px;
  padding: 0;
  justify-content: center;
}
.slot-badge-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.slot-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--teal);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}
.slot-title {
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-char-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.15);
  border: 1px solid rgba(74, 222, 128, 0.25);
  color: #4ade80;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 480px) {
  .hide-xs { display: none; }
  .app-topbar { padding: 0 6px; gap: 4px; }
  .top-link, .top-btn { padding: 0 7px; height: 28px; font-size: 11px; }
  .slot-title { max-width: 85px; }
  .top-char-badge { max-width: 95px; font-size: 10.5px; padding: 2px 6px; }
}

/* Game Canvas Area - Edge to Edge */
/* Game Canvas Area - Edge to Edge */
.game-canvas-area {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: #000000;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
  touch-action: none;
  display: block;
}

#gameCanvas.smooth {
  image-rendering: auto !important;
  image-rendering: smooth !important;
}

#gameCanvas.auto-fit {
  object-fit: contain;
}

/* Floating Mobile Quick Action Pill (Disabled to avoid blocking in-game UI) */
.floating-bar {
  display: none !important;
}
.floating-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: none;
}
.floating-btn:active {
  transform: scale(0.92);
  background: rgba(22, 163, 74, 0.5);
}

/* Start Cover Screen */
.start-cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 24, 18, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
  padding: 20px;
  text-align: center;
  gap: 10px;
}
.cover-logo {
  max-width: 150px;
  height: auto;
  margin-bottom: 2px;
}
.cover-hint {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}
.res-box {
  width: 100%;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
  margin: 4px 0;
}
.res-box label {
  font-size: 11px;
  font-weight: 800;
  color: #4ade80;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.res-select {
  width: 100%;
  height: 34px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 8px;
  border: 1.5px solid var(--topbar-border);
  background: #11261d;
  color: #ffffff;
  cursor: pointer;
}
.custom-res-box {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.custom-res-box input {
  flex: 1;
  height: 30px;
  padding: 2px 6px;
  font-size: 12px;
  border: 1.5px solid var(--topbar-border);
  border-radius: 6px;
  background: #11261d;
  color: #ffffff;
  text-align: center;
  font-weight: 700;
}
.custom-res-box span {
  font-weight: 800;
  color: #94a3b8;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: #e2e8f0;
  cursor: pointer;
}
.check-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}
.cover-play-btn {
  height: 42px;
  padding: 0 24px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  color: #ffffff;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
  width: 100%;
  max-width: 260px;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.35);
  transition: transform 0.1s ease, filter 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.cover-play-btn:active {
  transform: scale(0.97);
}
.cover-play-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}



/* Synchronized Modern Card Dialogs (Matching Image 2) */
.input-dialog {
  width: min(440px, calc(100vw - 24px));
  max-width: 95vw;
  padding: 16px 18px;
  border: 1.5px solid #cbd5e1;
  border-radius: 16px;
  color: #0f172a;
  background: #f8fafc;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.input-dialog::backdrop {
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1.5px solid #e2e8f0;
}
.dialog-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.2px;
}
.icon-close-btn {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.dialog-sub {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 14px;
  line-height: 1.4;
}

/* Form Items Container */
.form-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(82vh - 120px);
  overflow-y: auto;
  padding: 2px 4px 2px 2px;
}
.form-items::-webkit-scrollbar {
  width: 6px;
}
.form-items::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.form-items::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Form Card Box (Group / Container) */
.form-card-box {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  margin: 0;
  min-inline-size: auto;
}
.form-card-title {
  font-size: 13.5px;
  font-weight: 800;
  color: #1e293b;
  padding: 0 4px;
  margin-bottom: 8px;
}
.form-fields-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Choice Grid & Tile (Checkboxes & Radios) */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 8px;
}
.choice-tile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  user-select: none;
}
.choice-tile input[type="radio"],
.choice-tile input[type="checkbox"] {
  accent-color: #ea580c;
  width: 17px;
  height: 17px;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.choice-tile .choice-text {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  line-height: 1.25;
}
/* Active / Checked Card Highlight matching Image 2 */
.choice-tile.checked,
.choice-tile:has(input:checked) {
  border-color: #f97316;
  background: #fff7ed;
  box-shadow: 0 1px 3px rgba(249, 115, 22, 0.12);
}
.choice-tile.checked .choice-text,
.choice-tile:has(input:checked) .choice-text {
  color: #9a3412;
  font-weight: 700;
}

/* Dropdown Select */
.field-select {
  width: 100%;
  height: 38px;
  padding: 6px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 13.5px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-select:focus {
  border-color: #f97316;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

/* Text Field Card */
.field-card-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #475569;
}
.field-input {
  width: 100%;
  height: 38px;
  padding: 6px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input:focus {
  border-color: #f97316;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

/* Legacy Field Fallback (TextDialog) */
.field {
  display: grid;
  gap: 6px;
  font-size: 12px;
}
.field span {
  font-weight: 700;
  color: #475569;
}
.field input {
  width: 100%;
  height: 38px;
  padding: 8px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 14px;
  box-sizing: border-box;
}
.field input:focus {
  outline: none;
  border-color: #f97316;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
}

/* Dialog Action Buttons */
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}
.btn-form-save {
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  height: 38px;
  padding: 0 20px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
  transition: background 0.15s, transform 0.1s;
}
.btn-form-save:hover {
  background: #15803d;
}
.btn-form-save:active {
  transform: scale(0.98);
}
.btn-form-cancel {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #475569;
  border-radius: 8px;
  height: 38px;
  padding: 0 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-form-cancel:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}
.btn-form-cancel:active {
  transform: scale(0.98);
}

/* ==========================================================================
   Option 2: Dedicated Mobile Keypad (Ergonomic Golden Ratio for Portrait HD)
   ========================================================================== */
.game-keypad {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: clamp(210px, 33vh, 260px);
  min-height: 205px;
  max-height: 265px;
  background: #08140e;
  background: linear-gradient(180deg, #0b1f16 0%, #050d09 100%);
  border-top: 1.5px solid var(--topbar-border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(74, 222, 128, 0.15);
  padding: 8px 24px max(8px, env(safe-area-inset-bottom));
  box-sizing: border-box;
  flex-shrink: 0;
  z-index: 30;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.pad-cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.pad-btn {
  border: 1px solid rgba(74, 222, 128, 0.25);
  background: linear-gradient(145deg, #132b1f 0%, #091710 100%);
  color: #e2e8f0;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, background 0.08s ease, border-color 0.08s ease, box-shadow 0.08s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  padding: 0;
}
.pad-btn:active, .pad-btn.pressed {
  transform: scale(0.92);
  background: rgba(22, 163, 74, 0.45) !important;
  border-color: #4ade80 !important;
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.5), inset 0 0 6px rgba(0, 0, 0, 0.6) !important;
  color: #ffffff !important;
}

/* Left: D-Pad Cluster with Menu on Top */
.dpad-cluster {
  flex: 0 0 auto;
  width: clamp(160px, 42vw, 195px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
}
.dpad-top-bar {
  display: flex;
  width: 100%;
  max-width: 180px;
}
.dpad-top-bar .util-btn {
  width: 100%;
  height: 38px;
  font-size: 13.5px;
  font-weight: 850;
  border-radius: 9px;
  flex-direction: row;
  gap: 8px;
  border: 1.5px solid rgba(74, 222, 128, 0.35);
  background: linear-gradient(145deg, #163626 0%, #0c2016 100%);
  color: #4ade80;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}
.dpad-top-bar .util-btn i {
  font-size: 14px;
  color: #4ade80;
}

/* D-Pad 3x3 Grid - Larger buttons */
.dpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 180px;
  aspect-ratio: 1 / 1;
  background: rgba(0, 0, 0, 0.45);
  padding: 5px;
  border-radius: 50%;
  border: 1.5px solid rgba(74, 222, 128, 0.2);
  box-sizing: border-box;
}
.dpad-btn {
  font-size: 24px;
  border-radius: 9px;
}
.dpad-btn.diagonal {
  font-size: 14px;
  opacity: 0.8;
  background: rgba(22, 163, 74, 0.1);
  border-color: rgba(74, 222, 128, 0.15);
  border-radius: 7px;
}
.diag-arrow {
  font-size: 14px;
  font-weight: 900;
  color: #4ade80;
  line-height: 1;
}
.dpad-center {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.dpad-center-core {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4ade80;
  opacity: 0.4;
  box-shadow: 0 0 8px #4ade80;
}

/* Right Side: Big Attack Button */
.action-cluster {
  flex: 0 0 auto;
  width: clamp(120px, 35vw, 160px);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.attack-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.attack-btn {
  width: clamp(88px, 25vw, 108px);
  height: clamp(88px, 25vw, 108px);
  border-radius: 50%;
  border: 2.5px solid #4ade80;
  background: radial-gradient(circle at 35% 35%, #22c55e 0%, #15803d 60%, #0d5327 100%);
  box-shadow: 0 6px 24px rgba(34, 197, 94, 0.5), inset 0 2px 5px rgba(255, 255, 255, 0.4);
  color: #ffffff;
}
.attack-btn:active, .attack-btn.pressed {
  transform: scale(0.92);
  filter: brightness(1.2);
  box-shadow: 0 0 30px rgba(74, 222, 128, 0.95), inset 0 0 12px rgba(0, 0, 0, 0.6) !important;
}
.attack-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.attack-inner i {
  font-size: 28px;
}
.attack-inner span {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

@media (max-width: 360px) {
  .game-keypad {
    padding: 6px 8px max(6px, env(safe-area-inset-bottom));
    height: 200px;
    min-height: 200px;
  }
  .dpad-cluster { width: 145px; }
  .dpad-top-bar .util-btn { height: 34px; font-size: 11px; }
  .attack-btn { width: 78px; height: 78px; }
  .attack-btn i { font-size: 22px; }
  .attack-btn span { font-size: 12px; }
}
