* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100vw;
}

/* Header */
.header {
    background-color: #2a2a2a;
    padding: 0.5rem 1rem;
    border-bottom: 2px solid #3a3a3a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 100;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
}

.support-link-header {
    background: linear-gradient(135deg, #ff424d 0%, #ff6b6b 100%);
    color: #fff;
    text-decoration: none;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(255, 66, 77, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.support-link-header:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 66, 77, 0.6);
    background: linear-gradient(135deg, #ff6b6b 0%, #ff424d 100%);
}

.support-link-header:active {
    transform: translateY(0);
}

.header-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-nav-link {
    color: #e0e0e0;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.header-nav-link:hover {
    color: #4a9eff;
    background-color: rgba(74, 158, 255, 0.1);
}

/* User Menu */
.user-menu-container {
    position: relative;
}

.user-menu-trigger {
    cursor: pointer;
}

.user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: #2a2a2a;
    border: 2px solid #3a3a3a;
    border-radius: 6px;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    overflow: hidden;
}

.user-menu-item {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    color: #e0e0e0;
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.user-menu-item:hover {
    background-color: #3a3a3a;
    color: #4a9eff;
}

.user-menu-item:first-child {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.user-menu-item:last-child {
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

/* Toolbar */
.toolbar {
    background-color: #252525;
    border: 2px solid #3a3a3a;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    min-height: 40px;
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    position: relative;
    z-index: 50;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.toolbar-section-map {
    margin-left: auto; /* Push to the right */
    padding-left: 1rem; /* Add spacing from previous section */
}

.toolbar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 0.5rem;
}

.toolbar-section-title:not(:first-child) {
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid #3a3a3a;
}

.toolbar-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    background-color: #2a2a2a;
    border: 2px solid #3a3a3a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.toolbar-btn:hover {
    background-color: #3a3a3a;
    border-color: #4a9eff;
    transform: translateY(-1px);
}

.toolbar-btn:active {
    transform: translateY(0);
}

.toolbar-btn.active {
    background-color: rgba(74, 158, 255, 0.15);
    border-color: #4a9eff;
    color: #4a9eff;
}

/* LOS button uses the selected color when active */
#toolbar-los-btn.active {
    background-color: rgba(74, 158, 255, 0.15);
    border-color: #3a3a3a;
}

#toolbar-los-btn.active:hover {
    background-color: rgba(74, 158, 255, 0.2);
    border-color: #4a9eff;
}

.toolbar-btn-icon-only {
    min-width: auto;
    padding: 0.35rem 0.5rem;
}

.toolbar-btn-icon-only span {
    display: none;
}

.toolbar-radius-selector {
    display: flex;
    gap: 0.2rem;
    align-items: center;
}

.toolbar-btn-small {
    padding: 0.25rem 0.45rem;
    font-size: 0.7rem;
    min-width: auto;
}

.toolbar-btn-small.active {
    background-color: rgba(74, 158, 255, 0.15);
    border-color: #4a9eff;
}

#toolbar-radius-btn.active {
    background-color: rgba(74, 158, 255, 0.15);
    border-color: #4a9eff;
}

#toolbar-measure-btn.active,
#toolbar-measure-btn-unit.active {
    background-color: rgba(74, 158, 255, 0.15);
    border-color: #4a9eff;
    color: #4a9eff;
}

.toolbar-btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 1);
    color: rgba(239, 68, 68, 1);
}

#toolbar-color-btn,
#toolbar-radius-color-btn,
#toolbar-measurement-color-btn {
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    min-width: auto;
}

#toolbar-color-btn:hover,
#toolbar-radius-color-btn:hover,
#toolbar-measurement-color-btn:hover {
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-1px) scale(1.02);
}

.toolbar-btn svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.toolbar-btn span {
    white-space: nowrap;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: #252525;
    padding: 1rem;
    overflow-y: auto;
    border-right: 2px solid #3a3a3a;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar section {
    margin-bottom: 1.25rem;
}

.sidebar h2 {
    font-size: 1.1rem;
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: #fff;
    border-bottom: 1px solid #3a3a3a;
    padding-bottom: 0.35rem;
    padding-top: 0;
}

