feat(mobile): Add responsive layout, mobile Drawer menu, and touch gestures

- Add viewport-fit=cover & mobile slide-out Drawer navigation menu
- Add @media screen rules (<=768px and landscape <=540px)
- Add Touch Drag & Drop planting and continuous swipe-to-collect
- Add Vibration API haptic feedback for planting, collecting, and explosions
- Add automated responsive test assertions in test_game.py (242/242 PASS)
This commit is contained in:
Antigravity committed 2026-09-17 10:07:17 +00:00
1 parent 6457a8904e
commit 82654d8f64
4 files changed
+433 -22

No files matched your search

+310 -3
View File
@@ -28,7 +28,7 @@ body {
max-width: 98vw;
}
/* Clean Flexbox Top Navigation Bar (Adaptive & No Overflow) */
/* Clean Flexbox Top Navigation Bar (Adaptive & Responsive) */
.top-nav-bar {
width: 100%;
background: linear-gradient(to bottom, #3e2723, #2a160c);
@@ -37,7 +37,7 @@ body {
border-radius: 10px 10px 0 0;
padding: 4px 8px;
display: flex;
flex-wrap: wrap;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
gap: 4px;
@@ -49,10 +49,26 @@ body {
.nav-left, .nav-right {
display: flex;
align-items: center;
flex-wrap: wrap;
flex-wrap: nowrap;
gap: 4px;
}
.desktop-nav-links {
display: flex;
align-items: center;
gap: 4px;
}
.btn-drawer-toggle {
display: none;
background: #ff8f00;
color: #fff;
border-color: #ffd54f;
}
.btn-drawer-toggle:hover {
background: #ffa000;
}
.nav-btn {
background: #2a160c;
color: #ffeb3b;
@@ -1892,3 +1908,294 @@ body.theme-winter .banner-card {
color: #ffcdd2;
border: 1px solid #e53935;
}
/* ==========================================================================
📱 Mobile Slide-out Drawer Menu & Backdrop
========================================================================== */
.drawer-backdrop {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
height: 100dvh;
background: rgba(0, 0, 0, 0.65);
backdrop-filter: blur(4px);
z-index: 1000;
transition: opacity 0.25s ease;
opacity: 1;
}
.drawer-backdrop.hidden {
display: none;
opacity: 0;
}
.mobile-drawer {
position: fixed;
top: 0;
right: 0;
width: 290px;
max-width: 85vw;
height: 100vh;
height: 100dvh;
background: linear-gradient(180deg, #3e2723 0%, #1a0d05 100%);
border-left: 3px solid #e09f3e;
box-shadow: -8px 0 30px rgba(0, 0, 0, 0.85);
z-index: 1001;
display: flex;
flex-direction: column;
transform: translateX(0);
transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
padding-top: env(safe-area-inset-top, 0px);
padding-bottom: env(safe-area-inset-bottom, 0px);
box-sizing: border-box;
}
.mobile-drawer.hidden {
transform: translateX(100%);
pointer-events: none;
}
.drawer-header {
padding: 14px 16px;
background: rgba(0, 0, 0, 0.35);
border-bottom: 2px solid #5d4037;
display: flex;
justify-content: space-between;
align-items: center;
}
.drawer-header h2 {
font-size: 16px;
color: #ffeb3b;
margin: 0;
}
.btn-drawer-close {
background: rgba(255, 255, 255, 0.1);
border: 1px solid #8d6e63;
color: #fff;
font-size: 16px;
width: 32px;
height: 32px;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.15s;
}
.btn-drawer-close:hover {
background: #d32f2f;
border-color: #f44336;
}
.drawer-body {
flex: 1;
overflow-y: auto;
padding: 10px 12px;
display: flex;
flex-direction: column;
gap: 8px;
}
.drawer-item {
width: 100%;
background: #2a160c;
color: #ffeb3b;
border: 1.5px solid #8d6e63;
border-radius: 8px;
padding: 10px 12px;
font-size: 13px;
font-weight: bold;
text-align: left;
cursor: pointer;
transition: all 0.15s ease;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
display: flex;
align-items: center;
gap: 8px;
}
.drawer-item:hover, .drawer-item:active {
background: #422817;
border-color: #ffd54f;
transform: translateX(-2px);
}
.btn-drawer-bug {
border-color: #0288d1;
color: #e1f5fe;
margin-top: 6px;
}
.btn-drawer-bug:hover {
background: #0277bd;
}
/* ==========================================================================
📱 Comprehensive Mobile & Tablet Responsive Rules (@media)
========================================================================== */
/* Tablets & Mobile Screens (<= 768px) */
@media screen and (max-width: 768px) {
body {
padding: 0;
justify-content: flex-start;
}
#game-wrapper {
width: 100%;
max-width: 100vw;
}
.top-nav-bar {
border-radius: 0;
border-left: none;
border-right: none;
padding: 4px 6px;
padding-top: max(4px, env(safe-area-inset-top));
}
/* Hide long list of top links; use drawer button instead */
.desktop-nav-links {
display: none !important;
}
.btn-drawer-toggle {
display: inline-flex !important;
}
.nav-btn {
font-size: 10px;
padding: 4px 6px;
}
.profile-badge {
padding: 2px 4px;
font-size: 10px;
}
.profile-badge span {
max-width: 70px;
}
#game-container {
border-radius: 0;
border-left: none;
border-right: none;
border-bottom: none;
max-height: calc(100dvh - 42px);
width: 100vw;
}
/* Fullscreen & Bottom-sheet style modals for mobile */
.overlay {
padding: 4px;
}
.banner-card {
max-width: 96vw;
width: 96vw;
padding: 14px 12px;
max-height: 94dvh;
}
.start-card h1 {
font-size: 22px;
}
.start-card p {
font-size: 11px;
margin-bottom: 8px;
}
.mode-selector {
gap: 4px;
margin-bottom: 8px;
}
.mode-btn {
font-size: 11px;
padding: 6px 8px;
}
.start-hero-row {
flex-direction: column;
gap: 6px;
}
.btn-hero {
font-size: 14px;
padding: 10px 16px;
width: 100%;
}
.start-activities-grid {
grid-template-columns: repeat(2, 1fr);
gap: 6px;
}
.btn-act {
font-size: 11px;
padding: 8px 6px;
}
/* Modal Grids responsive */
.shop-items {
grid-template-columns: 1fr;
gap: 8px;
}
.almanac-layout {
flex-direction: column;
max-height: 80vh;
}
.almanac-grid {
grid-template-columns: repeat(4, 1fr) !important;
}
.almanac-details {
width: 100%;
}
.workshop-tabs {
flex-wrap: wrap;
gap: 4px;
}
.workshop-tab {
font-size: 11px;
padding: 5px 8px;
flex: 1;
text-align: center;
}
.campaign-levels-grid {
grid-template-columns: repeat(5, 1fr) !important;
gap: 4px !important;
}
}
/* Landscape Mode for Smartphones (< 540px height) */
@media screen and (orientation: landscape) and (max-height: 540px) {
body {
padding: 0;
}
.top-nav-bar {
padding: 2px 6px;
padding-left: max(6px, env(safe-area-inset-left));
padding-right: max(6px, env(safe-area-inset-right));
}
.nav-btn {
padding: 2px 5px;
font-size: 9px;
}
#game-container {
height: calc(100dvh - 30px);
max-height: calc(100dvh - 30px);
}
.banner-card {
max-height: 96dvh;
padding: 10px 14px;
}
}