.section-header-with-categories {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.section-header-with-categories h2 {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.selectors-wrapper {
    position: relative;
}

#selectors-container {
    margin-left: 0;
    padding-left: 0;
    position: relative;
}

.category-buttons-fixed {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    height: fit-content;
}

#selectors-container .selector-section:first-of-type {
    position: relative;
    margin-left: 0;
    padding-left: 0;
}

#selectors-container .selector-section:first-of-type h2 {
    margin-left: 0;
    padding-left: 0;
    text-align: left;
    position: static;
}

#selectors-container .selector-section {
    margin-left: 0;
    padding-left: 0;
}

#selectors-container .selector-section h2 {
    margin-left: 0;
    padding-left: 0;
    text-align: left;
    position: static;
}

/* Apply same left alignment to all selector-section h2 elements (including Base Sizes) */
.selector-section h2 {
    margin-left: 0;
    padding-left: 0;
    text-align: left;
    position: static;
}

.category-buttons {
    display: flex;
    gap: 0.3rem;
}

.category-btn {
    padding: 0.3rem 0.5rem;
    background-color: #2a2a2a;
    border: 2px solid #3a3a3a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
}

.category-btn:hover {
    border-color: #4a9eff;
    background-color: #2f3a4a;
    transform: translateY(-1px);
}

.category-btn.active {
    background-color: rgba(74, 158, 255, 0.15);
    border-color: #4a9eff;
    color: #4a9eff;
}

.selector-section {
    margin-bottom: 1.25rem;
    margin-left: 0;
    padding-left: 0;
    display: block;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    padding-bottom: 0.5rem;
    text-align: center;
    color: #888;
    font-size: 0.85rem;
    border-top: 1px solid #3a3a3a;
}

.sidebar-footer a {
    color: #fff;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.sidebar-footer a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.selector-dropdown {
    width: 100%;
    padding: 0.6rem;
    background-color: #2a2a2a;
    border: 2px solid #3a3a3a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.selector-dropdown:hover {
    border-color: #4a9eff;
}

.selector-dropdown:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.current-selection {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: #2a2a2a;
    border-radius: 4px;
    border-left: 3px solid #4a9eff;
}

.selection-label {
    font-weight: 500;
    color: #aaa;
}

.selection-value {
    color: #fff;
    font-weight: 600;
}

/* Base Sizes Grid */
.base-sizes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.base-size-item {
    padding: 0.45rem;
    background-color: #2a2a2a;
    border: 2px solid #3a3a3a;
    border-radius: 4px;
    color: #e0e0e0;
    text-align: center;
    font-size: 0.85rem;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Allow our custom pointer handling */
}

.base-size-item:hover {
    border-color: #4a9eff;
    background-color: #2f3a4a;
    transform: translateY(-1px);
}

.base-size-item:active {
    cursor: grabbing;
    transform: translateY(0);
}

.base-size-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* Shape Selector (New UI) */
.shape-selector-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.shape-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background-color: #2a2a2a;
    border: 2px solid #3a3a3a;
    border-radius: 6px;
    padding: 0.4rem;
}

.shape-size-dropdown {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.3rem;
    background-color: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.75rem;
    cursor: pointer;
}

.shape-size-dropdown:hover {
    border-color: #4a9eff;
}

.shape-size-dropdown:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.shape-qty-input {
    width: 42px;
    padding: 0.4rem 0.2rem;
    background-color: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.75rem;
    text-align: center;
}

.shape-qty-input:hover {
    border-color: #4a9eff;
}

.shape-qty-input:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

/* Hide spinner buttons on number input */
.shape-qty-input::-webkit-outer-spin-button,
.shape-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}
.shape-qty-input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.shape-drag-button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #1a1a1a;
    border: 2px solid #3a3a3a;
    border-radius: 6px;
    cursor: grab;
    transition: all 0.2s;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.shape-drag-button:hover {
    border-color: #4a9eff;
    background-color: #2f3a4a;
    transform: scale(1.05);
}

.shape-drag-button:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.shape-drag-button.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.shape-drag-button svg {
    width: 24px;
    height: 24px;
}

/* Battlefield */
.battlefield-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background-color: #1e1e1e;
    padding: 0.5rem;
    overflow: auto;
    position: relative;
}

/* Snap to Grid Toggle */
.toolbar-btn-snap {
    position: relative;
}

.toolbar-btn-snap input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toolbar-btn-snap .toolbar-btn-content {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.toolbar-btn-snap input[type="checkbox"]:checked ~ .toolbar-btn-content {
    color: #4a9eff;
}

.toolbar-btn-snap:has(input[type="checkbox"]:checked) {
    background-color: rgba(74, 158, 255, 0.15);
    border-color: #4a9eff;
}

.battlefield-wrapper {
    width: 100%;
    height: 0;
    flex: 1;
    min-height: 0;
    background-color: #2a2a2a;
    border: 2px solid #3a3a3a;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none; /* Prevent default touch behaviors like scrolling */
    overflow: hidden;
}

.battlefield-svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    touch-action: none; /* Prevent default touch behaviors */
    user-select: none; /* Prevent text selection on drag */
    -webkit-user-select: none;
}


/* Base Modal */
.base-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 1rem;
}

/* Generic Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #2a2a2a;
    border: 2px solid #3a3a3a;
    border-radius: 8px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    margin: 0 0 0.5rem 0;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
}

.modal-content .auth-subtitle {
    margin: 0 0 1.5rem 0;
    color: #aaa;
    font-size: 0.95rem;
    text-align: center;
}

.modal-content p {
    margin: 0 0 1.5rem 0;
    color: #e0e0e0;
    font-size: 0.95rem;
    line-height: 1.5;
    text-align: center;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #fff;
}

.button {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    border: 2px solid transparent;
}

.button-primary {
    background: linear-gradient(135deg, #4a9eff 0%, #357abd 100%);
    color: #fff;
    border-color: #4a9eff;
}

.button-primary:hover {
    background: linear-gradient(135deg, #357abd 0%, #4a9eff 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.4);
}

.button-secondary {
    background: transparent;
    color: #e0e0e0;
    border-color: #3a3a3a;
}

.button-secondary:hover {
    background: #3a3a3a;
    border-color: #4a9eff;
    color: #4a9eff;
}

/* Auth Pages */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background: #1a1a1a;
}

.auth-card {
    background: #2a2a2a;
    border: 2px solid #3a3a3a;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.auth-card h1 {
    margin: 0 0 0.5rem 0;
    color: #fff;
    font-size: 2rem;
    font-weight: 600;
    text-align: center;
}

.auth-subtitle {
    text-align: center;
    color: #aaa;
    margin: 0 0 2rem 0;
    font-size: 0.95rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    color: #e0e0e0;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-input {
    padding: 0.75rem;
    background: #1a1a1a;
    border: 2px solid #3a3a3a;
    border-radius: 6px;
    color: #fff;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

.form-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-input::placeholder {
    color: #666;
}

.auth-error {
    background: rgba(255, 66, 77, 0.1);
    border: 1px solid rgba(255, 66, 77, 0.3);
    border-radius: 6px;
    padding: 0.75rem;
    color: #ff6b6b;
    font-size: 0.9rem;
    text-align: center;
}

.auth-success-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    background: rgba(74, 158, 255, 0.1);
    border: 3px solid #4a9eff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #4a9eff;
    font-weight: bold;
}

.auth-help-text {
    color: #aaa;
    font-size: 0.9rem;
    text-align: center;
    margin: 0.5rem 0;
}

.auth-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.auth-submit {
    width: 100%;
    margin-top: 0.5rem;
}

.auth-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #3a3a3a;
    text-align: center;
}

.auth-footer p {
    margin: 0;
    color: #aaa;
    font-size: 0.9rem;
}

.auth-link {
    color: #4a9eff;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.auth-link:hover {
    color: #6bb3ff;
    text-decoration: underline;
}

.forgot-password-link {
    text-align: right;
    font-size: 0.85rem;
    margin-top: -0.5rem;
}

/* Account Page */
.account-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #3a3a3a;
}

.account-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.account-section h2 {
    margin: 0 0 1rem 0;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 600;
}

.account-section h3 {
    margin: 0 0 1rem 0;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
}

.account-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.account-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(26, 26, 26, 0.5);
    border-radius: 6px;
}

.account-label {
    color: #aaa;
    font-size: 0.9rem;
    font-weight: 500;
}

.account-value {
    color: #e0e0e0;
    font-size: 0.9rem;
}

.account-warning {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 6px;
}

.account-warning p {
    margin: 0 0 0.5rem 0;
    color: #ffc107;
    font-size: 0.9rem;
}

.account-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.subscription-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
}

.subscription-active {
    background: rgba(74, 158, 255, 0.2);
    color: #4a9eff;
    border: 1px solid rgba(74, 158, 255, 0.3);
}

.subscription-canceled {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.subscription-past_due {
    background: rgba(255, 66, 77, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(255, 66, 77, 0.3);
}

/* Account Modal Styles */
.account-modal-content {
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.account-modal-content h2 {
    margin: 0 0 1.5rem 0;
    color: #fff;
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
}

.account-status-verified {
    color: #4a9eff;
    font-weight: 600;
}

.account-status-unverified {
    color: #ff6b6b;
    font-weight: 600;
}

.account-logout-btn {
    background: rgba(255, 66, 77, 0.1) !important;
    border-color: #ff424d !important;
    color: #ff6b6b !important;
}

.account-logout-btn:hover {
    background: rgba(255, 66, 77, 0.2) !important;
    border-color: #ff6b6b !important;
    color: #ff8a8a !important;
}

.base-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 9999;
}

.base-modal-content {
    background-color: #2a2a2a;
    border: 2px solid #4a9eff;
    border-radius: 8px;
    padding: 1rem;
    min-width: 200px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.9);
    position: relative;
    z-index: 10001;
}

.base-size-selector-content {
    min-width: 400px;
    max-width: 600px;
}

.base-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #3a3a3a;
    padding-bottom: 0.75rem;
}

.base-modal-header h3 {
    margin: 0;
    color: #fff;
    font-size: 1.1rem;
}

.base-modal-close {
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.base-modal-close:hover {
    background-color: #3a3a3a;
}

.base-modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.base-modal-btn {
    background-color: #3a3a3a;
    border: 2px solid #4a4a4a;
    border-radius: 6px;
    padding: 0.75rem;
    cursor: pointer;
    color: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    min-width: 50px;
    min-height: 50px;
}

.base-modal-btn:hover {
    background-color: #4a4a4a;
    border-color: #4a9eff;
    transform: translateY(-2px);
}

.base-modal-btn:active {
    transform: translateY(0);
}

.base-modal-btn-danger:hover {
    background-color: #5a2a2a;
    border-color: #ff4a4a;
}

.base-modal-btn.active {
    background-color: #2a4a6a;
    border-color: #4a9eff;
}

.base-sizes-grid-modal {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-height: 50vh;
    overflow-y: auto;
}

.base-size-item-modal {
    padding: 0.75rem;
    background-color: #1a1a1a;
    border: 2px solid #3a3a3a;
    border-radius: 4px;
    color: #e0e0e0;
    text-align: center;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.base-size-item-modal:hover {
    border-color: #4a9eff;
    background-color: #2f3a4a;
    transform: translateY(-1px);
}

.base-size-item-modal:active {
    transform: translateY(0);
}

.support-text {
    letter-spacing: 0.5px;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }
    
    .base-sizes-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.35rem;
    }
    
    .toolbar {
        padding: 0.4rem 0.75rem;
    }
    
    .toolbar-controls {
        gap: 0.35rem;
    }
    
    .toolbar-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }
    
    .toolbar-btn svg {
        width: 12px;
        height: 12px;
    }
    
    .toolbar-btn-icon-only {
        padding: 0.3rem 0.45rem;
    }
}

/* Shortcuts Popup */
.shortcuts-popup {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(145deg, #2a2a2a 0%, #1e1e1e 100%);
    border: 1px solid #444;
    border-radius: 12px;
    padding: 0;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    min-width: 280px;
    max-width: 360px;
    overflow: hidden;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.shortcuts-popup.hidden {
    display: none;
}

.shortcuts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(74, 158, 255, 0.1);
    border-bottom: 1px solid #444;
}

.shortcuts-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #4a9eff;
    margin: 0;
}

.shortcuts-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.shortcuts-close:hover {
    color: #fff;
}

.shortcuts-content {
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.shortcut-group {
    margin-bottom: 0;
}

.shortcut-group h4 {
    font-size: 0.65rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid #333;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.2rem 0;
    font-size: 0.75rem;
    gap: 0.5rem;
}

.shortcut-item span {
    color: #ccc;
    text-align: right;
    flex: 1;
    font-size: 0.7rem;
}

.shortcut-item kbd {
    flex-shrink: 0;
}

kbd {
    display: inline-block;
    background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
    border: 1px solid #555;
    border-radius: 4px;
    padding: 0.1rem 0.3rem;
    font-family: 'SF Mono', Monaco, 'Consolas', monospace;
    font-size: 0.65rem;
    color: #e0e0e0;
    box-shadow: 0 2px 0 #222;
    margin: 0 0.1rem;
    white-space: nowrap;
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .shortcuts-popup {
        bottom: 10px;
        right: 10px;
        left: 10px;
        min-width: auto;
        max-width: none;
    }
    
    .shortcuts-content {
        grid-template-columns: 1fr;
        gap: 0.4rem;
        padding: 0.4rem 0.6rem;
    }
    
    .shortcut-group h4 {
        font-size: 0.6rem;
        margin-bottom: 0.25rem;
    }
    
    .shortcut-item {
        padding: 0.15rem 0;
        font-size: 0.7rem;
    }
    
    .shortcut-item span {
        font-size: 0.65rem;
    }
    
    kbd {
        font-size: 0.6rem;
        padding: 0.08rem 0.25rem;
    }
    
    .app-title {
        font-size: 1.2rem;
    }
    
    .header {
        padding: 0.4rem 0.75rem;
        position: relative;
        z-index: 100;
    }
    
    .support-link-header {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .main-content {
        flex-direction: column-reverse; /* Board on top, sidebar on bottom */
    }
    
    .sidebar {
        width: 100%;
        max-height: 35vh; /* Limit sidebar to 35% of viewport */
        border-right: none;
        border-top: 2px solid #3a3a3a;
        padding: 0.5rem;
        overflow-y: auto; /* Allow scrolling if needed */
        display: flex;
        flex-direction: column;
    }
    
    .sidebar h2 {
        font-size: 0.85rem;
        margin-bottom: 0.3rem;
        cursor: pointer;
        user-select: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.3rem 0;
    }
    
    .sidebar h2::after {
        content: '▼';
        font-size: 0.7rem;
        transition: transform 0.2s;
    }
    
    .selector-section.collapsed h2::after {
        transform: rotate(-90deg);
    }
    
    .selector-section.collapsed .selector-dropdown,
    .selector-section.collapsed .base-sizes-grid,
    .selector-section.collapsed .shape-selector-container {
        display: none;
    }
    
    .section-header-with-categories {
        gap: 0.3rem;
    }
    
    .category-buttons {
        gap: 0.25rem;
    }
    
    .category-btn {
        padding: 0.25rem 0.35rem;
        font-size: 0.7rem;
    }
    
    .selector-section {
        margin-bottom: 0.5rem;
    }
    
    .selector-section:last-of-type {
        margin-bottom: 0;
    }
    
    .sidebar-footer {
        padding-top: 0.5rem;
        padding-bottom: 0.25rem;
        font-size: 0.75rem;
    }
    
    .selector-dropdown {
        padding: 0.4rem;
        font-size: 0.85rem;
    }
    
    .base-sizes-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 0.25rem;
    }
    
    .base-size-item {
        padding: 0.3rem 0.15rem;
        font-size: 0.65rem;
    }
    
    .battlefield-container {
        flex: 1;
        min-height: auto; /* Let it size naturally on mobile */
        padding: 0.15rem 0.2rem; /* Minimal padding for mobile */
        position: relative;
        display: flex;
        flex-direction: column;
    }
    
    .toolbar {
        padding: 0.35rem 0.5rem;
        margin-bottom: 0;
        margin-top: 0.5rem; /* Space above toolbar when it's below */
        flex-shrink: 0; /* Don't shrink toolbar */
        width: 100%;
        box-sizing: border-box;
        z-index: 50;
        order: 2; /* Move toolbar after battlefield on mobile */
    }
    
    .toolbar-section-title {
        font-size: 0.65rem;
        margin-right: 0.35rem;
    }
    
    /* Hide "Options" text on mobile, keep Unit/Map/Measurement */
    #toolbar-unit .toolbar-section-title {
        font-size: 0;
    }
    
    #toolbar-unit .toolbar-section-title::after {
        content: 'Unit';
        font-size: 0.65rem;
    }
    
    #toolbar-measurement .toolbar-section-title {
        font-size: 0;
    }
    
    #toolbar-measurement .toolbar-section-title::after {
        content: 'Measurement';
        font-size: 0.65rem;
    }
    
    #toolbar-map .toolbar-section-title {
        font-size: 0;
    }
    
    #toolbar-map .toolbar-section-title::after {
        content: 'Map';
        font-size: 0.65rem;
    }
    
    .toolbar-controls {
        gap: 0.3rem;
    }
    
    .toolbar-btn {
        padding: 0.28rem 0.45rem;
        font-size: 0.65rem;
        gap: 0.25rem;
    }
    
    .toolbar-btn svg {
        width: 11px;
        height: 11px;
    }
    
    .toolbar-btn span {
        display: none; /* Hide text labels on mobile, keep icons only */
    }
    
    .toolbar-btn-icon-only span {
        display: none; /* Already hidden */
    }
    
    .toolbar-btn-small {
        padding: 0.22rem 0.38rem;
        font-size: 0.65rem;
    }
    
    .battlefield-wrapper {
        flex: 1;
        min-height: 0; /* Allow shrinking */
        order: 1; /* Keep battlefield before toolbar on mobile */
        margin-bottom: 0;

    }
    
    /* Make base size modal more compact on mobile */
    .base-size-selector-content {
        min-width: 85vw;
        max-width: 90vw;
        padding: 0.5rem;
    }
    
    .base-modal-header {
        margin-bottom: 0.75rem;
        padding-bottom: 0.4rem;
    }
    
    .base-modal-header h3 {
        font-size: 0.9rem;
    }
    
    .base-sizes-grid-modal {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.3rem;
        max-height: 50vh;
    }
    
    .base-size-item-modal {
        padding: 0.5rem 0.2rem;
        font-size: 0.7rem;
    }
}

/* Responsive - Very Small Mobile */
@media (max-width: 480px) {
    .app-title {
        font-size: 1rem;
    }
    
    .header-nav-link {
        font-size: 0.8rem;
        padding: 0.3rem 0.5rem;
    }
    
    .support-text {
        display: none; /* Just show icon on very small screens */
    }
    
    .base-sizes-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 0.2rem;
    }
    
    .base-size-item {
        padding: 0.25rem 0.1rem;
        font-size: 0.6rem;
    }
    
    .toolbar-section-title {
        display: none; /* Hide section titles on very small screens */
    }
    
    .toolbar-btn {
        padding: 0.3rem;
        min-width: 32px;
        min-height: 32px;
        justify-content: center;
    }
    
    .toolbar-btn-icon-only {
        padding: 0.3rem;
    }
}

/* Responsive - Extra Small Screens (< 360px) */
@media (max-width: 360px) {
    .header {
        padding: 0.3rem 0.5rem;
    }
    
    .app-title {
        font-size: 0.9rem;
    }
    
    .header-nav-link {
        font-size: 0.75rem;
        padding: 0.25rem 0.4rem;
    }
    
    .support-link-header {
        padding: 0.25rem 0.5rem;
    }
    
    .sidebar {
        padding: 0.4rem;
        max-height: 30vh; /* Less space on tiny screens */
    }
    
    .sidebar h2 {
        font-size: 0.8rem;
    }
    
    .category-btn {
        padding: 0.2rem 0.3rem;
        font-size: 0.65rem;
    }
    
    .sidebar-footer {
        padding-top: 0.4rem;
        padding-bottom: 0.2rem;
        font-size: 0.7rem;
    }
    
    .selector-dropdown {
        padding: 0.35rem;
        font-size: 0.8rem;
    }
    
    .base-sizes-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 0.15rem;
    }
    
    .base-size-item {
        padding: 0.2rem 0.05rem;
        font-size: 0.55rem;
    }
    
    .toolbar {
        padding: 0.3rem 0.4rem;
    }
    
    .toolbar-btn {
        padding: 0.25rem;
        min-width: 30px;
        min-height: 30px;
    }
    
    .toolbar-btn svg {
        width: 10px;
        height: 10px;
    }
    
    .base-size-selector-content {
        min-width: 92vw;
        padding: 0.4rem;
    }
    
    .base-modal-header h3 {
        font-size: 0.85rem;
    }
    
    .base-sizes-grid-modal {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.25rem;
    }
    
    .base-size-item-modal {
        padding: 0.4rem 0.15rem;
        font-size: 0.65rem;
    }
}

